Text analysis solutions ยท 10โ15%
Speech solutions
Speech to text (STT) transcribes spoken audio into text. Text to speech (TTS) synthesizes spoken audio from text. Azure gives you two ways to do both.
Two routes to speech โ pick correctly
| Route | Models/objects | When |
|---|---|---|
| GenAI audio models (OpenAI SDK) | gpt-4o-transcribe, -mini-transcribe, -transcribe-diarize (STT); gpt-4o-tts, -mini-tts (TTS) | Simple transcribe/synthesize in a gen-AI app |
| Azure Speech (Foundry Tools, Speech SDK) | SpeechRecognizer, SpeechSynthesizer, TranslationRecognizer | Full control: voices, SSML, translation, real-time |
How the GenAI route works
You call the model like any other OpenAI API. Two calls to know:
- Transcribe (STT):
client.audio.transcriptions.create(model, file, response_format="text")โ you upload an audio file, you get its text back. - Synthesize (TTS):
client.audio.speech.with_streaming_response.create(model, voice="alloy", input=..., instructions=...)โ you send text plus a voice name, you get audio back.instructionssets the tone (“speak in an excited tone”). - The
-transcribe-diarizemodel additionally labels who spoke each line (speaker separation).
Azure Speech SDK pattern (memorize)
Every Speech SDK app follows the same five steps:
- Create a SpeechConfig with your key and endpoint (or region). It holds the connection details.
- Optionally create an AudioConfig to say where audio comes from or goes to. Default is microphone in, speaker out; you can point it at a file instead.
- Build the worker object from those two configs: a
SpeechRecognizer(audio in, text out) or aSpeechSynthesizer(text in, audio out). - Call its method โ
recognize_once_async()to transcribe,speak_text_async()to speak. - Check
result.reasonto confirm it worked.
| Op | Object | Method | Success reason |
|---|---|---|---|
| STT | SpeechRecognizer | recognize_once_async() | RecognizedSpeech (else NoMatch, Canceled) |
| TTS | SpeechSynthesizer | speak_text_async() / speak_ssml_async() | SynthesizingAudioCompleted |
- Voice:
speech_config.speech_synthesis_voice_name = 'en-US-Brian:DragonHDLatestNeural'. - Output format:
set_speech_synthesis_output_format(...).
SSML
SSML (Speech Synthesis Markup Language) is an XML-based markup language that controls how synthesized speech sounds. Instead of plain text, you send markup that sets:
- speaking style (
mstts:express-as style="cheerful") - breaks/pauses (
<break>) - phonemes โ phonetic pronunciation (say “SQL” as “sequel”)
- prosody โ pitch, timbre, speaking rate
- say-as rules (read a string as a date, time, phone number)
- inserted audio and multiple voices in one document
Speech translation
Speech translation converts spoken input in one language into text (or speech) in other languages, in one call.
- Three steps: 1) create a
SpeechTranslationConfigand calladd_target_language()for each target language (several are fine); 2) callTranslationRecognizer.recognize_once_async(); 3) readresult.translations, a dict keyed by language code. - Two ways to get spoken output: manual synthesis โ loop over the translations and speak each one with a
SpeechSynthesizer(works for several languages at once); or event-based synthesis โ setvoice_nameon the config and collect the audio bytes inside thesynthesizingevent (1:1 only, no multi-language).
Voice Live API
The Voice Live API is an Azure Speech API for building agents that hold real-time voice conversations. It replaces the manual chain of speech-to-text, then a language model, then text-to-speech with one low-latency, bidirectional connection.
- Runs speech-to-speech over a WebSocket connection.
- JSON events: client events (
session.updateโฆ) vs server events. - Built-in noise suppression + echo cancellation; avatar streaming.
- Auth: Entra keyless (Bearer token) or API key. Endpoints: project
wss://โฆ.services.ai.azure.com/voice-live/realtimevs modelwss://โฆ.cognitiveservices.azure.com/voice-live/realtime.