rich-monitor-70665
05/18/2026, 6:26 PMtall-airline-16756
05/18/2026, 6:27 PMtall-airline-16756
05/18/2026, 6:27 PMlanguages parameter on the Azure STT plugin.
To help you further I need two quick details:
1. Which runtime/language are you using (Python, Node, etc.)?
2. Which target languages do you want to transcribe (list of language codes, e.g., en, es, fr)?
Once you share that I’ll give the exact code snippet and config steps (including env vars like AZURE_SPEECH_KEY and AZURE_SPEECH_REGION) to get multilingual transcriptions working.
Sources: Azure Speech STT plugin guide | LiveKit Documentation, with interactive elementsrich-monitor-70665
05/18/2026, 6:28 PMtall-airline-16756
05/18/2026, 6:28 PMupdate_options().
Prerequisites
• Install plugin: uv add "livekit-agents[azure]~=1.5"
• Set env vars: AZURE_SPEECH_KEY, AZURE_SPEECH_REGION, optionally AZURE_SPEECH_HOST
Example (Python)
from livekit.plugins import azure
from livekit.agents import AgentSession
# initial languages (language codes like "en-US", "es-ES")
stt = azure.STT(
speech_key="YOUR_KEY", # or rely on AZURE_SPEECH_KEY env var
speech_region="YOUR_REGION", # or rely on AZURE_SPEECH_REGION env var
languages=["en-US", "es-ES"]
)
session = AgentSession(
stt=stt,
# other config: llm, tts, etc.
)
# ... start your session / run agent ...
# At runtime: update target languages dynamically
stt.update_options(languages=["fr-FR", "de-DE"])
Notes
• Use full Azure language codes (e.g., en-US, es-ES, fr-FR).
• You can call stt.update_options(...) whenever you need to change transcription languages during the session.
Would you like a version that reads env vars only (no keys in code) or an example showing switching languages based on incoming user input?
Sources: Azure Speech STT plugin guide | LiveKit Documentation | Gladia STT plugin guide | LiveKit Documentation, with interactive elementsrich-monitor-70665
05/18/2026, 6:29 PMtall-airline-16756
05/18/2026, 6:30 PMfrom livekit.agents import Agent
from livekit.plugins import azure
from livekit.models import stt as stt_models
import logging
logger = logging.getLogger(__name__)
# initialize STT with possible languages
stt = azure.STT(languages=["en-US", "es-ES", "fr-FR"])
class MultilingualAgent(Agent):
async def stt_node(self, audio, model_settings) -> AsyncIterable[stt_models.SpeechEvent]:
async for event in await super().stt_node(audio, model_settings):
# check interim or final transcripts
if event.type in (stt_models.SpeechEventType.INTERIM_TRANSCRIPT,
stt_models.SpeechEventType.FINAL_TRANSCRIPT):
if event.alternatives:
alt = event.alternatives[0]
detected_lang = getattr(alt, "language", None)
text = getattr(alt, "text", None)
# Handle transcription + language
logger.info(f"Detected language: {detected_lang} — Transcript: {text}")
# Example: route, store, or trigger TTS based on detected_lang
yield event
Key points
• Configure azure.STT(languages=[...]) with the set of languages you want Azure to detect.
• Each transcription event contains alternatives[0].text and alternatives[0].language (the detected language for that segment).
• Override stt_node to receive events in real time and act on language + text (log, store, route, or switch TTS).
• To change detection languages at runtime, call `stt.update_options(languages=[...])`; new events will reflect the updated language set.
If you want, I can:
• Provide a version that reads credentials from env vars.
• Show how to store transcripts per-language or forward them to a callback/webhook.
Which would you prefer?
Sources: Azure Speech STT plugin guide | LiveKit Documentation | Build a multilingual voice agent that automatically switches languages | Li..., with interactive elementsrich-monitor-70665
05/18/2026, 6:30 PMtall-airline-16756
05/18/2026, 6:31 PMazure.STT with multiple languages,
• Overriding stt_node to capture transcription text and detected language,
• Dynamically updating languages at runtime,
• A simple async runner that starts an AgentSession.
Prerequisites
1. Install the plugin:
uv add "livekit-agents[azure]~=1.5"
1. Set env vars (example .env or export in shell):
◦ AZURE_SPEECH_KEY
◦ AZURE_SPEECH_REGION
◦ (optional) AZURE_SPEECH_HOST
Full working example
import os
import asyncio
import logging
from typing import AsyncIterable
from livekit.agents import Agent, AgentSession
from livekit.models import stt as stt_models
from livekit.plugins import azure
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("multilingual-agent")
# Read Azure creds from env
AZURE_KEY = os.getenv("AZURE_SPEECH_KEY")
AZURE_REGION = os.getenv("AZURE_SPEECH_REGION")
AZURE_HOST = os.getenv("AZURE_SPEECH_HOST") # optional
# Initialize STT with initial languages
# Use Azure language codes like "en-US", "es-ES", "fr-FR"
stt = azure.STT(
speech_key=AZURE_KEY,
speech_region=AZURE_REGION,
speech_host=AZURE_HOST,
languages=["en-US", "es-ES", "fr-FR"],
)
class MultilingualAgent(Agent):
"""
Custom agent that intercepts STT events to capture text + detected language.
"""
async def stt_node(self, audio, model_settings) -> AsyncIterable[stt_models.SpeechEvent]:
# Call parent STT node iterator to receive SpeechEvent objects
default_stream = await super().stt_node(audio, model_settings)
async for event in default_stream:
# Handle interim and final transcripts
if event.type in (
stt_models.SpeechEventType.INTERIM_TRANSCRIPT,
stt_models.SpeechEventType.FINAL_TRANSCRIPT,
):
if event.alternatives:
alt = event.alternatives[0]
detected_lang = getattr(alt, "language", None)
text = getattr(alt, "text", None)
# Example handling: log + route/store based on language
logger.info(f"Detected language: {detected_lang} — Transcript: {text}")
# Example: you could store per-language transcripts:
# append_to_store(detected_lang, text)
# Example: dynamically adjust TTS or other behavior:
# if detected_lang and detected_lang != self.session.tts.language:
# self.session.tts.update_options(language=detected_lang)
# Pass event through the pipeline
yield event
async def dynamic_language_switch_example():
"""
Example to demonstrate updating language list at runtime.
This function updates the STT languages after a delay.
"""
await asyncio.sleep(5) # wait for agent/session to start
logger.info("Updating STT languages to German + Italian")
stt.update_options(languages=["de-DE", "it-IT"])
async def main():
# Create your AgentSession with the custom agent class and the stt plugin
session = AgentSession(
stt=stt,
agent_class=MultilingualAgent,
# add llm, tts, vad, or other components as needed
)
# Start the agent session (this starts the media/STT pipeline)
# The actual start method depends on your integration; using session.run() here
# will run agent loop until stopped (example pattern).
runner = asyncio.create_task(session.run())
# Demonstrate changing languages at runtime
switcher = asyncio.create_task(dynamic_language_switch_example())
# Wait for tasks (in real usage, your app lifecycle determines when to stop)
await asyncio.wait([runner, switcher], return_when=asyncio.FIRST_COMPLETED)
# Clean up
await session.stop()
if __name__ == "__main__":
asyncio.run(main())
Notes and tips
• Each SpeechEvent.alternatives[0] contains text and language (detected language for that segment).
• Azure requires you to provide the set of possible languages up front via languages=[...]. To change that set mid-session, call stt.update_options(languages=[...]).
• The example logs detected language + text; replace logging with your storage, webhook, or TTS switching logic as needed.
• If you want an example that reads/writes transcripts to files or posts to a webhook, tell me which and I’ll add it., with interactive elementsrich-monitor-70665
05/18/2026, 6:45 PM{ language, value }[], low-latency WebSocket/WebRTC streaming, timestamp synchronization, overlapping speaker support, scalable event-driven architecture, and production-ready handling for diarization, reconnections, code-switching, and transcript correction updates.tall-airline-16756
05/18/2026, 6:45 PM{ language, value }[].
• Real-time translation step (translate each segment into all configured targets including source).
• Low-latency WebSocket sample for streaming transcripts to clients and timestamp sync approach.
• Reconnection, reconcilation, transcript-correction, and scaling guidance (stateless workers, message-broker events).
• Tests and deployment notes (Liveness, retries, batching, monitoring).
Which provider do you want me to use for the example: Deepgram, Soniox, Azure Speech, or Gladia?
Sources: Introduction | LiveKit Documentation | Speech-to-text (STT) models overview | LiveKit Documentation | Smallest AI STT plugin guide | LiveKit Documentation | Soniox STT plugin guide | LiveKit Documentation | NVIDIA Riva STT plugin guide | LiveKit Documentation, with interactive elementsrich-monitor-70665
05/18/2026, 6:46 PMtall-airline-16756
05/18/2026, 6:46 PM{ language, value }[] outputs, low-latency WebSocket/WebRTC streaming, timestamps, overlap support, dynamic language updates, reconnection/repair, and scaling guidance).
Before I produce the full design and code, one quick clarification so I tailor the implementation correctly:
Do you want translations performed by Azure Translator (preferred) or a different translation service?
After you confirm, I’ll deliver:
• Architecture and event flow.
• End-to-end Python code:
◦ Track Egress → per-participant WebSocket ingestion.
◦ LiveKit Agent using azure.STT with diarization and interim/final handling.
◦ Real-time translation (per-segment) and structured outputs.
◦ WebSocket server sample for low-latency client delivery and timestamp sync.
◦ Dynamic language updates, reconnection handling, correction updates, and scaling notes., with interactive elementsrich-monitor-70665
05/18/2026, 6:47 PMtall-airline-16756
05/18/2026, 6:47 PMazure.STT with diarization and interim/final event handling.
◦ Azure Translator integration for per-segment translation into all configured targets (including source).
◦ Structured output format: { speaker_id, start_ts, end_ts, alternatives: [{ language, value, word_timestamps? }], interim|final }.
◦ Low-latency WebSocket server and minimal browser client example.
◦ Handling for reconnections, transcript corrections, code-switching, overlap, and scaling notes.
◦ Persistence to Postgres + event publication to Redis Streams.
Before I produce the full code bundle, confirm one last thing: Do you want word-level timestamps included when available (this increases cost/latency)?
Sources: Soniox STT plugin guide | LiveKit Documentation | Azure Speech STT plugin guide | LiveKit Documentation | Speech-to-text (STT) models overview | LiveKit Documentation | Gladia STT plugin guide | LiveKit Documentation, with interactive elementsrich-monitor-70665
05/18/2026, 7:41 PMtall-airline-16756
05/18/2026, 7:41 PMazure.STT plugin configured with diarization and languages detection; override stt_node to emit interim and final SpeechEvent objects; include handling of alternatives[0].language and timestamps.
◦ Translation module that calls Azure Translator in parallel for each finalized/interim segment and returns translations for all configured target languages plus the source. Ensure translation calls are non-blocking and rate-limited.
◦ Aggregator that merges per-participant streams into a meeting transcript, preserves overlapping segments, produces structured JSON per segment, and assigns stable speaker_ids (mapping diarization ids to LiveKit participant IDs).
◦ WebSocket server that streams partial and final structured events to clients with minimal framing/latency; include example client snippet (JS) showing how to display interim updates and apply final replacements.
◦ Persistence layer: Postgres schema for transcripts (segments, alternatives, word timestamps, corrections) and sample write/update logic for interim → final replacement and correction updates.
◦ Event publication: publish each final segment to Redis Streams with idempotency keys; demonstrate consumer pattern for downstream processors.
◦ Support for dynamic language updates at runtime (API endpoint or WebSocket command) that calls stt.update_options(languages=...) and updates translation target list.
◦ Reconnection handling: retry/backoff for ingest, durable buffering (Redis) for transient outages, and logic to reconcile interim → final corrections after reconnects.
◦ Tests or test harness: simulate multiple participants with overlapping speech, code-switching segments, and connector mocks for Azure services.
4) Implementation details & examples
• Show concrete usage of LiveKit Azure STT plugin: initialization, env var usage, and update_options() for languages.
• Demonstrate how to override stt_node to inspect SpeechEvent objects, extract alternatives[0].text, alternatives[0].language, `start`/`end` timestamps (and word timestamps when available), and speaker_id.
• Provide an example of producing the required structured output array alternatives: [{ language, value, word_timestamps? }] for each segment, including the original transcription and translations.
• Translation concurrency: pool workers / asyncio.gather with semaphore to avoid throttling; include exponential backoff on 429s.
• Timestamp synchronization: map audio frame timestamps from Track Egress to transcript start/end (include example calculations and handling of clock drift).
• Overlap & diarization: show how to accept overlapping segments and keep multiple active speaker segments until finalized.
• Transcript correction: document and demonstrate how interim transcripts are replaced by final ones and how updates are persisted and broadcast (include idempotency and update IDs).
• Provide configuration examples for latency vs accuracy trade-offs (e.g., interim frequency, batch window length for finalization, enabling word timestamps).
• Security: mention using TLS, auth tokens for WebSocket clients, and rotating credentials.
5) Production & scaling guidance
• Stateless worker design, autoscaling STT & translation pools, event-driven processing with Redis Streams or Kafka, and Postgres for final persistence.
• Observability: metrics to emit (latency, interim->final correction rate, translation failures, queue lengths), logging format, and SLO suggestions.
• Cost/latency trade-offs when enabling word timestamps or large translation fan-out.
• Handling partial failures: circuit breaker for translator, fallback to untranslated original, retries, and dead-letter queue for failed segments.
6) Deliver a runnable minimal demo
• A trimmed-down repo layout and README with commands to:
◦ Set env vars.
◦ Start the ingest WebSocket server and agent worker locally.
◦ Run a test harness that streams pre-recorded per-participant PCM files (simulate overlapping speech).
◦ Start a simple WebSocket client to view transcripts with interim updates and final replacements.
7) Provide follow-ups
• List additional features to add next (speaker labeling via profile, adaptive models, offline batching, redact PII).
• Include pointers to azure SDK docs and LiveKit plugin docs in comments.
Constraints for the generated code:
• Do not assume any undocumented LiveKit-Azure Translator integration exists; implement translation as a separate Azure Translator call after transcription.
• Use only LiveKit features and STT plugin behavior that are documented: azure.STT, diarization support, languages parameter, update_options(), interim/final SpeechEvent handling.
• Keep examples concise but runnable; external integrations (Azure Translator) may be mocked in tests.
Produce:
• The full architecture description and the complete Python code described above (working examples and minimal demo), organized and ready to run locally."
End prompt.
, with interactive elements