首页 > 解决方案 > Amazon polly tts SSML 标签

问题描述

我过去曾使用 amazon polly 通过文本生成音频文件。这是我使用的代码:

 public static void GenerateVoiceFileByAmzonApi(string VoiceName, string StrText,string FileName)
        {

            Amazon.Polly.AmazonPollyClient cl = new Amazon.Polly.AmazonPollyClient("abc", "abc", RegionEndpoint.USEast1);
            Amazon.Polly.Model.SynthesizeSpeechRequest req = new Amazon.Polly.Model.SynthesizeSpeechRequest();
            req.Text = StrText;

            switch (VoiceName)
            {
                case VOICE_NAME_AMAZON_GIORGIO:
                    req.VoiceId = Amazon.Polly.VoiceId.Giorgio;
                    break;
                case VOICE_NAME_AMAZON_CARLA:
                    req.VoiceId = Amazon.Polly.VoiceId.Carla;
                    break;
                case VOICE_NAME_AMAZON_BIANCA:
                    req.VoiceId = Amazon.Polly.VoiceId.Bianca;
                    break;
                default:
                    req.VoiceId = Amazon.Polly.VoiceId.Giorgio;
                    break;
            }

            req.TextType

            req.OutputFormat = Amazon.Polly.OutputFormat.Ogg_vorbis;
            req.TextType = Amazon.Polly.TextType.Text;
            Amazon.Polly.Model.SynthesizeSpeechResponse resp = cl.SynthesizeSpeech(req);

            using (System.IO.FileStream wFile = new System.IO.FileStream(FileName, System.IO.FileMode.Create))
            {
                resp.AudioStream.CopyTo(wFile);
                wFile.Flush();
                wFile.Close();
            }
        }

此代码有效,但有时我的文本带有不同的感叹号(!)或问号(?),但声音没有改变。

特别是有一些带有感叹号的文本包含警报情况,我喜欢在这些特定的 circustanes 中模拟人声的声音。

您知道是否可以使用 SSML 或其他方法吗?

谢谢 !

标签: c#.nettext-to-speechamazon-polly

解决方案


推荐阅读