πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

realtime-voice-ai

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

realtime-voice-ai

A powerful, fully configurable React component for real-time voice chat powered by OpenAI's Realtime API. Create natural conversations with AI using advanced voice recognition and synthesis.

2.5.3
latest
Source
npm
Version published
Weekly downloads
13
-31.58%
Maintainers
1
Weekly downloads
Β 
Created
Source

πŸŽ™οΈ React Voice Chat Assistant

npm version Downloads

A powerful, fully configurable React component that provides instant voice chat functionality powered by OpenAI's Realtime API. Instead of building voice chat from scratch, simply import and configure this component to add natural, human-like voice conversations to your application.

πŸš€ Why Choose This Package?

  • 🎯 Instant Integration: Add voice chat to your app in minutes, not days
  • πŸ”§ Fully Configurable: Customize every aspect of the voice chat experience
  • 🎭 Natural Conversations: Built-in emotional expressions and human-like speech patterns
  • 🎨 Multiple UI Variants: Choose from 4 pre-built UI designs or create your own
  • ⚑ Real-time Communication: Powered by OpenAI's latest Realtime API
  • πŸ›‘οΈ Production Ready: Comprehensive error handling and fallback mechanisms

πŸ“¦ Installation

npm install realtime-voice-ai
yarn add realtime-voice-ai

🎬 Quick Start

import React from 'react';
import { VoiceChatTrigger } from 'realtime-voice-ai';

function App() {
  const config = {
    instructions: "You are a helpful assistant that speaks naturally with emotions.",
    voice: 'verse',
    temperature: 0.8
  };

  return (
    <VoiceChatTrigger
      name="John"
      botType="rvc"
      uiVersion="v2"
      apikey="your-openai-api-key"
      config={config}
    />
  );
}

πŸ“š Complete API Reference

Component Props

PropTypeRequiredDefaultDescription
namestringNoundefinedUser's name for personalized greetings and responses
botTypestringYes-Type of voice chat: 'rvc' (RealTimeVoiceChat) or 'va' (VoiceAssistant)
uiVersionstringNo'v1'UI variant: 'v1', 'v2', 'v3', 'v4', or 'custom'
customUIobjectNoundefinedCustom UI configuration when uiVersion='custom'
apikeystringYes-Your OpenAI API key
isDisabledbooleanNofalseWhether the voice chat is disabled
configobjectNo{}Session configuration object (see below)

Configuration Object (config)

Model & Basic Settings

PropertyTypeDefaultAllowed ValuesDescription
modelstring'gpt-4o-realtime-preview-2024-12-17''gpt-4o-realtime-preview-2024-12-17'OpenAI Realtime model
modalitiesarray['audio', 'text']['audio'], ['text'], ['audio', 'text']Supported interaction modes
instructionsstringNatural conversation promptAny stringAI personality and behavior instructions

Voice & Response Settings

PropertyTypeDefaultAllowed ValuesDescription
voicestring'alloy''alloy', 'ash', 'ballad', 'coral', 'echo', 'sage', 'shimmer', 'verse'Voice personality
temperaturenumber0.80.6 - 1.2Response creativity and randomness
max_response_output_tokensstring|number'inf''inf' or 1 - 4096Maximum response length

Audio Configuration

PropertyTypeDefaultAllowed ValuesDescription
input_audio_formatstring'pcm16''pcm16', 'g711_ulaw', 'g711_alaw'Input audio format
output_audio_formatstring'pcm16''pcm16', 'g711_ulaw', 'g711_alaw'Output audio format
input_audio_transcriptionobject{ model: 'whisper-1' }{ model: 'whisper-1' }Transcription settings

Turn Detection Settings

PropertyTypeDefaultRange/ValuesDescription
turn_detection.typestring'server_vad''server_vad', 'none'Voice activity detection type
turn_detection.thresholdnumber0.50.0 - 1.0Voice detection sensitivity
turn_detection.prefix_padding_msnumber2000 - 5000Audio padding before speech (ms)
turn_detection.silence_duration_msnumber4000 - 20000Silence duration to trigger response (ms)
turn_detection.create_responsebooleantruetrue, falseAuto-generate responses

🎨 UI Versions

