Text To Speech API
Use the Text to Speech
API
The Azure AI Speech
service provides additional REST APIs for speech synthesis, much like its
Speech to Text APIs:
- The Text to speech API, which is the primary way to perform speech synthesis.
- The Batch synthesis API, which is designed to support batch operations that convert large volumes of text to audio, for example to generate an audio-book from the source text.
Using the Azure AI Speech
SDK
Similar to voice
recognition, the Azure AI voice SDK is actually used to create the majority of
interactive speech-enabled applications. The pattern for implementing speech
synthesis is similar to that of speech recognition:
- Use a SpeechConfig object to encapsulate the information required to connect to your Azure AI Speech resource. Specifically, its location and key.
- Optionally, use an AudioConfig to define the output device for the speech to be synthesized. By default, this is the default system speaker, but you can also specify an audio file, or by explicitly setting this value to a null value, you can process the audio stream object that is returned directly.
- Use the SpeechConfig and AudioConfig to create a SpeechSynthesizer object. This object is a proxy client for the Text to speech API.
- Use the methods of the SpeechSynthesizer object to call the underlying API functions. For example, the SpeakTextAsync() method uses the Azure AI Speech service to convert text to spoken audio.
- Process the response from the Azure AI Speech service. In the case of the SpeakTextAsync method, the result is a SpeechSynthesisResult object that contains the for AudioData, Properties, Reason, ResultId.
The AudioData property
holds the audio stream (which, depending on the AudioConfig, may have been
automatically transmitted to a speaker or file) and the Reason property is set
to the SynthesizingAudioCompleted enumeration once speech has been properly synthesized.
Conclusion
We have successfully
learnt about text to speech API.
Comments
Post a Comment