Skip to main content

speech

Method
This is a method of the AudioAgent class in the audio_agent module.
Convert text to speech.

Signature

def speech(text: str, output: Optional[str], voice: Optional[str], speed: Optional[float], response_format: Optional[str], model: Optional[str]) -> Any

Parameters

text
str
required
Text to convert to speech
output
Optional
Path to save audio file (optional)
voice
Optional
Voice to use (e.g., “alloy”, “echo”, “fable”)
speed
Optional
Speech speed (0.25 to 4.0)
response_format
Optional
Audio format (mp3, opus, aac, flac, wav)
model
Optional
Override model for this call **kwargs: Additional provider-specific parameters

Returns

Returns
Any
Audio response object with stream_to_file() method

Usage

agent = AudioAgent(llm="openai/tts-1")
    agent.speech("Hello world!", output="hello.mp3")