1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| Title = "Text2Speech Powered by © Google"
inputLang = InputBox("Indiquez la Langue :"&vbcr& "- 1 pour Français "&vbcr& "- 2 pour Anglais "&vbcr& "- 3 العربية",Title,"1")
Set ws = CreateObject("wscript.shell")
set fso = CreateObject("scripting.FileSystemObject")
select case inputLang
case 1
input = InputBox("Indiquez un texte à lire",Title,"Salut tout le Monde!") ' French
MsgBox "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=" &Escape(input)
URL"http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=" &Escape(input)
Download2MP3 "http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=" &Escape(input),"c:\Text2speech-fr.mp3"
If fso.FileExists("c:\Text2speech-fr.mp3") Then
ws.run "wmplayer.exe c:\Text2speech-fr.mp3",0,True
TerminateProcess "iexplore.exe"
TerminateProcess "wmplayer.exe"
end if
case 2
input = InputBox("Enter text to speech",Title,"Hello World") 'English
MsgBox "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=" &Escape(input)
URL"http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=" &Escape(input)
Download2MP3 "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=" &Escape(input),"c:\Text2speech-en.mp3"
If fso.FileExists("c:\Text2speech-en.mp3") Then
ws.run "wmplayer.exe c:\Text2speech-en.mp3",0,True
TerminateProcess "iexplore.exe"
TerminateProcess "wmplayer.exe"
end if
Case 3
input = InputBox("أدخل النص للخطاب",Title,"199") ' Arabic
MsgBox "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=" &Escape(input)
URL"http://translate.google.com/translate_tts?ie=UTF-8&tl=ar&q=" &Escape(input)
Download2MP3 "http://translate.google.com/translate_tts?ie=UTF-8&tl=ar&q=" &Escape(input),"c:\Text2speech-ar.mp3"
If fso.FileExists("c:\Text2speech-ar.mp3") Then
ws.run "wmplayer.exe c:\Text2speech-ar.mp3",0,True
TerminateProcess "iexplore.exe"
TerminateProcess "wmplayer.exe"
end if
end select
Function Download2MP3(URL,strHDLocation)
Set objXMLHTTP = CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "GET", URL, False
objXMLHTTP.Send
Set objStream = createobject("Adodb.Stream")
objStream.type = 1
objStream.open
objStream.write objXMLHTTP.responseBody
objStream.savetofile strHDLocation, 2
objStream.close
set objStream = nothing
Set objXMLHTTP = Nothing
End Function
Function URL(adress)
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate(adress)
ie.Visible=False
DO While ie.busy
WScript.Sleep 20
Loop
end Function
Sub TerminateProcess(App)
Ws.Run "cmd /C taskkill /f /im "&App&"",0,TRUE
End Sub
Function Escape(str)
Dim strNocode,out,Car,i
strNocode = "*+-./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
out = ""
If Len(str) > 0 Then
str = Replace(str, " ", "+")
For i = 1 To Len(str)
Car = Mid(str, i, 1)
If InStr(strNocode, Car) Then
out = out & Car
Else
out = out & "%" & Hex(Asc(Car))
End If
Next
End If
Escape = out
End Function |
Partager