示例#1
0
        public static async Task <string> SynthesizeAudioAsync(string article, string title)
        {
            AmazonPollyClient apc = new AmazonPollyClient(Secret.AWSAccessKey, Secret.AWSSecretKey, Amazon.RegionEndpoint.USEast1);
            StartSpeechSynthesisTaskRequest req = new StartSpeechSynthesisTaskRequest();

            req.Engine             = "neural";
            req.OutputFormat       = "mp3";
            req.OutputS3BucketName = "lrnr-neural";
            req.Text    = article;
            req.VoiceId = "Matthew";

            StartSpeechSynthesisTaskResponse response = await apc.StartSpeechSynthesisTaskAsync(req);

            return(response.SynthesisTask.OutputUri);
        }
示例#2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            StartSpeechSynthesisTaskResponse response = new StartSpeechSynthesisTaskResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("SynthesisTask", targetDepth))
                {
                    var unmarshaller = SynthesisTaskUnmarshaller.Instance;
                    response.SynthesisTask = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }