> ## 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.

# Audio

> Text-to-speech and speech-to-text

Agents can speak and listen - convert text to speech and transcribe audio.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Audio Processing"
        A[👤 User] --> B[🤖 Agent]
        B -->|speak| C[🔊 Audio]
        B -->|listen| D[📝 Text]
    end
    
    classDef user fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef output fill:#10B981,stroke:#7C90A0,color:#fff
    
    class A user
    class B agent
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff
    class C,D output
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

## Quick Start

**1. Simple Usage**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent } from 'praisonai';

const agent = new Agent({
  instructions: 'You are a helpful assistant',
  audio: true
});

// Agent response as audio
const audio = await agent.speak('Hello! How can I help you today?');
// Returns audio buffer
```

**2. With Configuration**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// Transcribe audio file
const text = await agent.transcribe('./recording.mp3');
console.log(text);
// "This is what was said in the recording..."
```

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Audio
    
    User->>Agent: "Read this aloud"
    Agent->>Audio: Generate speech
    Audio-->>User: 🔊 Audio playback
    
    User->>Agent: [voice recording]
    Agent->>Audio: Transcribe
    Audio-->>Agent: Text content
    Agent-->>User: "You said..."
```

***

## Configuration Levels

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// Level 1: Bool - Enable with defaults
const agent = new Agent({
  audio: true
});

// Level 2: String - Specify voice
const agent = new Agent({
  audio: 'alloy'  // OpenAI voice name
});

// Level 3: Dict - Full options
const agent = new Agent({
  audio: {
    voice: 'nova',
    model: 'tts-1-hd',
    speed: 1.0,
    format: 'mp3'
  }
});

// Level 4: Instance - AudioAgent
import { AudioAgent } from 'praisonai';

const audio = new AudioAgent({
  provider: 'elevenlabs',
  voice: 'rachel'
});
```

***

## Audio Options

| Option | Description |
| - | - |
| `voice` | Voice name (alloy, echo, nova, etc.) |
| `model` | TTS model (tts-1, tts-1-hd) |
| `speed` | Playback speed (0.25 to 4.0) |
| `format` | Output format (mp3, wav, opus) |

***

## API Reference

> [card] [AudioConfig](https://praison.ai/docs/sdk/reference/typescript/classes/AudioConfig.md)
>
> Complete configuration options

***

## Best Practices

> [accordion] Use HD for quality
>
> `tts-1-hd` sounds more natural but costs more.

> [accordion] Match voice to content
>
> Choose voices that match your content's tone and audience.

> [accordion] Handle long text
>
> Break long text into chunks for better audio quality.

***

## Related

> [card] [Voice](https://praison.ai/docs/js/voice.md)
>
> Voice conversations

> [card] [Realtime](https://praison.ai/docs/js/realtime.md)
>
> Real-time streaming


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.