Skip to main content

Voice Integration

Cedar OS provides comprehensive voice support that integrates seamlessly with your agent backend. Voice processing is now handled through the agent connection system, providing a unified approach across different providers.

Voice Processing Architecture

As of the latest update, voice processing now works out of the box for Mastra, AI SDK, and custom backends.
  • Mastra/Custom backends: Voice data is sent directly to your voice endpoint
  • AI SDK/OpenAI providers: Voice is transcribed using Whisper, then processed through the LLM.
See the Voice Endpoint Format documentation for implementation details.This is still in beta. If you want more details please check out the repo, book a call at https://calendly.com/jesse-cedarcopilot/30min or join our discord.

Quick Start

Initialize Cedar with voice settings (already configured with the built in Cedar chat input):

Voice Settings

The voiceSettings prop accepts a partial configuration object with the following TypeScript interface:

Default Values

Provider-Specific Configuration

OpenAI / AI SDK

Mastra

Custom Backend

Overview

Cedar-OS provides a complete voice integration system that enables natural voice conversations with AI agents. The voice system handles audio capture, streaming to backend services, and automatic playback of responses, with seamless integration into the messaging system.

Features

  • 🎤 Voice Capture: Browser-based audio recording with permission management
  • 🔊 Audio Playback: Automatic playback of audio responses from agents
  • 🌐 Streaming Support: Real-time audio streaming to configurable endpoints
  • 🔧 Flexible Configuration: Customizable voice settings (language, pitch, rate, volume)
  • 🎯 State Management: Full integration with Cedar’s Zustand-based store
  • 💬 Message Integration: Automatic addition of voice interactions to chat history
  • 🛡️ Error Handling: Comprehensive error states and recovery
  • 🎨 Visual Indicators: Animated voice status indicators

ChatInput Component with Built-in Voice

The ChatInput component from cedar-os-components comes with voice functionality built-in, providing a seamless voice experience out of the box. When you use this component, voice capabilities are automatically available without additional configuration.

How It Works

The ChatInput component integrates voice through the following key features:

ChatInput Implementation Details

The ChatInput component automatically:
  1. Displays a microphone button that changes appearance based on voice state
  2. Shows the VoiceIndicator when voice is active (listening or speaking)
  3. Handles keyboard shortcuts - Press ‘M’ to toggle voice (when not typing)
  4. Manages permissions - Automatically requests microphone access when needed
  5. Provides visual feedback - Button animations and color changes for different states

Exported Components and Hooks

All voice-related functionality is exported from the main cedar-os package:

Quick Start

1. Automatic Configuration with Mastra

The easiest way to set up voice integration is through the Mastra provider configuration:
When you specify a voiceRoute in your Mastra configuration, Cedar-OS automatically sets the voice endpoint to baseURL + voiceRoute.

2. Manual Configuration

For non-Mastra providers or custom setups, configure the voice endpoint manually:

3. Request Microphone Permission

4. Using the Voice Indicator

Provider-Specific Voice Configuration

Mastra Provider

When using the Mastra provider, voice configuration is streamlined through the provider setup:
Benefits of Mastra voice integration:
  • Automatic endpoint configuration
  • Consistent routing with chat endpoints
  • Built-in context passing
  • Structured response handling

Other Providers

For OpenAI, Anthropic, AI SDK, or custom providers, configure the voice endpoint manually:

Voice State

The voice slice manages comprehensive state for voice interactions:

Available Actions

Permission Management

  • checkVoiceSupport() - Check if browser supports voice features
  • requestVoicePermission() - Request microphone access

Voice Control

  • startListening() - Start recording audio
  • stopListening() - Stop recording and send to endpoint
  • toggleVoice() - Toggle between listening and idle states

Audio Processing

  • streamAudioToEndpoint(audioData) - Send audio to backend
  • playAudioResponse(audioUrl) - Play audio response

Configuration

  • setVoiceEndpoint(endpoint) - Set the backend endpoint URL
  • updateVoiceSettings(settings) - Update voice configuration
  • setVoiceError(error) - Set error message
  • resetVoiceState() - Clean up and reset all voice state

Message Integration

By default, voice interactions are automatically added to the Cedar messages store, creating a seamless conversation history:

Disabling Message Integration

Browser Compatibility

The voice system requires modern browser APIs:
  • navigator.mediaDevices.getUserMedia - Audio capture
  • MediaRecorder API - Audio recording
  • AudioContext API - Audio processing
Supported browsers:
  • Chrome/Edge 47+
  • Firefox 25+
  • Safari 11+
  • Opera 34+
HTTPS is required for microphone access in production environments (localhost is exempt).

Next Steps

Backend Integration

Learn how to set up your backend to handle voice requests

Streaming Implementation

Implement real-time audio streaming

Examples

Complete Voice Chat Component