delphi 谷歌api文本转换语音mp3文件


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

    try
     
      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;

联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678