Sign in to follow this  
Followers 0
Danyfirex

Text-to-Speech ISpVoice Interface

3 posts in this topic

Well I was learning about  this great autoit function (ObjCreateInterface) and make this  simple example using ISpVoice.

;Gracias
;http://cyberdays.ru/govoryashhaya-programma


Local Const $CLSID_SpVoice= "{96749377-3391-11D2-9EE3-00C04F797396}"
Local Const $IID_ISpVoice="{6C44DF74-72B9-4992-A1EC-EF996E0422D4}"
Local Const $SPF_DEFAULT = 0

Local Const $sSpVoice = "SetNotifySink hresult(ptr)" & _
           "SetNotifyWindowMessage hresult(hwnd;uint;long;long);" & _
           "SetNotifyCallbackFunction hresult(ptr;long,long);" & _
           "SetNotifyCallbackInterface hresult(ptr;long,long);" & _
           "SetNotifyWin32Event hresult();" & _
           "WaitForNotifyEvent hresult(dword);" & _
           "GetNotifyEventHandle hresult();" & _
           "SetInterest hresult(long;long);" & _
           "GetEvents hresult(ulong;ptr;ptr)" & _
           "GetInfo hresult(ptr);" & _
           "SetOutput hresult(ptr;boolean);" & _
           "GetOutputObjectToken hresult(ptr);" & _
           "GetOutputStream result(ptr);" & _
           "Pause hresult();" & _
           "Resume hresult();" & _
           "SetVoice hresult(ptr);" & _
           "GetVoice hresult(ptr);" & _
           "Speak hresult(wstr;dword;ulong);" & _
           "SpeakStream hresult(ptr;dword;ulong);" & _
           "GetStatus hresult(ptr;ptr);" & _
           "Skip hresult(wstr;long;ulong);" & _
           "SetPriority hresult(long);" & _
           "GetPriority hresult(ptr);" & _
           "SetAlertBoundary hresult(long);" & _
           "GetAlertBoundary hresult(ptr);" & _
           "SetRate hresult(long);" & _
           "GetRate hresult(ptr);" & _
           "SetVolume hresult(ushort);" & _
           "GetVolume hresult(ptr);" & _
           "WaitUntilDone hresult(ulong);" & _
           "SetSyncSpeakTimeout  hresult(ulong);" & _
           "GetSyncSpeakTimeout hresult(ptr);" & _
           "SpeakCompleteEvent hresult();" & _
           "IsUISupported hresult(ptr;ptr;ptr;ptr);" & _
           "DisplayUI hresult(hwnd;ptr;ptr;ptr;ulong);"

Local $oSpVoice = ObjCreateInterface($CLSID_SpVoice, $IID_ISpVoice, $sSpVoice)
$oSpVoice.SetRate(-3)
$oSpVoice.speak("¿Hi Autoit Forum, Are you Okay?",$SPF_DEFAULT,0)
Exit

Saludos

Share this post


Link to post
Share on other sites



Hi Danyfirex

interesting to learn,

here there is a version with the interface already created.

bye


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Yes I know. but the that uses ObjCreate. and this use ObjCreateInterface.

 

