Translate text and speech with Microsoft Foundry Tools | AI-103 | Episode 21
Need multilingual text or real-time conversations? Azure provides purpose-built translation APIs for both text and speech. The key is knowing which SDK object performs which job.
Text Translation — know the difference
| Need | Use |
|---|---|
| Convert meaning to another language | translate() |
| Convert text between scripts | transliterate() |
| Discover available languages | get_supported_languages() |
Translation changes language; transliteration changes script.
client = TextTranslationClient(endpoint, credential)
# English → French
result = client.translate(
body=["Hello world"],
to_language=["fr"]
)
# → "Bonjour le monde"
The source language can be auto-detected or supplied with from_language. translate() can also target multiple languages in one request.
Speech Translation — remember the pipeline
Audio → TranslationRecognizer → translated text → SpeechSynthesizer → Audio
SpeechTranslationConfig→ credentials + source/target languagesAudioConfig→ microphone/file input or audio outputTranslationRecognizer→ recognizes and translates incoming speechSpeechSynthesizer→ converts translated text back to speech
config = SpeechTranslationConfig(endpoint, credential)
config.speech_recognition_language = "en-US"
config.add_target_language("fr")
recognizer = TranslationRecognizer(config, audio_in)
result = recognizer.recognize_once()
# result.translations["fr"] → translated text
Key decision
One target + streaming/live output → event-based synthesis
Multiple target languages → manual synthesis
Event-based synthesis supports one translation target; for multiple languages, iterate through the translated results and synthesize each separately.
Remember: Translate = language, Transliterate = script, TranslationRecognizer = speech → translated text, SpeechSynthesizer = text → speech.
Comments