Overview
SpeechmaticsSTTService enables real-time speech transcription using Speechmatics’ Agent STT WebSocket API with partial and final results, speaker diarization, and server-side or client-side turn detection.
Speechmatics provides its own user turn start and end detection. When using
TurnDetectionMode.VAD, the service runs its own VAD and closes turns itself,
automatically requesting ExternalUserTurnStrategies at start. The service
proposes each turn boundary and those strategies resolve it, so
should_interrupt is the control for barge-in. See User Turn
Strategies
for more details. A VAD in the transport (such as SileroVADAnalyzer) is
optional when Speechmatics drives turn detection; include it if you want
useful STT metrics.Speechmatics Agent STT Reference
The Agent STT WebSocket API this service speaks
Example Implementation
Complete example with interruption handling
Speechmatics Documentation
Speechmatics’ own guide to this integration
Speaker Diarization Guide
Learn about separating different speakers in audio
Installation
To use Speechmatics services, install the required dependencies:Prerequisites
Speechmatics Account Setup
Before using Speechmatics STT services, you need:- Speechmatics Account: Sign up at Speechmatics
- API Key: Generate an API key from your account dashboard
- Feature Selection: Configure transcription features like speaker diarization
Select Endpoint
Speechmatics Agent STT supports the following endpoints (defaults toEU2):
global.rt.speechmatics.com routes each connection to the nearest region for lowest latency. It may route to any region, so use a regional endpoint if you have data residency requirements. For the full list, see Supported endpoints.
Required Environment Variables
SPEECHMATICS_API_KEY: Your Speechmatics API key for authenticationSPEECHMATICS_RT_URL: Speechmatics endpoint URL (optional, defaults to EU2)
Configuration
SpeechmaticsSTTService
str
default:"None"
Speechmatics API key. Falls back to the
SPEECHMATICS_API_KEY environment
variable.str
default:"None"
Base URL for the Speechmatics API. Falls back to
SPEECHMATICS_RT_URL
environment variable, then defaults to
wss://eu2.rt.speechmatics.com/v2/agent.int
default:"None"
Audio sample rate in Hz. When
None, uses the pipeline’s configured sample
rate.AudioEncoding
default:"AudioEncoding.PCM_S16LE"
Audio encoding format. Init-only — not part of runtime-updatable settings.
SpeechmaticsSTTService.InputParams
default:"None"
deprecated
Additional configuration parameters. Deprecated in v0.0.105. Use
settings=SpeechmaticsSTTService.Settings(...) instead.SpeechmaticsSTTService.Settings
default:"None"
Runtime-configurable settings for the STT service. See Settings
below.
bool
default:"True"
Whether to interrupt bot output when Speechmatics detects user speech. Only
applies when
turn_detection_mode is set to VAD. See User Turn
Strategies
if you pass your own user_turn_strategies.float
default:"0.74"
P99 latency from speech end to final transcript in seconds. Override for your
deployment. See stt-benchmark.
Settings
Runtime-configurable settings passed via thesettings constructor argument using SpeechmaticsSTTService.Settings(...). These can be updated mid-conversation with STTUpdateSettingsFrame. See Service Settings for details.
Turn Detection
The Speechmatics Agent STT service supports two turn detection modes:External mode (Default)
The defaultTurnDetectionMode.EXTERNAL hands endpointing to the caller. The service does not endpoint on its own; instead, the caller drives turns by calling finalize(), typically from Pipecat’s own VAD. Use this mode when you want Pipecat’s VAD to control turn boundaries.
VAD mode
TurnDetectionMode.VAD lets the Speechmatics service run its own VAD and close turns itself. The service emits StartOfTurn and EndOfTurn events, proposes turn boundaries to Pipecat’s turn strategies, and handles endpointing server-side. In this mode, you do not need a VAD in the transport — the service manages turn detection.
When using
VAD mode, remove any vad_analyzer or turn_analyzer from your
transport configuration to avoid conflicts — Speechmatics handles turn
detection itself.Speaker Diarization
Speechmatics STT supports speaker diarization, which separates out different speakers in the audio. The identity of each speaker is returned in the TranscriptionFrame objects in theuser_id attribute.
If speaker_active_format is provided, then the text output for the TranscriptionFrame will be formatted to this specification. Your system context can then be updated to include information about this format to understand which speaker spoke which words.
Examples:
<{speaker_id}>{text}</{speaker_id}>→<S1>Good morning.</S1>.@{speaker_id}: {text}→@S1: Good morning..
Available attributes
Language Support
Refer to the Speechmatics
docs for more
information on supported languages.
language parameter when creating the STT object. The exception to this is English / Mandarin which has the code cmn_en.
For bilingual transcription, use the
language and domain parameters as follows:
Usage Examples
Examples are included in the Pipecat project:- Using Speechmatics STT service -> 07a-interruptible-speechmatics.py
- Using Speechmatics STT service with VAD -> 07a-interruptible-speechmatics-vad.py
- Transcribing with Speechmatics STT -> 13h-speechmatics-transcription.py
Basic Configuration
Initialize theSpeechmaticsSTTService and use it in a pipeline:
With Diarization
Enable diarization to attribute transcribed words to unique speakers. Initialize theSpeechmaticsSTTService and use it in a pipeline:
Additional Notes
- Connection Management: Automatically handles WebSocket connections and reconnections with exponential backoff. Transient failures trigger automatic reconnection while audio is buffered; permanent errors (auth rejection, bad configuration) mark the service unusable.
- Sample Rate: The default sample rate is
16000Hz inpcm_s16leformat - VAD Integration: Server-side VAD and turn detection are available in
VADmode
Event Handlers
In addition to the standard service connection events (on_connected, on_disconnected, on_connection_error), Speechmatics provides: