Page 1 sur 1
[Ex] google speech en autoit !
Posté : mar. 03 avr. 2012 01:07
par ethneldryt
Voila, rien de plus simple pour faire parler vos script!
Code : Tout sélectionner
#include <Sound.au3>
$input = InputBox("Que dire?","Indiquez un texte à lire")
if @error then exit
$input = StringReplace($input,"?","%3F")
InetGet("http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=" & $input,@TempDir & "\temp.mp3",1)
$sound = _SoundOpen(@TempDir & "\temp.mp3")
_SoundPlay($sound,1)
_SoundClose($sound)
Par contre pour la ponctuation, les caractères spéciaux genre : "ç" ne fonctionne pas.
Les longues phrases non plus ne fonctionne pas et j'arrive pas a savoir combien il y a de caractère maximum.
Si quelqu'un trouve la solution je suis preneur

Re: [Ex] google speech en autoit !
Posté : mar. 03 avr. 2012 01:32
par Iste
Bien trouvé !
► Afficher le texte
Code : Tout sélectionner
#include <Sound.au3>
$input = InputBox("Que dire?","Indiquez un texte à lire")
if @error then exit
$input = _URIEncode($input)
InetGet("http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=" & $input,@TempDir & "\temp.mp3",1)
$sound = _SoundOpen(@TempDir & "\temp.mp3")
_SoundPlay($sound,1)
_SoundClose($sound)
Func _URIEncode($sData)
; Prog@ndy
Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"")
Local $nChar
$sData=""
For $i = 1 To $aData[0]
ConsoleWrite($aData[$i] & @CRLF)
$nChar = Asc($aData[$i])
Switch $nChar
Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126
$sData &= $aData[$i]
Case 32
$sData &= "+"
Case Else
$sData &= "%" & Hex($nChar,2)
EndSwitch
Next
Return $sData
EndFunc
ca semble marcher mieux
Notez aussi qu'on peut changer le paramètre tl=fr pour d'autre langues
Re: [Ex] google speech en autoit !
Posté : mer. 04 avr. 2012 17:05
par Uranium
Les longues phrases non plus ne fonctionne pas et j'arrive pas a savoir combien il y a de caractère maximum.
Si quelqu'un trouve la solution je suis preneur

