AWS Polly集成SDK

Tre*_*van 1 .net amazon-web-services amazon-polly

我刚刚看到有关Amazon Polly文字转语音服务的公告.我能够在AWS控制台中访问该服务,但我找不到任何集成点.控制台中没有任何链接可以访问API/SDK.

AWS .NET SDKv3文档也不包含Polly的文档.

Amazon Polly有适用于.NET的SDK吗?

And*_*sko 6

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

这是一个我刚玩过的简单例子:

    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();
    }
Run Code Online (Sandbox Code Playgroud)

它返回带有您指定文本的mp3编码音频文件.