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

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

Parameters

ParamField str

Text 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 Any

Audio response object with stream_to_file() method

Usage

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

Uses

  • speech
  • response.stream_to_file
  • Path

Used By

Source

View on GitHub

praisonaiagents/agent/audio_agent.py at line 211