For information about synthesizing long-form text to speech, see batch synthesis.For information about speech synthesis from a file and finer control over voice styles, prosody, and other settings, see How to synthesize speech and Improve synthesis with Speech Synthesis Markup Language (SSML).You can also get text from files as described in these guides: This quickstart uses the SpeakTextAsync operation to synthesize a short block of text that you enter. Now that you've completed the quickstart, here are some additional considerations: For example, type "I'm excited to try text to speech." Press the Enter key to hear the synthesized speech. If you don't set these variables, the sample will fail with an error message.Įnter some text that you want to speak. Make sure that you set the SPEECH_KEY and SPEECH_REGION environment variables as described above. 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. 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)) SpeechConfig.SpeechSynthesisVoiceName = "en-US-JennyNeural" The language of the voice that speaks. Var speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion) 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 speechRegion = Environment.GetEnvironmentVariable("SPEECH_REGION") Static string speechKey = Environment.GetEnvironmentVariable("SPEECH_KEY") This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION" Replace the contents of Program.cs with the following code. Install the Speech SDK in your new project with the. The Program.cs file should be created in the project directory. 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. For example, westus.įor more configuration options, see the Xcode documentation. Set SPEECH_REGION to the region of your resource. To set the environment variable for your Speech resource region, follow the same steps. Enter SPEECH_KEY for the Name and enter your Speech resource key for the Value.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |