speech • AI Agent SDK
speech: Convert text to speech.
speech
Method
</div>
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]) -> AnyParameters
ParamField
strText to convert to speech
ParamField
Optional[str]Path to save audio file (optional)
ParamField
Optional[str]Voice to use (e.g., “alloy”, “echo”, “fable”)
ParamField
Optional[float]Speech speed (0.25 to 4.0)
ParamField
Optional[str]Audio format (mp3, opus, aac, flac, wav)
ParamField
Optional[str]Override model for this call **kwargs: Additional provider-specific parameters
Returns
ResponseField
AnyAudio response object with stream_to_file() method
Usage
agent = AudioAgent(llm="openai/tts-1")
agent.speech("Hello world!", output="hello.mp3")Uses
speechresponse.stream_to_filePath
Used By
Source
View on GitHubpraisonaiagents/agent/audio_agent.py at line 211