If the voice does not speak the language of the input text, the Speech service won't output synthesized audio.īuild and run your new console application to start speech synthesis to the default speaker. For example, if the input text in English is "I'm excited to try text to speech" and you set es-ES-ElviraNeural, the text is spoken in English with a Spanish accent. All neural voices are multilingual and fluent in their own language and English. To change the speech synthesis language, replace en-US-JennyNeural with another supported voice. In Program.cs, replace YourSubscriptionKey with your Speech resource key, and replace YourServiceRegion with your Speech resource region. OutputSpeechSynthesisResult(speechSynthesisResult, text) Ĭonsole.WriteLine("Press any key to exit.") Var speechSynthesisResult = await speechSynthesizer.SpeakTextAsync(text) Get text from the console and synthesize to the default speaker.Ĭonsole.WriteLine("Enter some text that you want to speak >") Using (var speechSynthesizer = new SpeechSynthesizer(speechConfig)) The language of the voice that speaks. Var speechConfig = SpeechConfig.FromSubscription(YourSubscriptionKey, YourServiceRegion) Static void OutputSpeechSynthesisResult(SpeechSynthesisResult speechSynthesisResult, string text)Ĭase ResultReason.SynthesizingAudioCompleted:Ĭonsole.WriteLine($"Speech synthesized for text: ") Ĭonsole.WriteLine($"CANCELED: Did you set the speech resource key and region values?") Static string YourServiceRegion = "YourServiceRegion" Static string YourSubscriptionKey = "YourSubscriptionKey" Replace the contents of Program.cs with the following code. Install the Speech SDK in your new project with the. Open a command prompt where you want the new project, and create a console application with the. Synthesize to speaker outputįollow these steps to create a new console application and install the Speech SDK. You install the Speech SDK in the next section of this article, but first check the SDK installation guide for any more requirements. The Speech SDK is available as a NuGet package and implements. For more information about Cognitive Services resources, see Get the keys for your resource. After your Speech resource is deployed, select Go to resource to view and manage keys.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |