public void GenerateWAV(string speakerText, ushort voice, string outputFileName) { var request = new SynthesizeSpeechRequest() { OutputFormat = OutputFormat.Pcm, SampleRate = Settings.SampleRateHz.ToString(), Text = GetSSMLForSpeakerText(speakerText), TextType = TextType.Ssml, VoiceId = Settings.VoiceIds[voice] }; var response = _awsPollyClient.SynthesizeSpeech(request); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { new PCMAudioSerializer().Serialize(response.AudioStream, outputFileName); } }
public void PollySynthesizeSpeech() { #region to-synthesize-speech-1482186064046 var response = client.SynthesizeSpeech(new SynthesizeSpeechRequest { LexiconNames = new List <string> { "example" }, OutputFormat = "mp3", SampleRate = "8000", Text = "All Gaul is divided into three parts", TextType = "text", VoiceId = "Joanna" }); MemoryStream audioStream = response.AudioStream; string contentType = response.ContentType; int requestCharacters = response.RequestCharacters; #endregion }
private Amazon.Polly.Model.SynthesizeSpeechResponse CallAWSServiceOperation(IAmazonPolly client, Amazon.Polly.Model.SynthesizeSpeechRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Polly", "SynthesizeSpeech"); try { #if DESKTOP return(client.SynthesizeSpeech(request)); #elif CORECLR return(client.SynthesizeSpeechAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }