A developer is building a lightweight Python desktop application that reads incoming text messages aloud to the user. The application uses Azure Speech in Foundry Tools. The environment variables FOUNDRY_KEY and ENDPOINT hold the key and endpoint of the developer's Foundry resource. The exhibit shows an excerpt of the application code.
# Python
import os
import azure.cognitiveservices.speech as speechsdk
speech_config = speechsdk.SpeechConfig(subscription=os.environ.get('FOUNDRY_KEY'), endpoint=os.environ.get('ENDPOINT'))
audio_config = speechsdk.audio.AudioOutputConfig(use_default_speaker=True)
speech_config.speech_synthesis_voice_name='en-US-Ava:DragonHDLatestNeural'
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)
result = speech_synthesizer.speak_text_async(message_text).get()
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
| Statement | Yes | No |
|---|---|---|
| The code plays the synthesized speech through the computer's default speaker. The AudioOutputConfig is created with use_default_speaker=True. The text-to-speech API can send its audio output either to the speaker or to an audio file, and this setting chooses the speaker. | Correct | |
| The speech_synthesis_voice_name setting specifies which voice speaks the messages. A text-to-speech solution needs both the text and the voice that will say it. The code chooses the voice by setting speech_synthesis_voice_name on the speech configuration. | Correct | |
| The application must include its own neural model to generate the audio on the local computer. The SDK sends the text to Azure Speech, and the speech synthesis runs in the cloud, where neural voices produce the audio. The SDK takes care of authentication and the network calls, so the app needs no local model. | Correct |
The exhibit connects to Azure Speech with the Foundry key and endpoint, picks a voice through speech_synthesis_voice_name, and routes output to the default speaker. The SpeechSynthesizer sends the message text to Azure Speech, where neural voices create the audio in the cloud. The audio comes back to the app for playback, so the application does not need its own speech model.
- Get started with speech in Azure: Speech synthesisMicrosoft Learn