sarvam-convai-embed
v1.0.19
Published
This is a React application for testing the Sarvam Conversational AI SDK locally.
Readme
Sarvam SDK React Test App
This is a React application for testing the Sarvam Conversational AI SDK locally.
Prerequisites
Make sure you have built the SDK first:
cd .. npm install npm run buildInstall dependencies for the React app:
cd react-test-app npm install
Running the App
Start the development server:
npm run devOpen your browser to
http://localhost:3000Enter your Sarvam credentials:
- API Key
- App ID
- Org ID
- Workspace ID
- User ID (optional)
Click "Start Testing" to begin a voice conversation
Features
- Voice Chat Interface: Test voice-to-voice conversations using the browser's microphone and speakers
- Real-time Transcript: See the agent's responses in real-time
- Connection Status: Monitor connection status and interaction ID
- Error Handling: Clear error messages if something goes wrong
How It Works
This app uses:
- Vite for fast development and building
- React for the UI
- Web Audio API for browser-based audio input/output
- Local SDK: References the SDK from
../srcusing Vite's alias configuration
Browser Compatibility
- Requires a modern browser with Web Audio API support
- Chrome, Firefox, Safari, and Edge are supported
- Microphone permissions will be requested when starting a conversation
CORS Configuration
The app is configured to use a Vite proxy to avoid CORS issues. All API requests are automatically proxied through the dev server at /api/app-runtime to https://apps.sarvam.ai/api/app-runtime. This means:
- HTTP requests go through the proxy (no CORS issues)
- WebSocket connections use the signed URL from the API directly (should work without CORS)
If you still encounter CORS errors:
- Make sure you're running the dev server (
npm run dev) - Check that the proxy is configured correctly in
vite.config.ts - Verify your API credentials are correct
Troubleshooting
- SDK not found: Make sure you've built the SDK (
npm run buildin the root directory) - WebSocket errors: Check that your API key and credentials are correct
- Audio not working: Make sure your browser has microphone permissions enabled
- Build errors: Ensure all dependencies are installed (
npm install) - CORS errors: See the CORS Configuration section above. The app uses a proxy to avoid CORS issues automatically.
