Azure Speech and SpeechConfig
Azure Speech in Foundry Tools is a set of speech capabilities reached through a Foundry resource — speech-to-text (transcribe calls, meetings, audio) and text-to-speech (read messages or emails aloud). You authenticate with the resource endpoint and key, via REST or a language SDK.
Key concept · SpeechConfig is the foundation
Every operation begins with a SpeechConfig object encapsulating the connection details (subscription key + endpoint). Python SDK 1.48.2 and later accept the Foundry resource endpoint directly; earlier versions needed a region instead. SDKs exist for Python, C#, JavaScript, and more (pip install azure-cognitiveservices-speech).
One pattern, two directions
Both APIs follow the same four-step shape: build a SpeechConfig, optionally an AudioConfig (input source or output destination), create a proxy client, then call a method and inspect the result.
| Speech-to-text | Text-to-speech | |
|---|---|---|
| Proxy client | SpeechRecognizer | SpeechSynthesizer |
| AudioConfig default | System microphone (or a file) | System speaker (or a file/stream) |
| Main method | RecognizeOnceAsync() | SpeakTextAsync() |
| Success Reason | RecognizedSpeech (read Text) | SynthesizingAudioCompleted (read AudioData) |
Key concept · Reading the result's Reason
The recognition result's Reason tells you what happened: RecognizedSpeech (success — use the Text property), NoMatch (audio parsed but no speech detected), or Canceled (an error — check CancellationReason). The synthesis result exposes AudioData, Reason, and ResultId; a Canceled synthesis carries cancellation details.
Shaping the spoken output
Through SpeechConfig you choose the audio format (file type, sample rate, bit depth — e.g. Riff24Khz16BitMonoPcm) and the voice, named by locale + person + detail (e.g. en-US-Brian:DragonHDLatestNeural).
Key concept · SSML for fine control
Speech Synthesis Markup Language is an XML syntax that goes beyond plain text: speaking styles (e.g. cheerful, via mstts:express-as with neural voices), pauses/breaks, phonemes (pronounce "SQL" as "sequel"), prosody (pitch, timbre, rate), say-as rules (dates, times, phone numbers), and inserted audio. Submit it with speak_ssml_async() instead of speak_text_async(). Multiple <voice> elements can hold a dialog between different neural voices.
Chapter 19 quiz
Fifteen questions on the service, the two APIs, and formats/voices/SSML. Answer first, then expand Show answer.
Part A · Multiple choice
What object encapsulates the connection details for every Azure Speech operation?
- A SpeechConfig
- B AudioConfig
- C MCPTool
- D TextAnalyticsClient
Show answer
A — SpeechConfig. Subscription key plus endpoint (or region).
Which proxy client transcribes speech?
- A SpeechRecognizer
- B SpeechSynthesizer
- C TranslationRecognizer
- D AIProjectClient
Show answer
A — SpeechRecognizer. SpeechSynthesizer does text-to-speech.
What Reason value means audio was parsed but no speech was detected?
- A RecognizedSpeech
- B NoMatch
- C Canceled
- D SynthesizingAudioCompleted
Show answer
B — NoMatch. Canceled means an error occurred.
What is the default AudioConfig input for speech-to-text?
- A The system microphone
- B A blob container
- C A fixed WAV file
- D The system speaker
Show answer
A — the system microphone (a file path is the alternative).
How is a voice named?
- A Locale + person + detail, e.g. en-US-Brian:DragonHDLatestNeural
- B A random GUID
- C Just a number
- D The endpoint URL
Show answer
A. e.g. locale en-US, person Brian, detail DragonHDLatestNeural.
Which SSML feature makes "SQL" pronounced as "sequel"?
- A Phonemes
- B Prosody
- C Say-as
- D Break
Show answer
A — phonemes. They define phonetic pronunciation.
Which method submits SSML rather than plain text?
- A speak_ssml_async()
- B speak_text_async()
- C recognize_once_async()
- D transcriptions.create()
Show answer
A — speak_ssml_async().
Part B · True or false
Both the STT and TTS APIs follow the same core four-step pattern.
Show answer
True. Config → (audio config) → proxy client → method call/result.
Python SDK 1.48.2+ can use the Foundry resource endpoint directly.
Show answer
True. Earlier versions required a region.
AudioConfig is always required.
Show answer
False. It's optional; defaults are microphone (in) and speaker (out).
SSML can put two different neural voices into one dialog.
Show answer
True. Using multiple <voice> elements.
Audio output format lets you set file type, sample rate, and bit depth.
Show answer
True. e.g. Riff24Khz16BitMonoPcm, set via SpeechConfig.
Part C · Short answer
Name the two proxy clients for STT and TTS.
Show answer
SpeechRecognizer (STT) and SpeechSynthesizer (TTS).
Name three things SSML controls.
Show answer
Any three: speaking styles, pauses/breaks, phonemes, prosody (pitch/rate), say-as rules, and inserted audio.
What Reason value indicates a successful synthesis?
Show answer
SynthesizingAudioCompleted — with AudioData containing the stream.