Azure AI Speech
| Downloads |
Overview
Section titled “Overview”Azure AI Speech provides enterprise-grade cloud speech-to-text and text-to-speech powered by Azure Cognitive Services. It replaces the platform-native ISpeechToTextService and ITextToSpeechService registrations with cloud-backed implementations while still using platform-native audio capture and playback.
// In MauiProgram.csbuilder.Services.AddAzureSpeech("your-subscription-key", "eastus");// IAudioSource and IAudioPlayer are automatically registered for platform audio I/OOr with a config object and selective services:
builder.Services.AddAzureSpeech( new AzureSpeechConfig { SubscriptionKey = "your-subscription-key", Region = "eastus" }, speechToText: true, textToSpeech: true);Configuration
Section titled “Configuration”public record AzureSpeechConfig{ public required string SubscriptionKey { get; init; } public required string Region { get; init; }}| Property | Description |
|---|---|
SubscriptionKey |
Your Azure Speech Services subscription key |
Region |
Azure region (e.g., eastus, westus2, westeurope) |
Once registered, inject and use ISpeechToTextService and ITextToSpeechService exactly as you would with platform-native speech — the API is identical:
public class MyViewModel(ISpeechToTextService stt, ITextToSpeechService tts){ async Task ListenAndRespond(CancellationToken ct) { var access = await stt.RequestAccess(); if (access != AccessState.Available) return;
var text = await stt.ListenUntilSilence(cancellationToken: ct);
if (text != null) await tts.SpeakAsync($"You said: {text}"); }}Emotion & Tone
Section titled “Emotion & Tone”Azure expresses emotion through SSML, so a portable SpeechTone becomes an
mstts:express-as wrapper and any bracketed annotations in the text are stripped rather than spoken
aloud:
await tts.SpeakAsync("We just shipped it.", new TextToSpeechOptions{ Tone = new SpeechTone { Emotion = SpeechEmotion.Excited, Intensity = 1.5f }});<prosody rate="+0%" pitch="+0%" volume="100"> <mstts:express-as style="excited" styledegree="1.5"> We just shipped it. </mstts:express-as></prosody>Intensity maps to styledegree (clamped to Azure’s 0.01–2 range). Style support is
per-voice — a voice that doesn’t offer the requested style renders in its default delivery rather
than failing, so check the voice list before relying on a particular style. No wrapper is emitted at
all when there’s no tone, leaving the SSML byte-identical to before.
STT-Only or TTS-Only
Section titled “STT-Only or TTS-Only”You can register Azure for just one service:
// Azure STT only (use platform-native TTS)builder.Services.AddTextToSpeech(); // Platform-native TTSbuilder.Services.AddAzureSpeech("key", "region", speechToText: true, textToSpeech: false);
// Azure TTS only (use platform-native STT)builder.Services.AddSpeechToText(); // Platform-native STTbuilder.Services.AddAzureSpeech("key", "region", speechToText: false, textToSpeech: true);

