Add voice capabilities to your Cedar OS application
voiceSettings
prop accepts a partial configuration object with the following TypeScript interface:
Setting | Type | Default | Description |
---|---|---|---|
language | string | 'en-US' | Language code for speech recognition/synthesis |
voiceId | string | undefined | Voice identifier (provider-specific) |
pitch | number | 1.0 | Voice pitch modulation (0.5-2.0) |
rate | number | 1.0 | Speech rate (0.5-2.0) |
volume | number | 1.0 | Audio volume (0.0-1.0) |
useBrowserTTS | boolean | false | Use browser’s built-in TTS |
autoAddToMessages | boolean | true | Add voice interactions to chat |
endpoint | string | undefined | Custom voice endpoint URL |
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.
cedar-os
package:
voiceRoute
in your Mastra configuration, Cedar-OS automatically sets the voice endpoint to baseURL + voiceRoute
.
checkVoiceSupport()
- Check if browser supports voice featuresrequestVoicePermission()
- Request microphone accessstartListening()
- Start recording audiostopListening()
- Stop recording and send to endpointtoggleVoice()
- Toggle between listening and idle statesstreamAudioToEndpoint(audioData)
- Send audio to backendplayAudioResponse(audioUrl)
- Play audio responsesetVoiceEndpoint(endpoint)
- Set the backend endpoint URLupdateVoiceSettings(settings)
- Update voice configurationsetVoiceError(error)
- Set error messageresetVoiceState()
- Clean up and reset all voice statenavigator.mediaDevices.getUserMedia
- Audio captureMediaRecorder
API - Audio recordingAudioContext
API - Audio processing