unotelos-rn-voice-sdk
v1.1.2
Published
React Native SDK for real-time AI voice conversations with Ultravox integration
Downloads
393
Maintainers
Readme
unotelos-rn-voice-sdk
A React Native SDK for real-time AI voice conversations with Ultravox integration.
Features
- 🎤 Real-time voice conversations with AI assistants
- 📱 Cross-platform support (iOS & Android)
- 🎛️ Audio controls (mute/unmute)
- 📡 Session management
- 🌍 Multi-language support (English, Pidgin, Igbo, Hausa, Yoruba)
- 🔧 Built with Kotlin for Android and Objective-C for iOS
- ⚛️ TypeScript support
Installation
npm install unotelos-rn-voice-sdkiOS Setup
- Run
cd ios && pod installto install iOS dependencies - Add microphone permissions to your
Info.plist:
<key>NSMicrophoneUsageDescription</key>
<string>This app needs microphone access for voice conversations</string>Android Setup
- Add microphone permissions to your
android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />- The native module will be automatically linked via React Native auto-linking.
Usage
Basic Example
import { VoiceSDK, VoiceSessionState } from 'unotelos-rn-voice-sdk';
// Initialize the SDK
const sdk = VoiceSDK.getInstance({
baseUrl: 'https://your-backend-url.com/v1/api', // Optional: defaults to https://voice.scalercm.ai
debug: __DEV__,
});
// Set up event listeners
sdk.setEventCallbacks({
onStateChange: (state) => {
console.log('Session state changed:', state);
},
onAudioStateChange: (audioState) => {
console.log('Audio state changed:', audioState);
},
onError: (error) => {
console.error('SDK Error:', error);
},
});
// Start a voice session
await sdk.startSession({
customerId: 'customer-123',
customerName: 'John Doe',
// ... other config
});
// Audio controls
await sdk.mute();
await sdk.unmute();
// End session
await sdk.endSession();Using the VoiceSupportComponent
import React from 'react';
import { VoiceSupportComponent } from '@unotelos/rn-voice-sdk';
export default function App() {
return (
<VoiceSupportComponent
customerData={{
id: 'customer-123',
name: 'John Doe',
phone: '+1234567890',
accountType: 'premium',
}}
backendUrl="https://your-backend-url.com"
debug={__DEV__}
/>
);
}API Reference
VoiceSDK
Methods
getInstance(config: VoiceSDKConfig): VoiceSDK- Get singleton instancesetEventCallbacks(callbacks: VoiceSessionEvents): void- Set event callbacksstartSession(config: VoiceSessionConfig): Promise<void>- Start voice sessionendSession(): Promise<void>- End current sessionmute(): Promise<void>- Mute microphoneunmute(): Promise<void>- Unmute microphonegetSessionState(): VoiceSessionState- Get current session stategetAudioState(): AudioState- Get current audio state
Types
interface VoiceSDKConfig {
backendUrl: string;
debug?: boolean;
}
interface VoiceSessionConfig {
customerId: string;
customerName: string;
customerPhone?: string;
accountType?: string;
metadata?: Record<string, any>;
}
enum VoiceSessionState {
IDLE = 'idle',
INITIALIZING = 'initializing',
CONNECTED = 'connected',
ENDING = 'ending',
ERROR = 'error',
}
enum AudioState {
MUTED = 'muted',
UNMUTED = 'unmuted',
}Development
Setting up Ultravox Integration
This SDK is designed to work with the Ultravox platform. To integrate with Ultravox:
- Android: Add the Ultravox Android SDK dependency to your app's
build.gradle - iOS: Add the Ultravox iOS SDK to your
Podfile - Update the native module code to use the actual Ultravox SDK APIs
Building the SDK
npm run clean
npm run prepareLinting
npm run lintType Checking
npm run typecheckContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT © Unotelos