Saludos

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • Ontosy
      By Ontosy
      I have tryed to compile this "com object" and then use with AutoIt3 but not work: "err.number 0x80020006.
      How to do?
      #include-once Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local Const $sCLSID_TaskbarList = "{7233b105-bc01-41ff-b72e-582c5954b76d}" Local Const $sIID_ITaskbarList = "{702d63b3-d7d1-4f17-ab11-2f2ed770fdc8}" Local Const $sTagITaskbarList = 'SetString(wstr:cdecl);wstr:cdecl GetString();' Local $oIExample = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList) $a=$oIExample.SetString("Abc") msgbox(0,@error,$a) $a=$oIExample.GetString() ;.GetRootElement.CurrentClassName exit msgbox(0,0,$a) Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc  
    • Danyfirex
      By Danyfirex
      well. Reading in msdn I found an interface to run a Gadget. So I wrote it. 
       
      #include <Array.au3> #include <File.au3> Global Const $sCLSID_DesktopGadget = "{924CCC1B-6562-4C85-8657-D177925222B6}" Global Const $sIID_IDesktopGadget = "{C1646BC4-F298-4F91-A204-EB2DD1709D1A}" Global Const $sTagIDesktopGadget = "RunGadget hresult(wstr);" Global Enum $eNoShared = 1, $eShared, $eAll Local $aGadGets = _GetGadget($eAll) If IsArray($aGadGets) Then For $i = 1 To $aGadGets[0] If StringInStr($aGadGets[$i], "CPU") Then ;Run CPU GadGet RunGadget($aGadGets[$i]) EndIf Next EndIf Func RunGadget($sGadGetPath) Local $oDesktopGadget = ObjCreateInterface($sCLSID_DesktopGadget, $sIID_IDesktopGadget, $sTagIDesktopGadget) if not IsObj($oDesktopGadget) then Return False return SUCCEEDED($oDesktopGadget.RunGadget($sGadGetPath)) EndFunc ;==>RunGadget Func _GetGadget($GadgetType = $eNoShared) Local $aNoSharedGadGets = 0 Local $aSharedGadGets = 0 Local $aGadGets = 0 Local $Size = 0 Local Const $sSharedGadget = @ProgramFilesDir & "\Windows Sidebar\Shared Gadgets" Local Const $sNoShared = @ProgramFilesDir & "\Windows Sidebar\Gadgets" If $GadgetType < $eNoShared Or $GadgetType > $eAll Then Return 0 If BitAND($GadgetType, $eNoShared) Then $aNoSharedGadGets = _FileListToArray($sNoShared, Default, Default, True) If BitAND($GadgetType, $eShared) Then $aSharedGadGets = _FileListToArray($sSharedGadget, Default, Default, True) If IsArray($aSharedGadGets) And IsArray($aNoSharedGadGets) Then $Size = UBound($aNoSharedGadGets) - 1 + (UBound($aSharedGadGets) - 1) _ArrayConcatenate($aNoSharedGadGets, $aSharedGadGets, 1) $aGadGets = $aNoSharedGadGets $aGadGets[0] = $Size Else If IsArray($aSharedGadGets) Then $aGadGets = $aSharedGadGets If IsArray($aNoSharedGadGets) Then $aGadGets = $aNoSharedGadGets EndIf $aSharedGadGets = 0;Free $aNoSharedGadGets = 0 ;Free Return $aGadGets EndFunc ;==>_GetGadget Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED Saludos
       
       
       
    • Danyfirex
      By Danyfirex
      Well. I was needing to create a networks shortcut. so I did find anything into the forum. So I write this after reading about Nonfile Object.
       
      ;~ Danyfirex 26/07/2015 #include <WinAPIShellEx.au3> Opt("MustDeclareVars", 1) Global Const $SHCONTF_NONFOLDERS = 0x00040 Global Const $SHGDN_NORMAL = 0 Global Const $S_OK = 0 Global Const $sTagSTRRET = "UINT uType;ptr pOleStr;UINT uOffset;CHAR cStr[256]" Global Const $CLSID_ShellLink = "{00021401-0000-0000-C000-000000000046}" Global Const $sIID_IShellLinkW = "{000214F9-0000-0000-C000-000000000046}" Global Const $sTagIShellLink = "getpath hresult(long;long;long;long); " & _ "getidlist hresult(ptr); " & _ "setidlist hresult(ptr); " & _ "getdescription hresult(long;long); " & _ "setdescription hresult(wstr); " & _ "getworkingdirectory hresult(long;long); " & _ "setworkingdirectory hresult(long); " & _ "getarguments hresult(long;long); " & _ "setarguments hresult(ptr); " & _ "gethotkey hresult(long); " & _ "sethotkey hresult(word); " & _ "getshowcmd hresult(long); " & _ "setshowcmd hresult(int); " & _ "geticonlocation hresult(long;long;long); " & _ "seticonlocation hresult(wstr;int); " & _ "setrelativepath hresult(long;long); " & _ "resolve hresult(long;long); " & _ "setpath hresult(wstr)" Global Const $sIID_IPersistFile = "{0000010b-0000-0000-C000-000000000046}" Global Const $sTagIPersistFile = "GetClassID hresult(long); IsDirty hresult(); Load hresult(long;long); Save hresult(wstr;bool); SaveCompleted hresult(long); GetCurFile hresult(long)" Global Const $sIID_IEnumIDList = "{000214F2-0000-0000-C000-000000000046}" Global Const $sTagIEnumIDList = "Next hresult(ulong;ptr*;ulong*);" & _ "Reset hresult();" & _ "Skip hresult(ulong);" & _ "Clone hresult(ptr*);" Global Const $sIID_IShellFolder = "{000214E6-0000-0000-C000-000000000046}" Global Const $sTagIShellFolder = "ParseDisplayName hresult(hwnd;ptr;wstr;ulong*;ptr*;ulong*);" & _ "EnumObjects hresult(hwnd;dword;ptr*);" & _ "BindToObject hresult(ptr;ptr;clsid;ptr*);" & _ "BindToStorage hresult(ptr*;ptr;clsid;ptr*);" & _ "CompareIDs hresult(lparam;ptr*;ptr*);" & _ "CreateViewObject hresult(hwnd;clsid;ptr*);" & _ "GetAttributesOf hresult(uint:ptr*;ulong*);" & _ "GetUIObjectOf hresult(hwnd;uint;ptr*;clsid;uint*;ptr*);" & _ "GetDisplayNameOf hresult(ptr;dword;ptr);" & _ "SetNameOf hresult(hwnd;ptr*;wstr;dword;ptr*);" Local $MyNetWorkConnectionName="Conexión de red inalámbrica" CreateNetWorkConnectionShortCut($MyNetWorkConnectionName) ;~ Success: Return True ;~ Failure: Return False ;~ if $lnkPath = "" ShortCut will be Create on Desktop with the name of the Conections($sConnectionName) Func CreateNetWorkConnectionShortCut($sConnectionName, $lnkPath = "") Local $pConecctionsFolder = 0 Local $oConecctionsFolder = 0 Local $pEnumIDList = 0 Local $oEnumIDList = 0 Local $pPIDLItem = 0 Local $celtFetched = 0 Local $pPIDLConectionsFolder = 0 Local $bRet = False Local $tSTRRET = 0 Local $twstring = 0 Local $pShellFolder = SHGetDesktopFolder() Local $oShellFolder = ObjCreateInterface($pShellFolder, $sIID_IShellFolder, $sTagIShellFolder) If @error Then Return $bRet $pPIDLConectionsFolder = _WinAPI_ShellGetSpecialFolderLocation($CSIDL_CONNECTIONS) If SUCCEEDED($oShellFolder.BindToObject($pPIDLConectionsFolder, Null, $sIID_IShellFolder, $pConecctionsFolder)) Then $oConecctionsFolder = ObjCreateInterface($pConecctionsFolder, $sIID_IShellFolder, $sTagIShellFolder) If IsObj($oConecctionsFolder) Then If SUCCEEDED($oConecctionsFolder.EnumObjects(Null, $SHCONTF_NONFOLDERS, $pEnumIDList)) Then $oEnumIDList = ObjCreateInterface($pEnumIDList, $sIID_IEnumIDList, $sTagIEnumIDList) If IsObj($oEnumIDList) Then $tSTRRET = DllStructCreate($sTagSTRRET) While (SUCCEEDED($oEnumIDList.Next(1, $pPIDLItem, $celtFetched)) And $celtFetched > 0) If SUCCEEDED($oConecctionsFolder.GetDisplayNameOf($pPIDLItem, $SHGDN_NORMAL, DllStructGetPtr($tSTRRET))) Then $twstring = DllStructCreate("wchar Name[512]", $tSTRRET.pOleStr) If $twstring.Name = $sConnectionName Then If $lnkPath = "" Then $lnkPath = @DesktopDir & "\" & $twstring.Name & ".lnk" $bRet = CreateLnk($pPIDLConectionsFolder, $pPIDLItem, $lnkPath) ExitLoop EndIf $twstring = 0 EndIf WEnd EndIf EndIf EndIf EndIf If $pPIDLConectionsFolder Then _WinAPI_CoTaskMemFree($pPIDLConectionsFolder) Return $bRet EndFunc ;==>CreateNetWorkShortCut Func CreateLnk($PIDL1, $PIDL2, $lnkPath) Local $oShellLink = 0 Local $oIPersistFile = 0 Local $pIPersistFile = 0 Local $pAppendID = 0 Local $bRet = False $oShellLink = ObjCreateInterface($CLSID_ShellLink, $sIID_IShellLinkW, $sTagIShellLink) If @error Then Return $bRet $pAppendID = ILAppendID($PIDL1, $PIDL2) If IsObj($oShellLink) And $pAppendID Then If SUCCEEDED($oShellLink.SetIDList($pAppendID)) Then $oShellLink.QueryInterface($sIID_IPersistFile, $pIPersistFile) $oIPersistFile = ObjCreateInterface($pIPersistFile, $sIID_IPersistFile, $sTagIPersistFile) If IsObj($oIPersistFile) Then $bRet = SUCCEEDED($oIPersistFile.Save($lnkPath, True)) EndIf EndIf EndIf Return $bRet EndFunc ;==>CreateLnk Func ILAppendID($PIDLIST_RELATIVE, $LPSHITEMID, $fAppend = True) Local $aRet = DllCall("Shell32.dll", "ptr", "ILAppendID", "ptr", $PIDLIST_RELATIVE, "ptr", $LPSHITEMID, "bool", $fAppend) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] = 0 Then Return SetError(10, $aRet[0], 0) Return $aRet[0] EndFunc ;==>ILAppendID Func SHGetDesktopFolder() Local $aRet = DllCall("Shell32.dll", "long", "SHGetDesktopFolder", "ptr*", Null) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return $aRet[1] EndFunc ;==>SHGetDesktopFolder Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED Saludos
    • Danyfirex
      By Danyfirex
      A simple example of listing installed applications using ObjCreateInterface.
      Update.  10/09/2014
      ;Danyfirex 06/09/2014 #include <Array.au3> Opt("MustDeclareVars", 1) Global Const $sTagAppInfoData = "UINT cbSize;UINT dwMask;ptr pszDisplayName;ptr pszVersion;ptr pszPublisher;ptr pszProductID;" & _ "ptr pszRegisteredOwner;ptr pszRegisteredCompany;ptr pszLanguage;ptr pszSupportUrl;ptr pszSupportTelephone;" & _ "ptr pszHelpLink;ptr pszInstallLocation;ptr pszInstallSource;ptr pszInstallDate;ptr pszContact;ptr pszComments;" & _ "ptr pszImage;ptr pszReadmeUrl;ptr pszUpdateInfoUrl" Global Const $sCLSID_EnumInstalledApps = "{0B124F8F-91F0-11D1-B8B5-006008059382}" Global Const $sIID_IEnumInstalledApps = "{1BC752E1-9046-11D1-B8B3-006008059382}" Global Const $sTagIEnumInstalledApps = "Next hresult(ptr*);Reset hresult();" Global Const $sIID_IShellApp = "{A3E14960-935F-11D1-B8B8-006008059382}" Global Const $sShellApp = "GetAppInfoData hresult(ptr);" Global Const $AIM_DISPLAYNAME = 0x00000001 Global Const $AIM_VERSION = 0x00000002 Global Const $AIM_PUBLISHER = 0x00000004 Global Const $AIM_PRODUCTID = 0x00000008 Global Const $AIM_REGISTEREDOWNER = 0x00000010 Global Const $AIM_REGISTEREDCOMPANY = 0x00000020 Global Const $AIM_LANGUAGE = 0x00000040 Global Const $AIM_SUPPORTURL = 0x00000080 Global Const $AIM_SUPPORTTELEPHONE = 0x00000100 Global Const $AIM_HELPLINK = 0x00000200 Global Const $AIM_INSTALLLOCATION = 0x00000400 Global Const $AIM_INSTALLSOURCE = 0x00000800 Global Const $AIM_INSTALLDATE = 0x00001000 Global Const $AIM_CONTACT = 0x00004000 Global Const $AIM_COMMENTS = 0x00008000 Global Const $AIM_IMAGE = 0x00020000 Global Const $AIM_READMEURL = 0x00040000 Global Const $AIM_UPDATEINFOURL = 0x00080000 Local $aArray = GetInstalledApps(BitOR($AIM_DISPLAYNAME, $AIM_INSTALLDATE)) _ArrayDisplay($aArray, "GetInstalledApps", Default, Default, Default, "NAME|INSTALLDATE") $aArray = GetInstalledApps(BitOR($AIM_DISPLAYNAME, $AIM_UPDATEINFOURL)) _ArrayDisplay($aArray, "GetInstalledApps", Default, Default, Default, "DISPLAYNAME|UPDATEINFOURL") $aArray = GetInstalledApps(BitOR($AIM_DISPLAYNAME, $AIM_INSTALLDATE, $AIM_INSTALLLOCATION)) _ArrayDisplay($aArray, "GetInstalledApps", Default, Default, Default, "DISPLAYNAME|INSTALLLOCATION|INSTALLDATE") Func GetInstalledApps($iMask = $AIM_DISPLAYNAME) Local $oEnumInstalledApps = ObjCreateInterface($sCLSID_EnumInstalledApps, $sIID_IEnumInstalledApps, $sTagIEnumInstalledApps) If @error Then Return 0 Local $pShellApp = 0 Local $oShellApp = 0 Local $AppInfoData = DllStructCreate($sTagAppInfoData) Local $pAppInfoData = DllStructGetPtr($AppInfoData) Local $i = 0 Local $aArray[0][0] Local $iF = 1 Local $tData = 0 Local $sData = "" Local $aMax = nCol($iMask) While $oEnumInstalledApps.Next($pShellApp) = 0 And $pShellApp <> 0 $oShellApp = ObjCreateInterface($pShellApp, $sIID_IShellApp, $sShellApp) If @error Then Return 0 DllStructSetData($AppInfoData, "cbSize", DllStructGetSize($AppInfoData)) DllStructSetData($AppInfoData, "dwMask", $iMask) $oShellApp.GetAppInfoData($pAppInfoData) ReDim $aArray[$iF][UBound($aMax)] For $i = 0 To UBound($aMax) - 1 $tData = DllStructCreate("wchar[260]", DllStructGetData($AppInfoData, $aMax[$i] + 2)) $sData = DllStructGetData($tData, 1) If $aMax[$i] = 13 Then $sData = StringMid($sData, 7, 2) & "/" & StringMid($sData, 5, 2) & "/" & StringMid($sData, 1, 4) $aArray[$iF - 1][$i] = ($sData = "0") ? "" : $sData DllStructSetData($tData, 1, "") Next $oShellApp = Null $iF += 1 WEnd $oEnumInstalledApps = Null Return $aArray EndFunc ;==>GetInstalledApps Func nCol($iMask) Local $aFlag[18] = [$AIM_DISPLAYNAME, $AIM_VERSION, $AIM_PUBLISHER, $AIM_PRODUCTID, $AIM_REGISTEREDOWNER, $AIM_REGISTEREDCOMPANY, _ $AIM_LANGUAGE, $AIM_SUPPORTURL, $AIM_SUPPORTTELEPHONE, $AIM_HELPLINK, $AIM_INSTALLLOCATION, $AIM_INSTALLSOURCE, _ $AIM_INSTALLDATE, $AIM_CONTACT, $AIM_COMMENTS, $AIM_IMAGE, $AIM_READMEURL, $AIM_UPDATEINFOURL] Local $iCol = 0 Local $x = 0 Local $aCol[18] For $i = 0 To UBound($aFlag) - 1 If BitAND($iMask, $aFlag[$i]) Then $aCol[$x] = $i + 1 $x += 1 EndIf Next ReDim $aCol[$x] Return $aCol EndFunc ;==>nCol  
      Saludos
    • Inververs
      By Inververs
      I try to create interface_description for ObjCreateInterface function
      Here the part of interface:
      [id(0x00000002), propput, helpstring("Default")] HRESULT Default([in] BSTR TokenId); [id(0x00000002), propget, helpstring("Default")] HRESULT Default([out, retval] BSTR* TokenId); you can see that there are two the same method Default.
      first is [in], second is - [out].

      how to write a description of this?

      Default hresult(bstr;);Default hresult(bstr*); - is it correct?

      or so?
      Default hresult(bstr;bstr*);
      please help.