stt

Whisper speech-to-text services with locally-downloaded models.

This module implements Whisper transcription using locally-downloaded models, supporting both Faster Whisper and MLX Whisper backends for efficient inference.

class pipecat.services.whisper.stt.Model(*values)[source]

Bases: StrEnum

Whisper model selection options for Faster Whisper.

Provides various model sizes and specializations for speech recognition, balancing quality and performance based on use case requirements.

Parameters:
  • TINY – Smallest multilingual model, fastest inference.

  • BASE – Basic multilingual model, good speed/quality balance.

  • SMALL – Small multilingual model, better speed/quality balance than BASE.

  • MEDIUM – Medium-sized multilingual model, better quality.

  • LARGE – Best quality multilingual model, slower inference.

  • LARGE_V3_TURBO – Fast multilingual model, slightly lower quality than LARGE.

  • DISTIL_LARGE_V2 – Fast English-only distilled model.

  • DISTIL_MEDIUM_EN – Fast English-only distilled model.

TINY = 'tiny'
BASE = 'base'
SMALL = 'small'
MEDIUM = 'medium'
LARGE = 'large-v3'
LARGE_V3_TURBO = 'deepdml/faster-whisper-large-v3-turbo-ct2'
DISTIL_LARGE_V2 = 'Systran/faster-distil-whisper-large-v2'
DISTIL_MEDIUM_EN = 'Systran/faster-distil-whisper-medium.en'
class pipecat.services.whisper.stt.MLXModel(*values)[source]

Bases: StrEnum

MLX Whisper model selection options for Apple Silicon.

Provides various model sizes optimized for Apple Silicon hardware, including quantized variants for improved performance.

Parameters:
  • TINY – Smallest multilingual model for MLX.

  • MEDIUM – Medium-sized multilingual model for MLX.

  • LARGE_V3 – Best quality multilingual model for MLX.

  • LARGE_V3_TURBO – Finetuned, pruned Whisper large-v3, much faster with slightly lower quality.

  • LARGE_V3_TURBO_Q4 – LARGE_V3_TURBO quantized to Q4 for reduced memory usage.

  • DISTIL_LARGE_V3 – Fast English-only distilled model for MLX.

TINY = 'mlx-community/whisper-tiny'
MEDIUM = 'mlx-community/whisper-medium-mlx'
LARGE_V3 = 'mlx-community/whisper-large-v3-mlx'
LARGE_V3_TURBO = 'mlx-community/whisper-large-v3-turbo'
LARGE_V3_TURBO_Q4 = 'mlx-community/whisper-large-v3-turbo-q4'
DISTIL_LARGE_V3 = 'mlx-community/distil-whisper-large-v3'
pipecat.services.whisper.stt.language_to_whisper_language(language: Language) → str[source]

Maps pipecat Language enum to Whisper language codes.

Parameters:

language – A Language enum value representing the input language.

Returns:

The corresponding service language code. If language is not in the verified mapping, falls back to the base language code (e.g., en from en-US) and logs a warning (via resolve_language(..., use_base_code=True)).

Note

Only includes languages officially supported by Whisper.

class pipecat.services.whisper.stt.WhisperSTTSettings(model: str | None | NotGiven = <factory>, extra: dict[str, ~typing.Any]=<factory>, language: Language | str | None | NotGiven = <factory>, no_speech_prob: float | NotGiven = <factory>, hotwords: str | None | NotGiven = <factory>, initial_prompt: str | None | NotGiven = <factory>)[source]

Bases: STTSettings

Settings for WhisperSTTService.

Parameters:
  • no_speech_prob – Probability threshold for filtering non-speech segments.

  • hotwords – Words or phrases to bias the transcription towards, as a single space-separated string (e.g. product names or jargon).

  • initial_prompt – Text prepended to the decoder prompt as preceding context, steering style, punctuation and spelling (e.g. a sample sentence in the wording the transcript should use).

class pipecat.services.whisper.stt.WhisperMLXSTTSettings(model: str | None | NotGiven = <factory>, extra: dict[str, ~typing.Any]=<factory>, language: Language | str | None | NotGiven = <factory>, no_speech_prob: float | NotGiven = <factory>, temperature: float | NotGiven = <factory>, engine: str | NotGiven = <factory>)[source]

Bases: STTSettings

Settings for WhisperMLXSTTService.

Parameters:
  • no_speech_prob – Probability threshold for filtering non-speech segments.

  • temperature – Sampling temperature (0.0-1.0).

  • engine – Whisper engine identifier.

class pipecat.services.whisper.stt.WhisperSTTService(*, model: str | Model | None = None, device: str = 'auto', compute_type: str = 'default', no_speech_prob: float | None = None, language: Language | None = None, settings: WhisperSTTSettings | None = None, **kwargs)[source]

Bases: SegmentedSTTService

Class to transcribe audio with a locally-downloaded Whisper model.

This service uses Faster Whisper to perform speech-to-text transcription on audio segments. It supports multiple languages and various model sizes.

Settings

alias of WhisperSTTSettings

property wants_wav_segments: bool

Receive segments as raw 16-bit PCM, which the model reads directly.

property segment_sample_rate: int

Receive segments at 16 kHz, the rate Whisper reads.

