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:
TTSSettingsSettings 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:
WebsocketTTSServiceText-to-Speech service using Gradium’s websocket API.
- Settings
alias of
GradiumTTSSettings
- class InputParams(*, temp: float | None = 0.6)[source]
Bases:
BaseModelConfiguration parameters for Gradium TTS service.
Deprecated since version 0.0.105: Use
GradiumTTSService.Settingsdirectly via thesettingsparameter 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,
settingsvalues 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 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_idwill 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_streammessage (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.