> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# speech • AI Agent SDK

> speech: Convert text to speech.

# speech

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**AudioAgent**](../classes/AudioAgent) class in the [**audio\_agent**](../modules/audio_agent) module.

Convert text to speech.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def speech(text: str, output: Optional[str], voice: Optional[str], speed: Optional[float], response_format: Optional[str], model: Optional[str]) -> Any
```

## Parameters

<ParamField query="text" type="str" required={true}>
  Text to convert to speech
</ParamField>

<ParamField query="output" type="Optional" required={false}>
  Path to save audio file (optional)
</ParamField>

<ParamField query="voice" type="Optional" required={false}>
  Voice to use (e.g., "alloy", "echo", "fable")
</ParamField>

<ParamField query="speed" type="Optional" required={false}>
  Speech speed (0.25 to 4.0)
</ParamField>

<ParamField query="response_format" type="Optional" required={false}>
  Audio format (mp3, opus, aac, flac, wav)
</ParamField>

<ParamField query="model" type="Optional" required={false}>
  Override model for this call \*\*kwargs: Additional provider-specific parameters
</ParamField>

### Returns

<ResponseField name="Returns" type="Any">
  Audio response object with stream\_to\_file() method
</ResponseField>

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
agent = AudioAgent(llm="openai/tts-1")
    agent.speech("Hello world!", output="hello.mp3")
```

## Uses

* `speech`
* `response.stream_to_file`
* `Path`

## Used By

* [`AudioAgent.speech`](../functions/AudioAgent-speech)
* [`AudioAgent.say`](../functions/AudioAgent-say)

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/audio_agent.py#L213">
  `praisonaiagents/agent/audio_agent.py` at line 213
</Card>
