Advertisement
phatjk

Text to speech Vietnamese from Microsoft

May 17th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.84 KB | None | 0 0
  1. #RequireAdmin
  2. #include <_httprequest.au3>
  3. $text = ''
  4. $dir = @ScriptDir & '\amthanh.mp3'
  5. $url=_HttpRequest(3,'https://www.bing.com/tspeak?&format=audio%2Fmp3&language=vi&IG=D2CBB80AA6824D9A91B0A5D1074FC4A1&IID=translator.5034.2&text='&_EncodeURL($text))
  6. $file=FileOpen($dir,2+16)
  7. FileWrite($file,$url)
  8. MsgBox(64,'Thông báo','Thành công :D')
  9. Func _EncodeURL($sData)
  10.     Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"")
  11.     Local $nChar
  12.     $sData=""
  13.     For $i = 1 To $aData[0]
  14.         $nChar = Asc($aData[$i])
  15.         Switch $nChar
  16.             Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126
  17.                 $sData &= $aData[$i]
  18.             Case 32
  19.                 $sData &= "+"
  20.             Case Else
  21.                 $sData &= "%" & Hex($nChar,2)
  22.         EndSwitch
  23.     Next
  24.     Return $sData
  25. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement