cool-queen-46059
12/10/2025, 12:59 PMtall-airline-16756
12/10/2025, 12:59 PMtall-airline-16756
12/10/2025, 12:59 PMcool-queen-46059
12/10/2025, 12:59 PMtall-airline-16756
12/10/2025, 12:59 PMcool-queen-46059
12/10/2025, 3:37 PMtall-airline-16756
12/10/2025, 3:37 PMlivekit, livekit-plugins-google, and google-genai.
Quick troubleshooting steps to try now:
• Before muting, list or fetch the room to confirm it exists and that your agent has joined it. Retry with short backoff if it's transient.
• Ensure you wait for the room-joined/connected event before sending room operations.
• Validate audio frames before sending to Gemini: they must be correctly formatted (no None/NaN, correct sample rate/bit depth, and proper binary vs text framing).
• Enable DEBUG logging for the plugin to capture the exact outgoing message that triggers the 1007 close.
• Update livekit and livekit-plugins-google to their latest compatible versions if not already current.
Send the requested snippets (room create/join, mute call, and Gemini send/receive code) plus package versions and I’ll pinpoint the likely offending message and a code fix.
Sources: Managing rooms | LiveKit docs | Agents telephony integration | LiveKit docs | Gemini Live API plugin | LiveKit docs | Realtime model plugins | LiveKit Docscool-queen-46059
12/10/2025, 3:40 PMtall-airline-16756
12/10/2025, 3:40 PMgoogle-genai and google-generativeai (possible incompatibility), and multiple overlapping livekit-agents extras — these can cause mixed imports or incompatible runtime behavior that produces malformed frames.
Immediate troubleshooting steps (minimal, actionable)
1. Enable debug logging for the Google plugin to capture the exact outgoing frames.
◦ logging.basicConfig(level=logging.DEBUG) and target livekit.plugins.google and google.genai logs.
1. Reproduce with a minimal test: connect the RealtimeModel and send a single small, known-good payload (e.g., a simple text event or a short validated PCM audio frame). Confirm whether minimal payloads succeed.
2. Validate audio payloads before send:
◦ Ensure 16-bit signed PCM (pcm_s16le), correct sample rate expected by the model, mono, and proper chunk sizes. Reject frames with None/NaN.
1. Inspect outgoing frames right before send:
◦ Log type, length, and a small hex/utf-8 preview. If text frames fail, ensure UTF-8 validity.
1. Simplify dependencies:
◦ Uninstall google-generativeai if not required. Keep google-genai (the package used by the plugin).
◦ Consolidate livekit-agents extras into one install to avoid duplicate extras and reinstall to remove import ambiguities.
1. Update packages to compatible versions (reinstall after cleanup) and retest.
If you want, paste:
• A small snippet that sends frames to Gemini (text or audio send path).
• One logged example of an outgoing frame (or its type/first ~100 bytes).
I’ll point to the exact offending encoding/field.
Sources: Gemini Live API plugin | LiveKit docs | An open source stack for real-time multimodal AIcool-queen-46059
12/10/2025, 4:02 PMtall-airline-16756
12/10/2025, 4:02 PMpcm_s16le) unless the model/docs specify otherwise.
◦ Use the sample rate the RealtimeModel expects (verify model—common rates are 16kHz or 24/48kHz).
◦ Send mono (1 channel) unless stereo is explicitly supported.
• Validate your audio pipeline:
◦ Ensure samples are integers (no NaN/None), correct dtype (int16), and contiguous bytes: numpy_array.astype(np.int16).tobytes().
◦ Do not send encoded formats (MP3/OPUS) as raw PCM frames.
• Check framing/packetization:
◦ Send reasonably sized chunks; avoid sending huge blobs or splitting frames incorrectly.
◦ Ensure you send binary WS frames when sending audio (not text frames).
• Log outgoing payloads right before send:
◦ Log type, length, and a small hex/UTF-8 preview (first ~64 bytes) to spot corruption or wrong framing.
• Reproduce with a minimal valid frame:
◦ Generate a short 1s sine wave converted to int16 PCM and send it; if that works, your capture/encoding is the problem.
• Dependency sanity:
◦ Keep the Google GenAI client your plugin expects (google-genai), remove conflicting google-generativeai if present, and ensure livekit-plugins-google is compatible with installed genai version.
• Retry behavior:
◦ If you detect an invalid frame, drop it and continue rather than repeatedly sending corrupt data.
If you want, paste a small snippet that encodes/sends the audio frame (the code that creates the bytes and calls send). I’ll point out exactly what to change or validate.cool-queen-46059
12/10/2025, 4:03 PMtall-airline-16756
12/10/2025, 4:04 PMpcm_s16le) and the sample rate/channels expected by the RealtimeModel.
• Ensure frames contain valid int16 samples (no NaN/None) and are properly chunked.
• Log outgoing frames (type, length, first bytes) to find malformed sends.
• Remove conflicting Google packages (google-generativeai) if it interferes with the plugin's google-genai usage.
If you want, paste one logged outgoing frame (type + first ~64 bytes or hex preview) and the small send/encode snippet — I’ll point out exactly what looks malformed.
Sources: Server-side | livekit/livekit_composite | DeepWiki | Track egress | LiveKit docs | Vision | LiveKit Docscool-queen-46059
12/10/2025, 7:01 PMtall-airline-16756
12/10/2025, 7:01 PMpcm_s16le) and the sample rate/channels your RealtimeModel expects.
◦ Convert arrays with: pcm_bytes = numpy_array.astype(np.int16).tobytes().
1. Inspect the exact frame that triggers the close
◦ Add logging immediately before sending: type, len, and first 64 bytes hex preview.
◦ Example log: logger.debug("send: %s bytes %d preview=%s", type(data), len(data), data[:64].hex())
1. Check for mixed/duplicate packages causing runtime conflict
◦ Having both google-genai and google-generativeai can cause unexpected behavior. Uninstall google-generativeai unless you explicitly need it.
◦ Consolidate livekit-agents extras to a single install to avoid overlapping installs.
1. Reproduce with a minimal valid frame
◦ Send a short generated 1s int16 sine wave as a test payload. If that works, the issue is your recorded/intro audio encoding or clips injected mid-stream.
1. Playback timing/race
◦ If you switch from playback to capture or splice streams, ensure you don’t accidentally send a zero-length frame, None, or metadata in place of binary audio during the transition.
If you want me to pinpoint it, paste:
• The small send/encode snippet used when playing the intro and during playback (how you build/send bytes).
• One logged send preview (type, len, first ~64 bytes hex) captured right before the socket close.
I’ll examine that and show exactly what is malformed.cool-queen-46059
12/10/2025, 7:15 PMtall-airline-16756
12/10/2025, 7:16 PMgoogle-genai and LiveKit’s noise‑cancellation plugin that would inherently produce WebSocket 1007 — but noise processing can indirectly cause malformed audio frames, so it’s worth testing.
What to try (quick):
• Disable noise cancellation and retest playback. If the 1007 stops, the processing pipeline is likely corrupting frames or changing format.
• Confirm noise-cancellation output is still raw 16-bit PCM int16 bytes, correct sample rate, and mono before sending to Gemini.
• Log a failing frame (type, length, first ~64 bytes hex) right before send with and without noise cancellation to compare.
• As a control, send a known-good synthetic 1s int16 sine wave during playback; if that never triggers 1007, your real audio or processing is at fault.
If you want, paste the small encode/process/send snippet (where noise cancellation runs) and one logged failing-frame preview and I’ll point out what to change.
Sources: Google Gemini LLM plugin guide | LiveKit Docs | Enhanced noise cancellation | LiveKit docs