__init__(*, model: str | Model | None = None, device: str = 'auto', compute_type: str = 'default', no_speech_prob: float | None = None, language: Language | None = None, settings: WhisperSTTSettings | None = None, **kwargs)[source]

Initialize the Whisper STT service.

Parameters:
  • model –

    The Whisper model to use for transcription. Can be a Model enum or string.

    Deprecated since version 0.0.105: Use settings=WhisperSTTService.Settings(model=...) instead. Will be removed in 2.0.0.

  • device – The device to run inference on (‘cpu’, ‘cuda’, or ‘auto’). Defaults to "auto".

  • compute_type – The compute type for inference (‘default’, ‘int8’, ‘int8_float16’, etc.). Defaults to "default".

  • no_speech_prob –

    Probability threshold for filtering out non-speech segments.

    Deprecated since version 0.0.105: Use settings=WhisperSTTService.Settings(no_speech_prob=...) instead. Will be removed in 2.0.0.

  • language –

    The default language for transcription.

    Deprecated since version 0.0.105: Use settings=WhisperSTTService.Settings(language=...) instead. Will be removed in 2.0.0.

  • settings – Runtime-updatable settings. When provided alongside deprecated parameters, settings values take precedence.

  • **kwargs – Additional arguments passed to SegmentedSTTService.

can_generate_metrics() → bool[source]

Indicates whether this service can generate metrics.

Returns:

True, as this service supports metric generation.

Return type:

bool

language_to_service_language(language: Language) → str | None[source]

Convert from pipecat Language to Whisper language code.

Parameters:

language – The Language enum value to convert.

Returns:

The corresponding Whisper language code, or None if not supported.

async run_stt(audio: bytes) → AsyncGenerator[Frame, None][source]

Transcribe audio data using Whisper.

Parameters:

audio – Raw 16-bit PCM audio at 16 kHz.

Yields:

Frame –

Either a TranscriptionFrame containing the transcribed text

or an ErrorFrame if transcription fails.

Note

The audio is expected to be 16-bit signed PCM data. The service will normalize it to float32 in the range [-1, 1].

async push_frame(frame: Frame, direction: FrameDirection = FrameDirection.DOWNSTREAM)

Push a frame, marking a TranscriptionFrame finalized when its segment is the latest.

Once the user speaks again, the transcript of an earlier segment covers only the words before they resumed, so it isn’t finalized, the same way STTService drops a pending finalize when the user starts speaking. When a segment’s transcript arrives as several diarized TranscriptionFrames (one per speaker run), only the last one can be.

Parameters:
  • frame – The frame to push.

  • direction – The direction of frame flow in the pipeline.

async start_stt_usage_metrics(usage: STTUsage)

Start STT usage metrics collection.

Parameters:

usage – Usage information for the STT operation.

async stop_ttfb_metrics(*, end_time: float | None = None)

Stop time-to-first-byte metrics collection and push results.

Parameters:

end_time – Optional timestamp to use as the end time. If None, uses the current time.

class pipecat.services.whisper.stt.WhisperSTTServiceMLX(*, model: str | MLXModel | None = None, no_speech_prob: float | None = None, language: Language | None = None, temperature: float | None = None, settings: WhisperMLXSTTSettings | None = None, **kwargs)[source]

Bases: WhisperSTTService

Subclass of WhisperSTTService with MLX Whisper model support.

This service uses MLX Whisper to perform speech-to-text transcription on audio segments. It’s optimized for Apple Silicon and supports multiple languages and quantizations.

Settings

alias of WhisperMLXSTTSettings

__init__(*, model: str | MLXModel | None = None, no_speech_prob: float | None = None, language: Language | None = None, temperature: float | None = None, settings: WhisperMLXSTTSettings | None = None, **kwargs)[source]

Initialize the MLX Whisper STT service.

Parameters:
  • model –

    The MLX Whisper model to use for transcription. Can be an MLXModel enum or string.

    Deprecated since version 0.0.105: Use settings=WhisperSTTServiceMLX.Settings(model=...) instead. Will be removed in 2.0.0.

  • no_speech_prob –

    Probability threshold for filtering out non-speech segments.

    Deprecated since version 0.0.105: Use settings=WhisperSTTServiceMLX.Settings(no_speech_prob=...) instead. Will be removed in 2.0.0.

  • language –

    The default language for transcription.

    Deprecated since version 0.0.105: Use settings=WhisperSTTServiceMLX.Settings(language=...) instead. Will be removed in 2.0.0.

  • temperature –

    Temperature for sampling. Can be a float or tuple of floats.

    Deprecated since version 0.0.105: Use settings=WhisperSTTServiceMLX.Settings(temperature=...) instead. Will be removed in 2.0.0.

  • settings – Runtime-updatable settings. When provided alongside deprecated parameters, settings values take precedence.

  • **kwargs – Additional arguments passed to SegmentedSTTService.

async run_stt(audio: bytes) → AsyncGenerator[Frame, None][source]

Transcribe audio data using MLX Whisper.

The audio is expected to be 16-bit signed PCM data. MLX Whisper will handle the conversion internally.

Parameters:

audio – Raw 16-bit PCM audio at 16 kHz.

Yields:

Frame –

Either a TranscriptionFrame containing the transcribed text

or an ErrorFrame if transcription fails.