Exactement 98 caractères ( donc espaces ,virgules ect inclus )
Re: [Ex] google speech en autoit !
Posté : mer. 17 oct. 2012 18:11
par Popwers
Bonjour/Bonsoir
Après avoir eu besoin de "Google Speech", un problème c'est poser !
Celui de ne pas pouvoir lire une long chaîne de caractères,
Donc voila l'amélioration du script, qui permet maintenant de pouvoir lire une long chaîne de caractères !
Ce code a était fait avec l'aide de Uranium qui a compter pour nous le nombre de caractères maximal et le code de Iste qui a permis la lecture de caractères spéciale, En oubliant pas le Créateur ethneldryt.
Merci a eux !!
► Afficher le texteCode Autoit
Code : Tout sélectionner
#include <Sound.au3>
Global $END = 0,$sText,$sText1,$N = 1
$input = InputBox("Que dire?","Indiquez un texte à lire","")
If @error Then MsgBox(0,"",$input&" "&GUICtrlRead($input))
$TesteEs = StringReplace($input," ","")
If $TesteEs <> "" Then
$NCharac = _CountString($input) ; ~ On peut trés bien utiliser la fonction StringLen().
While $END <> $NCharac
$sText1 = StringMid($input,$N,98)
If $sText1 <> "" Then _GSpeech($sText1)
$N += 98
$END += 98
Wend
Exit
Else
MsgBox(0,"","Aucune saisie !")
Exit
EndIf
Func _GSpeech($Text)
$Data = _URIEncode($Text)
InetGet("http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=" & $Data,@TempDir & "\temp.mp3",1)
$sound = _SoundOpen(@TempDir & "\temp.mp3")
_SoundPlay($sound,1)
_SoundClose($sound)
EndFunc
Func _URIEncode($sData)
; Prog@ndy
Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"")
Local $nChar
$sData=""
For $i = 1 To $aData[0]
ConsoleWrite($aData[$i] & @CRLF)
$nChar = Asc($aData[$i])
Switch $nChar
Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126
$sData &= $aData[$i]
Case 32
$sData &= "+"
Case Else
$sData &= "%" & Hex($nChar,2)
EndSwitch
Next
Return $sData
EndFunc
Func _CountString($string, $Opt=0)
If $string = "" Then Return 0
If $Opt < 0 Or $Opt > 1 Then Return 0
If $Opt = 1 Then $string = StringReplace($string, " ", "") ;=> Options on compte que les caractères sans espaces ou avec
$string = $string & "$"
Local $count = 0, $iMax = 1, $END = "true" ;==> Variables
While $END = "true"
If Stringleft($string, $iMax) <> "" Then $iMax += 1 ;=> si il y a quelque chose on ajoute un caractère
If StringTrimLeft($string, $iMax) = "$" Then $END = "false"
Wend
Return $iMax
Endfunc
Re: [Ex] google speech en autoit !
Posté : mer. 17 oct. 2012 20:48
par jl56
Bonjour
Merci à vous tous pour vos scripts
@popwers
votre script ne sort pas de la boucle, j'ai pas eu le temps de regarder pourquoi
A+
JL56
Re: [Ex] google speech en autoit !
Posté : jeu. 18 oct. 2012 19:07
par Popwers
Merci jl56 d'avoir trouver une erreur,
J'ai fait la correction et rajouter un filtre pour que sa ne coupe plus
en plein milieu d'un mot !
Donc voila le script normalement fini et sans erreurs
► Afficher le texteCode Autoit
Code : Tout sélectionner
#include <Sound.au3>
Global $END = 0,$sText,$sText1,$N = 1,$Split = 0,$NR
$input = InputBox("Que dire?","Indiquez un texte à lire","")
If @error Then MsgBox(0,"",$input&" "&GUICtrlRead($input))
$TesteEs = StringReplace($input," ","")
If $TesteEs <> "" Then
$NCharac = StringLen($input)
While $END < $NCharac
If StringIsSpace($input) <> 0 Then
$sText1 = StringSplit($input," ")
For $o = 1 To $sText1[0]
If $NR = StringLen($sText1[$o]) > 98 Then
$CountS = $NR - 98
$sTextR = StringRight($sText1,$CountS)
$sText1[$o] = StringMid($sText1[$o],0,98)
_GSpeech($sText1[$o])
_GSpeech($sTextR)
Else
_GSpeech($sText1[$o])
EndIf
Next
ExitLoop
$Split = 1
Else
$sText1 = StringMid($input,$N,98)
EndIf
If $Split <> 1 Then
_GSpeech($sText1)
$N += 98
$END += 98
EndIf
Wend
Exit
Else
MsgBox(0,"","Aucune saisie !")
Exit
EndIf
Func _GSpeech($Text)
$Data = _URIEncode($Text)
InetGet("http://translate.google.com/translate_tts?ie=UTF-8&tl=fr&q=" & $Data,@TempDir & "\temp.mp3",1)
$sound = _SoundOpen(@TempDir & "\temp.mp3")
_SoundPlay($sound,1)
_SoundClose($sound)
EndFunc
Func _URIEncode($sData)
; Prog@ndy
Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"")
Local $nChar
$sData=""
For $i = 1 To $aData[0]
ConsoleWrite($aData[$i] & @CRLF)
$nChar = Asc($aData[$i])
Switch $nChar
Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126
$sData &= $aData[$i]
Case 32
$sData &= "+"
Case Else
$sData &= "%" & Hex($nChar,2)
EndSwitch
Next
Return $sData
EndFunc
EDIT : Petite amélioration apporter au script aprés avoir poster le message
