Voice Features
• Real-time voice-to-text transcription via WebSocket
• Auto-stop on silence: configurable pause duration & threshold
• Typing indicator: shows while server processes audio
• User transcript placeholder: appears instantly on recording stop
• Customizable processing UI: text config or full postprocessMessage override via voiceProcessing flag
• Text-to-speech via browser voices, Runtype hosted voices, or OpenAI through the demo proxy
• WebSocket-based bidirectional communication
• Automatic fallback to browser speech API when WebSocket unavailable
Configuration
const config = {
voiceRecognition: {
enabled: true,
processingText: 'Transcribing...',
processingErrorText: 'Failed',
provider: {
type: 'runtype',
runtype: {
agentId: 'your-agent-id',
clientToken: 'your-token',
host: 'api.runtype.com',
pauseDuration: 2000,
silenceThreshold: 0.01
}
}
},
textToSpeech: {
enabled: false,
provider: 'browser',
createEngine: () => new ServerTtsEngine({ endpoint: '/api/tts' })
},
messageActions: {
showReadAloud: true
},
processingIconName: 'loader',
processingBackgroundColor: '#6366f1',
processingIconColor: '#ffffff',
speakingIconName: 'volume-2',
speakingBackgroundColor: '#3b82f6',
speakingIconColor: '#ffffff',
postprocessMessage: ({ text, message }) => {
if (message.voiceProcessing) {
return '<div>Custom UI</div>';
}
return text;
}
};