TTS
- pipecat.services.playht.tts.language_to_playht_language(language)[source]
- Parameters:
language (Language)
- Return type:
str | None
- class pipecat.services.playht.tts.PlayHTTTSService(*, api_key, user_id, voice_url, voice_engine='Play3.0-mini', sample_rate=None, output_format='wav', params=None, **kwargs)[source]
Bases:
InterruptibleTTSService
- Parameters:
api_key (str)
user_id (str)
voice_url (str)
voice_engine (str)
sample_rate (int | None)
output_format (str)
params (InputParams | None)
- class InputParams(*, language=Language.EN, speed=1.0, seed=None)[source]
Bases:
BaseModel
- Parameters:
language (Language | None)
speed (float | None)
seed (int | None)
- language: Language | None
- speed: float | None
- seed: int | None
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- can_generate_metrics()[source]
- Return type:
bool
- language_to_service_language(language)[source]
Convert a language to the service-specific language format.
- Parameters:
language (Language) – The language to convert.
- Returns:
The service-specific language identifier, or None if not supported.
- Return type:
str | None
- async start(frame)[source]
Start the TTS service.
- Parameters:
frame (StartFrame) – The start frame containing initialization parameters.
- async stop(frame)[source]
Stop the TTS service.
- Parameters:
frame (EndFrame) – The end frame.
- async cancel(frame)[source]
Cancel the TTS service.
- Parameters:
frame (CancelFrame) – The cancel frame.
- async run_tts(text)[source]
Run text-to-speech synthesis on the provided text.
This method must be implemented by subclasses to provide actual TTS functionality.
- Parameters:
text (str) – The text to synthesize into speech.
- Yields:
Frame – Audio frames containing the synthesized speech.
- Return type:
AsyncGenerator[Frame, None]
- class pipecat.services.playht.tts.PlayHTHttpTTSService(*, api_key, user_id, voice_url, voice_engine='Play3.0-mini', protocol='http', sample_rate=None, params=None, **kwargs)[source]
Bases:
TTSService
- Parameters:
api_key (str)
user_id (str)
voice_url (str)
voice_engine (str)
protocol (str)
sample_rate (int | None)
params (InputParams | None)
- class InputParams(*, language=Language.EN, speed=1.0, seed=None)[source]
Bases:
BaseModel
- Parameters:
language (Language | None)
speed (float | None)
seed (int | None)
- language: Language | None
- speed: float | None
- seed: int | None
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- async start(frame)[source]
Start the TTS service.
- Parameters:
frame (StartFrame) – The start frame containing initialization parameters.
- can_generate_metrics()[source]
- Return type:
bool
- language_to_service_language(language)[source]
Convert a language to the service-specific language format.
- Parameters:
language (Language) – The language to convert.
- Returns:
The service-specific language identifier, or None if not supported.
- Return type:
str | None
- async run_tts(text)[source]
Run text-to-speech synthesis on the provided text.
This method must be implemented by subclasses to provide actual TTS functionality.
- Parameters:
text (str) – The text to synthesize into speech.
- Yields:
Frame – Audio frames containing the synthesized speech.
- Return type:
AsyncGenerator[Frame, None]