Delphi 使用Google Translate实现TTS


本文整理自网络,侵删。

 
var
    Stream : TMemoryStream;
begin
    Stream := TMemoryStream.Create;

    try
      // idHTTPUserAgent
      IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401';
      IdHTTP1.Get(TIdURI.URLEncode('http://translate.google.com/translate_tts?tl=ko&q=' + txtHangul.Text), Stream);
    finally
      MediaPlayer1.Close;
      Stream.SaveToFile(ExtractFilePath(Application.ExeName) + 'temp.mp3');

      MediaPlayer1.FileName := ExtractFilePath(Application.ExeName) + 'temp.mp3';
      MediaPlayer1.Open;
      MediaPlayer1.Play;
   end;
end;

相关阅读 >>

Delphi 如何快速读写文件中的字符串

incyear:将一个tdatetime变量加减一定数量的年数

Delphi treeview �c 自动给标题上加图片

Delphi form生成时的事件次序

Delphi 取 utc/tfiletime 时间

Delphi 跨平台获取文件列表

Delphi ios 保持设备开机状态

Delphi tnotification android通知

Delphi sendemail 邮件发送单元

Delphi webbrowser多次执行documentcomplete

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...