tts

Speechmatics TTS service integration.

class pipecat.services.speechmatics.tts.SpeechmaticsTTSSettings(model: str | None | _NotGiven = <factory>, extra: dict[str, Any]=<factory>, voice: str | _NotGiven = <factory>, language: Language | str | None | _NotGiven = <factory>, max_retries: int | _NotGiven = <factory>)[source]

Bases: TTSSettings

Settings for SpeechmaticsTTSService.

Parameters:

max_retries – Maximum number of retries for HTTP requests.

voice: str | _NotGiven
max_retries: int | _NotGiven
class pipecat.services.speechmatics.tts.SpeechmaticsTTSService(*, api_key: str, base_url: str = 'https://preview.tts.speechmatics.com', voice_id: str | None = None, aiohttp_session: ClientSession, sample_rate: int | None = 16000, params: InputParams | None = None, settings: SpeechmaticsTTSSettings | None = None, **kwargs)[source]

Bases: TTSService

Speechmatics TTS service implementation.

This service provides text-to-speech synthesis using the Speechmatics HTTP API. It converts text to speech and returns raw PCM audio data for real-time playback.

Settings

alias of SpeechmaticsTTSSettings

SPEECHMATICS_SAMPLE_RATE = 16000
class InputParams(*, max_retries: int = 5)[source]

Bases: BaseModel

Optional input parameters for Speechmatics TTS configuration.

Deprecated since version 0.0.105: Use settings=SpeechmaticsTTSService.Settings(...) instead.

Parameters:

max_retries – Maximum number of retries for TTS requests. Defaults to 5.

max_retries: int
__init__(*, api_key: str, base_url: str = 'https://preview.tts.speechmatics.com', voice_id: str | None = None, aiohttp_session: ClientSession, sample_rate: int | None = 16000, params: InputParams | None = None, settings: SpeechmaticsTTSSettings | None = None, **kwargs)[source]

Initialize the Speechmatics TTS service.

Parameters:
  • api_key – Speechmatics API key for authentication.

  • base_url – Base URL for Speechmatics TTS API.

  • voice_id

    Voice model to use for synthesis.

    Deprecated since version 0.0.105: Use settings=SpeechmaticsTTSService.Settings(voice=...) instead.

  • aiohttp_session – Shared aiohttp session for HTTP requests.

  • sample_rate – Audio sample rate in Hz.

  • params

    Input parameters for the service.

    Deprecated since version 0.0.105: Use settings=SpeechmaticsTTSService.Settings(...) instead.

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

  • **kwargs – Additional arguments passed to TTSService.

can_generate_metrics() bool[source]

Check if this service can generate processing metrics.

Returns:

True, as Speechmatics service supports metrics generation.

async run_tts(text: str, context_id: str) AsyncGenerator[Frame, None][source]

Generate speech from text using Speechmatics’ HTTP API.

Parameters:
  • text – The text to synthesize into speech.

  • context_id – The context ID for tracking audio frames.

Yields:

Frame – Audio frames containing the synthesized speech.