Skip to main content
Voice enables agents to communicate through natural speech, supporting real-time voice conversations, voice commands, and audio-based interactions.

Overview

The Voice primitive transforms text-based agents into voice-enabled conversational AI systems. With built-in speech-to-text (STT) and text-to-speech (TTS) capabilities, agents can understand spoken language and respond with natural-sounding speech, enabling hands-free interactions and accessibility features. Voice is essential for:
  • Voice Assistants: Build Alexa/Siri-style voice interfaces
  • Phone Systems: Create AI-powered phone support and IVR systems
  • Accessibility: Make applications accessible to visually impaired users
  • Hands-Free Interactions: Enable voice commands for hands-free operation
  • Natural Conversations: Provide more natural, human-like interactions
  • Multilingual Support: Communicate in multiple languages with native accents

Real-Time STT

Convert speech to text in real-time with high accuracy and low latency

Natural TTS

Generate natural-sounding speech in multiple voices, languages, and accents

Voice Streaming

Stream audio input and output for low-latency conversational experiences

Voice Customization

Customize voice characteristics, speed, pitch, and speaking style

How Voice Works

When you enable voice for an agent:
  1. Audio Input: User speaks into microphone or phone
  2. Speech-to-Text: Audio is transcribed to text in real-time
  3. Agent Processing: Agent processes text and generates response
  4. Text-to-Speech: Response is converted to natural speech
  5. Audio Output: Generated speech is played to user
  6. Streaming: For real-time conversations, audio streams continuously
Low Latency: Voice streaming enables natural conversation flow with minimal delay between speaking and response.

Voice Capabilities

Speech-to-Text (STT)

Convert spoken words to text:

Text-to-Speech (TTS)

Generate natural speech from text:

Code Examples

Basic Voice Conversation

Real-Time Voice Streaming

Voice with Multiple Languages

Custom Voice Characteristics

Phone Integration

Voice with Interruption Handling

Use Cases

1. Customer Service Phone System

AI-powered phone support:

2. Voice-Enabled Personal Assistant

Hands-free assistant for daily tasks:

3. Language Learning Tutor

Interactive language practice:

4. Healthcare Voice Interface

Accessible medical information:

5. Voice-Activated Navigation

Hands-free driving assistance:

6. Conference Room Assistant

Meeting room voice control:

Best Practices

Voice Design

Voice Selection

Match Voice to Use Case: Choose voice characteristics that match your application’s personality and audience.

Error Handling

Always Handle Audio Errors: Network issues, microphone problems, and audio format incompatibilities can disrupt voice interactions.

Privacy and Security

Integration with Other Primitives

With Memory

Remember conversation context:
Learn more: Memory Primitive

With Custom Tools

Access external services:
Learn more: Custom Tools Primitive

With Multi-Agent

Transfer between voice agents:
Learn more: Multi-Agent Primitive

Performance Considerations

Latency Optimization

Bandwidth Management

Optimize for Network: Choose appropriate audio formats and quality based on network conditions.

Cost Management

Troubleshooting

Problem: Voice output sounds robotic or distortedSolutions:
  • Increase sample rate (24kHz or 48kHz)
  • Use neural voices instead of standard
  • Check network bandwidth
  • Reduce speed/pitch modifications
  • Use appropriate audio format for medium
Problem: Delay between speaking and responseSolutions:
  • Enable streaming for input and output
  • Reduce endpointing delay
  • Optimize agent response time
  • Use closer geographic region
  • Enable voice activity detection
Problem: Speech not transcribed correctlySolutions:
  • Specify correct language
  • Improve audio quality (reduce noise)
  • Use appropriate dialect
  • Add custom vocabulary
  • Enable noise reduction
Problem: Agent continues speaking when interruptedSolutions:
  • Enable interruptible output
  • Configure interruption handling
  • Reduce VAD sensitivity
  • Check audio pipeline configuration

Advanced Features

Emotion Detection

Detect user emotion from voice:

Voice Biometrics

Identify speakers by voice:

Multi-Party Conversations

Handle multiple speakers:

Sessions

Maintain voice conversation context

Memory

Remember user preferences and history

Multi-Agent

Transfer between voice specialists

Custom Tools

Integrate external services in voice flows

Additional Resources

API Reference

Complete voice API documentation

Voice Design Guide

Best practices for voice UX

Examples

Voice integration examples
Remember: Voice interfaces require different design principles than text interfaces. Keep responses concise, design for interruptions, and provide clear audio feedback.