首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AWS Polly Integration SDK

AWS Polly Integration SDK
EN

Stack Overflow用户
提问于 2016-12-02 00:01:09
回答 1查看 1.5K关注 0票数 2

我刚看到关于亚马逊Polly文本到语音服务的公告。我能够访问AWS控制台中的服务,但是我找不到任何集成点。控制台中没有任何访问API/SDK的链接。

AWS .NET SDK的.NET文档也不包括Polly的文档。

有.NET和Amazon的SDK吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-02 01:42:25

你查过这个链接了吗?目前,在(pdf格式 / html)中,您可以找到python、android和iOS的示例。安装SDK后,您可以找到包含要使用Polly的所有类的C:\Program Files (x86)\AWS SDK for .NET\bin\Net45\AWSSDK.Polly.dll

下面是我刚才玩过的一个简单的例子:

代码语言:javascript
复制
    public static void Main(string[] args)
    {

        AmazonPollyClient client = new AmazonPollyClient();

        // Create describe voices request.
        DescribeVoicesRequest describeVoicesRequest = new DescribeVoicesRequest();
        // Synchronously ask Amazon Polly to describe available TTS voices.
        DescribeVoicesResponse describeVoicesResult = client.DescribeVoices(describeVoicesRequest);
        List<Voice> voices = describeVoicesResult.Voices;


        // Create speech synthesis request.
        SynthesizeSpeechRequest synthesizeSpeechPresignRequest = new SynthesizeSpeechRequest();
        // Text
        synthesizeSpeechPresignRequest.Text = "Hello world!";
        // Select voice for synthesis.
        synthesizeSpeechPresignRequest.VoiceId = voices[0].Id;
        // Set format to MP3.
        synthesizeSpeechPresignRequest.OutputFormat = OutputFormat.Mp3;
        // Get the presigned URL for synthesized speech audio stream.
        var presignedSynthesizeSpeechUrl = client.SynthesizeSpeechAsync(synthesizeSpeechPresignRequest).GetAwaiter().GetResult();
        using (FileStream output = File.OpenWrite("hello_world.mp3"))
        {
            presignedSynthesizeSpeechUrl.AudioStream.CopyTo(output);
        }

        Console.Read();
    }

它使用指定的文本返回mp3编码的音频文件。

票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40922581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档