Vapi WebSocket local usage – echo loop or mic not ...
# support
m
I’m trying to use Vapi with my own local code via WebSocket using my API key. But I’m running into an issue: When I send audio from my microphone, it either goes into an echo loop (keeps repeating itself) or it doesn’t detect my voice at all. I can’t figure out how to stabilize it — it’s either constantly re-listening to its own output or ignoring my mic input. Has anyone else faced this problem before? How did you solve it? Any tips on preventing the echo loop or making sure mic input is captured correctly would be super helpful. 🙏
v
Thank you for sharing the details. To help pinpoint the issue, could you clarify: Are you playing back the assistant's audio through speakers (which might be picked up by your mic), or are you using headphones during your tests? This will help determine if the echo loop is due to audio feedback or a configuration issue. Source: - [Vapi WebSocket Transport Documentation](https://docs.vapi.ai/calls/websocket-transport)
c
Hi mzeydkurt, To address your issue with the WebSocket local usage, there are a few areas you could check to ensure proper function: 1. **WebSocket Connection**: Ensure you have successfully established a WebSocket connection using the correct URL and that the connection is open before sending audio data. 2. **Microphone Access**: Verify that your application has permission to access the microphone. You can check this in your browser settings or on your device. 3. **Audio Data Stream**: Confirm that you are correctly capturing and encoding the audio data into the PCM format as per the [WebSocket Transport documentation](https://docs.vapi.ai/calls/websocket-transport). The audio should be streamed in
pcm_s16le
format with a sample rate of 16kHz. 4. **Echo Issues**: If there is an echo, consider using headphones or verifying that your audio context's source and processor are correctly configured to avoid feedback loops. Review these steps to troubleshoot the connection and audio streaming. If the issue persists, it might be helpful to check the code for handling WebSocket events such as
onaudioprocess
or errors.
2 Views