Skip to main content
Enable voice interaction with AudioAgent for speech-to-text and text-to-speech.

Quick Start

1

Create Voice-Enabled Agent

use praisonai::{AudioAgent, AudioConfig};

// Configure audio settings
let config = AudioConfig::new()
    .speech_to_text(true)
    .text_to_speech(true)
    .voice("alloy");

// Create AudioAgent (specialized agent with audio capabilities)
let audio_agent = AudioAgent::new()
    .name("Voice Assistant")
    .instructions("You are a helpful voice assistant")
    .config(config)
    .build()?;

// Process audio input
let response = audio_agent.process_audio("path/to/audio.wav").await?;
2

Text-to-Speech Output

use praisonai::{AudioAgent, AudioConfig};

let config = AudioConfig::new()
    .text_to_speech(true)
    .voice("nova");  // Choose voice

let agent = AudioAgent::new()
    .name("Speaker")
    .config(config)
    .build()?;

// Generate speech from text
let audio_bytes = agent.speak("Hello, how can I help?").await?;

AudioConfig

OptionTypeDefaultDescription
speech_to_textboolfalseEnable voice input
text_to_speechboolfalseEnable voice output
voiceStringalloyVoice selection

Available Voices

VoiceStyle
alloyProfessional, balanced
novaWarm, conversational
echoClear, articulate
onyxDeep, authoritative