What It Demonstrates
This example shows:- ✅ Connecting to WebSocket server
- ✅ Capturing audio from microphone
- ✅ Streaming audio chunks to server
- ✅ Receiving STT transcriptions
- ✅ Receiving agent responses
- ✅ Complete client-side protocol implementation
Prerequisites
- Python 3.8 or higher
- Kuralit SDK installed:
pip install kuralit - Additional dependencies:
- A running Kuralit WebSocket server (use one of the server examples)
Step-by-Step Explanation
Step 1: Start a Server
First, start a server in another terminal:Step 2: Connect to Server
Step 3: Send Audio Start
Step 4: Stream Audio Chunks
Step 5: Receive Responses
Full Code Structure
The client includes:- Audio Capture - PyAudio for microphone input
- WebSocket Connection - Connect to server
- Audio Streaming - Send audio chunks
- Response Handling - Receive and display responses
- Protocol Implementation - Complete client-side protocol
How to Run
Step 1: Start Server
In one terminal:Step 2: Run Client
In another terminal:With Custom Server URL
Expected Output
Audio Configuration
The client uses:- Sample Rate: 16000 Hz
- Channels: Mono (1 channel)
- Format: PCM16 (16-bit)
- Chunk Size: 1024 frames
Protocol Flow
Use Cases
This client is useful for:- Testing servers - Test your AI Voice Agent servers
- Debugging - See what the server receives
- Development - Quick testing without Flutter app
- Protocol understanding - Learn the WebSocket protocol
Troubleshooting
Microphone not working
Microphone not working
- Check microphone permissions
- Verify PyAudio installation:
pip install pyaudio - Test microphone with other applications
- Check audio device settings
Connection failed
Connection failed
- Verify server is running
- Check server URL is correct
- Verify API key matches server configuration
- Check network connectivity
No audio received
No audio received
- Check server STT configuration
- Verify API keys are set correctly
- Check server logs for errors
- Ensure audio format matches (16000 Hz, PCM16)
Next Steps
- Protocol Reference → - Complete WebSocket protocol documentation
- Quickstart → - Connect your existing API to an AI Voice Agent
- Server Examples → - Test with different servers
Related
- Protocol → - WebSocket protocol reference
- Voice → - Real-time voice streaming
- Quickstart → - Connect your existing API to an AI Voice Agent