Choose from multiple pre-built UI designs:

v1 - Classic Animated Blob

Classic animated blob with pulse effects UI Version 1

v2 - Modern Gradient Blob

Modern gradient blob with smooth animations UI Version 2

v3 - Geometric Animated Shapes

Geometric animated shapes with color transitions UI Version 3

v4 - Advanced Particle System

Advanced particle system with dynamic effects UI Version 4

v5 - Advanced Wave Particle System

Advanced particle system with dynamic effects UI Version 5

This one is the best in my opionion 😁

custom - Your Own Design

Use your own UI component by passing it to the customUI prop

🎡 Voice Personalities

VoiceCharacteristicsBest For
alloyNeutral, balancedGeneral purpose, professional
ashSmooth, sophisticatedBusiness presentations, formal conversations
balladMelodic, expressiveStorytelling, creative content
coralWarm, friendlyCustomer service, casual conversations
echoClear, crispTechnical support, education
sageWise, calmHealthcare, therapy, guidance
shimmerSoft, gentleChildren's content, soothing interactions
verseRhythmic, engagingEntertainment, dynamic conversations

πŸ“– Usage Examples

Basic Configuration

import { VoiceChatTrigger } from 'realtime-voice-ai';

const BasicExample = () => {
  const basicConfig = {
    instructions: "You are a helpful customer service representative.",
    voice: "coral",
    temperature: 0.7
  };

  return (
    <VoiceChatTrigger
      name="Sarah"
      botType="rvc"
      uiVersion="v2"
      apikey={process.env.REACT_APP_OPENAI_API_KEY}
      config={basicConfig}
    />
  );
};

Advanced Configuration

const AdvancedExample = () => {
  const advancedConfig = {
    model: 'gpt-4o-realtime-preview-2024-12-17',
    modalities: ['audio', 'text'],
    instructions: `You are an enthusiastic fitness coach. Use natural expressions like "Oh wow!", "That's amazing!", and "Let's go!" to motivate users. Be encouraging and energetic.`,
    voice: 'nova',
    temperature: 0.9,
    max_response_output_tokens: 2048,
    turn_detection: {
      type: 'server_vad',
      threshold: 0.6,
      prefix_padding_ms: 300,
      silence_duration_ms: 500,
      create_response: true
    }
  };

  return (
    <VoiceChatTrigger
      name="Alex"
      botType="rvc"
      uiVersion="v4"
      apikey={process.env.REACT_APP_OPENAI_API_KEY}
      config={advancedConfig}
    />
  );
};

πŸ”§ Environment Variables

For security, store your API key in environment variables:

# .env
REACT_APP_OPENAI_API_KEY=your_openai_api_key_here
// Use in your component
apikey={import.meta.env.REACT_APP_OPENAI_API_KEY}

🎯 Turn Detection Tuning Guide

Fine-tune when the AI responds by adjusting these parameters:

Sensitivity Settings

  • High Sensitivity (threshold: 0.2-0.4): Responds to quieter speech, may pick up background noise
  • Medium Sensitivity (threshold: 0.4-0.6): Balanced detection, good for most environments
  • Low Sensitivity (threshold: 0.6-0.8): Requires clearer speech, filters out background noise

Response Timing

  • Fast Response (silence_duration_ms: 200-400): Quick interactions, may interrupt user
  • Normal Response (silence_duration_ms: 400-600): Standard conversation timing
  • Thoughtful Response (silence_duration_ms: 600-1000): Allows for pauses, better for complex topics

🚨 Troubleshooting

Common Issues

IssueSolution
No audio playbackCheck browser microphone permissions
Voice cuts outAdjust threshold value (try 0.6-0.7)
AI interrupts userIncrease silence_duration_ms (try 600-800)
Delayed responsesDecrease silence_duration_ms (try 300-400)
Connection failsVerify OpenAI API key and internet connection

Browser Compatibility

  • βœ… Chrome 88+
  • βœ… Firefox 84+
  • βœ… Safari 14.1+
  • βœ… Edge 88+

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“ž Support

If you encounter any issues or have questions:

Made with ❀️ for developers who want to add natural voice conversations to their applications.

Keywords

voice-chat

FAQs

Package last updated on 05 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts