【原创】Azure语音合成示例
【代码】【原创】Azure语音合成示例。
·
个人体验:个人免费,美式英语语音合成质量比较高,系统提供了多种语音风格选择。
语音合成示例代码
static string speechKey = "6daa5e17bb9b4681aabdf3.。。。。。。";
static string speechRegion = "eastus2";
async static Task Main(string[] args)
{
var speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion);
speechConfig.SpeechSynthesisVoiceName = "en-US-JennyNeural";
speechConfig.OutputFormat = OutputFormat.Simple;
speechConfig.SetSpeechSynthesisOutputFormat(SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3);
using (var speechSynthesizer = new SpeechSynthesizer(speechConfig))
{
string text = "Enter some text that you want to speak";
var speechSynthesisResult = await speechSynthesizer.SpeakTextAsync(text);
File.WriteAllBytes("aa.mp3", speechSynthesisResult.AudioData);
Process.Start("explorer.exe","aa.mp3");
}
}
所有语音列表
var speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion);
var allVoices = new SpeechSynthesizer(speechConfig).GetVoicesAsync().Result.Voices.ToList();
allVoices.ForEach(x =>
{
if (x.Locale == "en-US" && x.Gender == SynthesisVoiceGender.Male)
{
Console.WriteLine(x.Gender + "," + x.ShortName);
if (x.StyleList.Count() > 1)
{
Console.Write("\t");
foreach (var style in x.StyleList)
{
Console.Write(style + ",");
}
Console.WriteLine();
}
}
});
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)