tts

Speechify Text-to-Speech Service Implementation.

Contains SpeechifyHttpTTSService, which streams audio and word-level speech marks from Speechify’s /v1/audio/stream/with-timestamps endpoint over Server-Sent Events.

pipecat.services.speechify.tts.language_to_speechify_language(language: Language) → str | None[source]

Convert a Language enum to a Speechify language tag.

Parameters:

language – The Language enum value to convert.

Returns:

The corresponding Speechify language tag (e.g. "en-US"). Languages outside the officially supported set fall back to their BCP-47 value with a warning.

class pipecat.services.speechify.tts.SpeechifyTTSSettings(model: str | None | NotGiven = <factory>, extra: dict[str, ~typing.Any]=<factory>, voice: str | None | NotGiven = <factory>, language: Language | str | None | NotGiven = <factory>, loudness_normalization: bool | None | NotGiven = <factory>, text_normalization: bool | None | NotGiven = <factory>, safety_identifier: str | None | NotGiven = <factory>, pronunciations: list[dict[str, ~typing.Any]] | None | ~pipecat.utils.types.NotGiven=<factory>)[source]

Bases: TTSSettings

Settings for SpeechifyHttpTTSService.

Parameters:
  • loudness_normalization – Whether to normalize audio loudness to a standard level. Adds latency.

  • text_normalization – Whether to spell out numbers, dates and similar tokens before synthesis. Adds latency.

  • safety_identifier – Stable, opaque identifier for the end user a request is synthesized for, so Speechify can rate-limit or block that user instead of the whole workspace. 1 to 64 characters of letters, digits and . _ - : | + / = — a keyed hash of an internal user id, never personal data such as an email address, which Speechify rejects.

  • pronunciations –

    How specific words in the text should be spoken, up to 200 entries. Each entry gives the text to match and exactly one of ipa (phones from the model’s set, for a single word) or alias (replacement text), plus an optional case_sensitive:

    [{"text": "Pipecat", "ipa": "p ˈaɪ p k æ t"},
     {"text": "TTS", "alias": "text to speech"}]
    

    Speechify applies these on simba-3.5 in every language it lists under pronunciation_languages in GET /v1/audio/models, which excludes English; any other model or language returns pronunciations_unsupported.

    Another way to guide pronunciation is to pass replace_text() find-and-replace rules through the text_transforms parameter. Pipecat applies them before the text reaches the provider, so the same rules can work across TTS services and depend less on what each provider supports. They’re worth trying if this setting isn’t giving you the results you want.

class pipecat.services.speechify.tts.SpeechifyHttpTTSService(*, api_key: str, aiohttp_session: ClientSession, base_url: str = 'https://api.speechify.ai', sample_rate: int | None = None, settings: SpeechifyTTSSettings | None = None, text_aggregation_mode: TextAggregationMode | None = None, **kwargs)[source]

Bases: TTSService

Speechify HTTP-based TTS service with word timestamps.

Streams PCM audio and word-level speech marks over Server-Sent Events from Speechify’s /v1/audio/stream/with-timestamps endpoint. Defaults to simba-3.5, which covers 48 languages, English included, under one model id.

Requests pin Speechify’s API version to SPEECHIFY_API_VERSION rather than letting the workspace default decide it. The legacy simba-english and simba-multilingual models are retired at that version and return a model_retired error.

Settings

alias of SpeechifyTTSSettings

__init__(*, api_key: str, aiohttp_session: ClientSession, base_url: str = 'https://api.speechify.ai', sample_rate: int | None = None, settings: SpeechifyTTSSettings | None = None, text_aggregation_mode: TextAggregationMode | None = None, **kwargs)[source]

Initialize the Speechify HTTP TTS service.

Parameters:
  • api_key – Speechify API key for authentication.

  • aiohttp_session – aiohttp ClientSession for HTTP requests.

  • base_url – Base URL for the Speechify API.

  • sample_rate – Audio sample rate in Hz. If None, uses the pipeline’s rate.

  • settings – Runtime-updatable settings.

  • text_aggregation_mode – How to aggregate incoming text before synthesis.

  • **kwargs – Additional arguments passed to the parent service.

can_generate_metrics() → bool[source]

Check if this service can generate processing metrics.

Returns:

True, as Speechify TTS service supports metrics generation.

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

Convert a Language enum to a Speechify language tag.

Parameters:

language – The language to convert.

Returns:

The Speechify language tag, or None if not supported.

async setup(setup: FrameProcessorSetup)[source]

Set up the service.

Parameters:

setup – Configuration object containing setup parameters.

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

Push a frame and handle state changes.

Parameters:
  • frame – The frame to push.

  • direction – The direction to push the frame.

async flush_audio(context_id: str | None = None)[source]

Flush any pending audio synthesis.

Note

HTTP-based service doesn’t require explicit flushing.

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

Generate speech from text using the Speechify streaming API with timestamps.

Parameters:
  • text – Text to convert to speech.

  • context_id – Unique identifier for this TTS context.

Yields:

Frame – Audio frames containing the synthesized speech.