Skip to main content

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 (such as SileroVADAnalyzer, set with LLMUserAggregatorParams(vad_analyzer=...)) 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:
  1. Speechmatics Account: Sign up at Speechmatics
  2. API Key: Generate an API key from your account dashboard
  3. Feature Selection: Configure transcription features like speaker diarization

Select Endpoint

Speechmatics Agent STT supports the following endpoints (defaults to EU2): 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 authentication
  • SPEECHMATICS_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
Deprecated since 0.0.105, removed in 2.0.0. 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 the settings 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 default TurnDetectionMode.EXTERNAL hands endpointing to the caller. The service does not endpoint on its own; instead, it closes a turn when it receives VADUserStoppedSpeakingFrame, 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.

Speaker Diarization

Speechmatics STT supports speaker diarization, which separates out different speakers in the audio. The user_id attribute of each TranscriptionFrame holds the Speechmatics speaker label (empty when there is none), never the transport’s user ID. 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.
Speechmatics STT supports the following languages and regional variants. Setting a language can be done using the 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: Sample projects:

Basic Configuration

Initialize the SpeechmaticsSTTService and use it in a pipeline:

With Diarization

Enable diarization to attribute transcribed words to unique speakers. Initialize the SpeechmaticsSTTService and use it in a pipeline:

Methods

send_message()

Sends a client message to the Speechmatics session, with any keyword arguments added to the message payload. Send ClientMessageType.GET_SPEAKERS to request the session’s speaker data, which arrives in on_speakers_result. Raises RuntimeError if the session isn’t connected or the message can’t be sent.

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.
  • VAD Integration: Server-side VAD and turn detection are available in VAD mode

Event Handlers

In addition to the on_disconnected service event, Speechmatics provides: