gpt4 book ai didi

c# - 如何从谷歌翻译下载文本到语音数据?

转载 作者:行者123 更新时间:2023-11-30 14:34:46 25 4
gpt4 key购买 nike

我正在尝试创建一个讲希腊语的应用程序。但是由于 Microsoft 不支持将希腊语作为口语,而且我的问题是关于如何创建自己的词典的指南 (here),所以我要问这个问题:

我如何下载包含我在运行时发送给 google translate 的文本的 mp3(或者只是数据无关紧要)并使用 C# 播放它?

最佳答案

只需使用此链接下载 MP3:

http://translate.google.com/translate_tts?tl=el&q=%22hello%22

编辑:请注意,某些浏览器(如 Firefox)将 %22 替换为 "并且该链接不起作用,因此您需要复制它并且无法单击它!

如何下​​载文件: http://www.csharp-examples.net/download-files/

http://msdn.microsoft.com/en-us/library/ez801hhe.aspx

如何播放 MP3: http://msdn.microsoft.com/en-us/library/4y171b18.aspx

using System.Media;

String strTextYouWantAsMp3 = "Hello";
WebClient webClient = new WebClient();
webClient.DownloadFile("http://translate.google.com/translate_tts?tl=el&q=%22" + strTextYouWantAsMp3 + "%22", @"c:\audio.mp3");

SoundPlayer simpleSound = new SoundPlayer(@"c:\audio.mp3");
simpleSound.Play();

关于c# - 如何从谷歌翻译下载文本到语音数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13413711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com