tts

Gradium Text-to-Speech service implementation.

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

Bases: TTSSettings

Settings for GradiumTTSService.

class pipecat.services.gradium.tts.GradiumTTSService(*, api_key: str, voice_id: str | None = None, url: str = 'wss://eu.api.gradium.ai/api/speech/tts', model: str | None = None, json_config: str | None = None, params: InputParams | None = None, settings: GradiumTTSSettings | None = None, **kwargs)[source]

Bases: WebsocketTTSService

Text-to-Speech service using Gradium’s websocket API.

Settings

alias of GradiumTTSSettings

class InputParams(*, temp: float | None = 0.6)[source]

Bases: BaseModel

Configuration parameters for Gradium TTS service.

Deprecated since version 0.0.105: Use GradiumTTSService.Settings directly via the settings parameter instead.

Parameters:

temp – Temperature to be used for generation, defaults to 0.6.

temp: float | None
__init__(*, api_key: str, voice_id: str | None = None, url: str = 'wss://eu.api.gradium.ai/api/speech/tts', model: str | None = None, json_config: str | None = None, params: InputParams | None = None, settings: GradiumTTSSettings | None = None, **kwargs)[source]

Initialize the Gradium TTS service.

Parameters:
  • api_key – Gradium API key for authentication.

  • voice_id

    the voice identifier.

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

  • url – Gradium websocket API endpoint.

  • model

    Model ID to use for synthesis.

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

  • json_config – Optional JSON configuration string for additional model settings.

  • params

    Additional configuration parameters.

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

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

  • **kwargs – Additional arguments passed to parent class.

can_generate_metrics() bool[source]

Check if this service can generate processing metrics.

Returns:

True, as Gradium service supports metrics generation.

async start(frame: StartFrame)[source]

Start the service and establish websocket connection.

Parameters:

frame – The start frame containing initialization parameters.

async stop(frame: EndFrame)[source]

Stop the service and close connection.

Parameters:

frame – The end frame.

async cancel(frame: CancelFrame)[source]

Cancel current operation and clean up.

Parameters:

frame – The cancel frame.

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

Flush any pending audio synthesis.

async on_audio_context_interrupted(context_id: str)[source]

Called when an audio context is cancelled due to an interruption.

No WebSocket message is needed — audio from the interrupted client_req_id will be silently dropped by the base class once the audio context no longer exists.

async on_audio_context_completed(context_id: str)[source]

Called after an audio context has finished playing all of its audio.

No close message is needed: Gradium signals completion with an end_of_stream message (handled in _receive_messages), after which the server-side context is already closed.

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

Generate speech from text using Gradium’s streaming API.

Parameters:
  • text – The text to convert to speech.

  • context_id – Unique identifier for this TTS context.

Yields:

Frame – Audio frames containing the synthesized speech.