stt
Meta speech-to-text service implementation.
This module provides integration with Meta’s Muse Voice realtime transcription WebSocket API documented at https://dev.meta.ai/docs/api-reference/voice/realtime.
- pipecat.services.meta.stt.language_to_meta_language(language: Language) str[source]
Convert a Language enum to the Meta STT language name.
Meta biases recognition on English language names rather than codes, e.g.
"English"or"Mandarin Chinese".- Parameters:
language – The Language enum value to convert.
- Returns:
The corresponding service language name. If
languageis not in the verified mapping, falls back to the base language code (e.g.,enfromen-US) and logs a warning (viaresolve_language(..., use_base_code=True)). Meta ignores a bias it doesn’t recognize, so an unmapped language degrades to auto-detection.
- class pipecat.services.meta.stt.MetaSTTSettings(model: str | None | NotGiven = <factory>, extra: dict[str, ~typing.Any]=<factory>, language: Language | str | None | NotGiven = <factory>, language_bias: list[Language] | None | NotGiven = <factory>, mode: str | NotGiven = <factory>, keywords: list[str] | None | NotGiven = <factory>, emit_audio_progress: bool | NotGiven = <factory>, zdr_override: bool | None | NotGiven = <factory>, speaker_format: str | None | NotGiven = <factory>)[source]
Bases:
STTSettingsSettings for MetaSTTService.
- Parameters:
language_bias – Languages to bias recognition toward, for speech that switches between them. When set, it replaces the single
languagebias. Leave both unset to let the model detect the language.mode – Segmentation mode.
"ENDPOINTING"has the model mark turn boundaries;"PUSH_TO_TALK"leaves them to the client;"DIARIZATION"attributes turns to speakers: each final transcript carries Meta’s label for its turn’s speaker (e.g."A") inspeaker. Interim transcripts are not labelled.keywords – Terms to bias recognition toward. Biasing raises the odds a term is recognized but doesn’t guarantee its spelling.
emit_audio_progress – Whether the server reports progress for every processed audio chunk.
zdr_override – Forces metadata-only logging when True, or allows content retention when False. Leave unset to use the account’s setting.
speaker_format – Optional format string for diarized transcripts. Use
{speaker}for the speaker label,{text}for the transcript text, and{speaker_number}for the speaker’s order of first appearance in the session (1,2, …), e.g."{speaker}: {text}". IfNone, transcript text is not modified. Applied locally, so changing it does not reconnect.
- class pipecat.services.meta.stt.MetaSTTService(*, api_key: str, url: str = 'wss://api.meta.ai/v1/asr/realtime', sample_rate: int | None = None, settings: MetaSTTSettings | None = None, ttfs_p99_latency: float | None = 1.92, **kwargs)[source]
Bases:
WebsocketSTTServiceMeta Muse Voice real-time speech-to-text service.
Streams audio to Meta’s realtime transcription WebSocket and emits interim and final transcription frames. The API key travels in the handshake frame rather than an HTTP header, and the session’s configuration is fixed once the server accepts that handshake, so a settings change reconnects.
In the default
ENDPOINTINGmode the server marks turn boundaries itself, emittingspeechStart, a run of cumulative partial transcripts,speechEnd, and finallyspeechCompletewith the post-processed text that becomes theTranscriptionFrame. Those boundaries segment transcripts only: Pipecat’s own VAD and turn strategies still decide when the user’s turn ends.Sessions are capped at 60 minutes. The server closes the socket when a session reaches that limit, and the base class reconnects into a fresh one.
- Settings
alias of
MetaSTTSettings
- __init__(*, api_key: str, url: str = 'wss://api.meta.ai/v1/asr/realtime', sample_rate: int | None = None, settings: MetaSTTSettings | None = None, ttfs_p99_latency: float | None = 1.92, **kwargs)[source]
Initialize the Meta STT service.
- Parameters:
api_key – Meta Model API key, sent as a Bearer token in the handshake.
url – WebSocket endpoint URL. Defaults to
wss://api.meta.ai/v1/asr/realtime.sample_rate – Audio sample rate in Hz. If None, uses the pipeline sample rate. Audio at anything other than 24000 is resampled to 16000, the only other rate the API accepts.
settings – Runtime-updatable settings overriding defaults.
ttfs_p99_latency – P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark
**kwargs – Additional arguments passed to WebsocketSTTService.
- can_generate_metrics() bool[source]
Check if the service can generate metrics.
- Returns:
True if metrics generation is supported.
- language_to_service_language(language: Language) str | None[source]
Convert a Language enum to the Meta STT language name.
- property send_sample_rate: int
Get the rate audio is sent at, which the API limits to 24 kHz or 16 kHz.
- Returns:
The sample rate in Hz.
- async setup(setup: FrameProcessorSetup)[source]
Set up the service and connect.
- Parameters:
setup – Configuration object containing setup parameters.
- async cancel(frame: CancelFrame)[source]
Cancel the speech-to-text service.
- async run_stt(audio: bytes) AsyncGenerator[Frame | None, None][source]
Forward raw audio bytes to the Meta STT WebSocket.
Transcription frames are pushed from the receive task, not yielded from this coroutine.
- async push_frame(frame: Frame, direction: FrameDirection = FrameDirection.DOWNSTREAM)
Push a frame downstream, tracking TranscriptionFrame timestamps for TTFB.
Stores the timestamp of each TranscriptionFrame for TTFB calculation. If the frame is marked as finalized (via request_finalize/confirm_finalize), reports TTFB immediately and cancels any pending timeout. Otherwise, TTFB is reported after a timeout.
- Parameters:
frame – The frame to push.
direction – The direction to push the frame.