@swatle2/voice-chatbot
v1.0.0
Published
Zolvit AI Legal Assistant Voice Chatbot - Real-time voice chat with OpenAI Realtime API
Downloads
89
Maintainers
Readme
@swatle/voice-chatbot
Zolvit AI Legal Assistant Voice Chatbot - Real-time voice chat with OpenAI Realtime API
Installation
npm install @swatle/voice-chatbotQuick Start
import { VoiceChatbot } from '@swatle/voice-chatbot';
// Initialize chatbot
const chatbot = new VoiceChatbot({
container: '#chat-container',
apiBaseUrl: 'https://your-api.com',
defaultLanguage: 'english',
defaultVoice: 'verse',
onMessage: (message) => {
console.log('Message received:', message);
}
});
// Initialize and start
await chatbot.init();
await chatbot.start();Configuration Options
VoiceChatbotConfig
interface VoiceChatbotConfig {
container: string | HTMLElement; // Required: Container selector or element
apiBaseUrl?: string; // Backend API base URL
apiKey?: string; // OpenAI API key (optional)
defaultLanguage?: string; // Default language
defaultVoice?: string; // Default AI voice
enableTextChat?: boolean; // Enable text chat mode
enableHistory?: boolean; // Enable conversation history
customStyles?: string; // Custom CSS styles
onStart?: () => void; // Callback when chat starts
onStop?: () => void; // Callback when chat stops
onError?: (error: Error) => void; // Callback on error
onMessage?: (message: ChatMessage) => void; // Callback on message
}API Methods
init(): Promise<void>
Initialize the chatbot UI and prepare for connection.
start(): Promise<void>
Start voice chat session.
stop(): Promise<void>
Stop voice chat session.
setLanguage(language: string): void
Change conversation language.
setVoice(voice: string): void
Change AI voice.
getHistory(): Conversation[]
Get conversation history.
clearHistory(): void
Clear conversation history.
Supported Languages
- English
- Tamil
- Hindi
- Telugu
- Kannada
- Malayalam
- Urdu
- Marathi
Browser Support
- Chrome/Edge (recommended)
- Firefox
- Safari (with limitations)
Requirements
- Backend API endpoint for session management
- Microphone access permission
- HTTPS (required for WebRTC)
License
MIT
Repository
https://github.com/jerrytregno/zolvit-ai-legal-assistant
