Google speech in Vbscript
-
Monday, April 09, 2012 10:43 AM
Hi
I want to perform a Google speech in vbscript but i have some issues with this code :
input = InputBox("Enter a text to Speak","Enter a text to Speak") HTTPDownload "http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=" &input,"c:\Gspeak.mp3" Sub HTTPDownload(strFileURL,strHDLocation) 'MsgBox "http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=" &input Set Ws = CreateObject("WScript.Shell") Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP") objXMLHTTP.open "GET", strFileURL, false objXMLHTTP.send() If objXMLHTTP.Status = 200 Then Set objADOStream = CreateObject("ADODB.Stream") objADOStream.Open objADOStream.Type = 1 'adTypeBinary objADOStream.Write objXMLHTTP.ResponseBody objADOStream.Position = 0 'Set the stream position to the start Set objFSO = Createobject("Scripting.FileSystemObject") If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation Set objFSO = Nothing objADOStream.SaveToFile strHDLocation objADOStream.Close Set objADOStream = Nothing End If Set objXMLHTTP = Nothing Ws.Run strHDLocation Set WS = Nothing End SubSo i get this Error
Line 10 Caract :5
The system cannot locate the resource specified
Code : 800C0005
msxml3.dll
All Replies
-
Monday, April 09, 2012 11:41 AM
Start here:
HTTPDownload "http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=hello you idiot","e:\test2\Gspeak.mp3" Sub HTTPDownload(strFileURL,strHDLocation) Set objXMLHTTP = CreateObject("Msxml2.XMLHTTP.4.0") objXMLHTTP.open "GET", strFileURL, False objXMLHTTP.send() If objXMLHTTP.Status = 200 Then Set objADOStream = CreateObject("ADODB.Stream") objADOStream.Open objADOStream.Type = 1 'adTypeBinary objADOStream.Write objXMLHTTP.ResponseBody objADOStream.Position = 0 'Set the stream position to the start objADOStream.SaveToFile strHDLocation, 2 'overwrite file objADOStream.Close Set Ws = CreateObject("WScript.Shell") Ws.Run strHDLocation Else WScript.Echo "Status not good:" & objXMLHTTP.Status End If End SubIre moved some mistakes in logic and unnecessary lines of code. I also switched to using teh newer MSXNL4 which should exists on all systems post XP.
If that fails use MSXML2.XMLHTTP which should load the latest version available.
Your XML nay be damaged
Objects will be set to n0othing by system when subroutine exits. Setting them to nothing is not normally necessary in scripting.
¯\_(ツ)_/¯
- Edited by jrvMicrosoft Community Contributor Monday, April 09, 2012 11:44 AM
- Edited by jrvMicrosoft Community Contributor Monday, April 09, 2012 11:46 AM
- Proposed As Answer by Richard MuellerMVP, Moderator Wednesday, April 18, 2012 1:59 AM
- Marked As Answer by IamMredMicrosoft Employee, Owner Thursday, April 19, 2012 10:30 PM
-
Monday, April 09, 2012 1:12 PM
I'm under Windows XP SP3 and i have the same Error :(Start here:
HTTPDownload "http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=hello you idiot","e:\test2\Gspeak.mp3" Sub HTTPDownload(strFileURL,strHDLocation) Set objXMLHTTP = CreateObject("Msxml2.XMLHTTP.4.0") objXMLHTTP.open "GET", strFileURL, False objXMLHTTP.send() If objXMLHTTP.Status = 200 Then Set objADOStream = CreateObject("ADODB.Stream") objADOStream.Open objADOStream.Type = 1 'adTypeBinary objADOStream.Write objXMLHTTP.ResponseBody objADOStream.Position = 0 'Set the stream position to the start objADOStream.SaveToFile strHDLocation, 2 objADOStream.Close Set Ws = CreateObject("WScript.Shell") Ws.Run strHDLocation Else WScript.Echo "Status not good:" & objXMLHTTP.Status End If End SubIre moved some mistakes in logic and unnecessary lines of code. I also switched to using teh newer MSXNL4 which should exists on all systems post XP.
¯\_(ツ)_/¯
-
Monday, April 09, 2012 3:34 PMModeratorThe way I read the error message you provided in your original post, the file pointed to by the registry entry for "MSXML2.XMLHTTP" is missing. That is, check to see if the file msxml3.dll is present in your Windows\System32 folder. If it's not there you will need to find a copy and put it there. If it is there you will need to reregister it.
Tom Lavedas
-
Monday, April 09, 2012 3:55 PM
I'm under Windows XP SP3 and i have the same Error :(
This code runs perfectly under Win7. Your XML installation is corrupted and/or has missing files.
¯\_(ツ)_/¯
-
Tuesday, April 10, 2012 2:59 PM
Check the file path.I'm under Windows XP SP3 and i have the same Error :(
This code runs perfectly under Win7. Your XML installation is corrupted and/or has missing files.
¯\_(ツ)_/¯
-
Tuesday, April 10, 2012 5:48 PM
Check the file path.I'm under Windows XP SP3 and i have the same Error :(
This code runs perfectly under Win7. Your XML installation is corrupted and/or has missing files.
¯\_(ツ)_/¯
What file path. When we create an object there is no file path.
You will always get errors in an HTML page. If you use vbscript or an HTA file it will work.
Windows XP may not have XML 4.0 installed by default or it may have become damaged.
No - paths sre not an issue with automation calls.
¯\_(ツ)_/¯

