Skip to content

[Bug] Real-time Audio Streaming Accumulates Significant Latency & Scrambles Audio on Longer Inputs (Mac/Python) #1859

Description

@AthemiS13

Description:

I am experiencing severe latency accumulation and "scrambled" audio transcripts when streaming audio to the google.genai V1 Beta API (gemini-2.0-flash-exp) over a persistent WebSocket connection.

Symptoms:

Latency Accumulation: On short utterances (<5s), response is fast. On longer utterances (20s+), the system does not seem to keep up with the real-time audio stream. At some point the system lags completely, I do not get transcript anymore and i have to wait around two minutes for Gemini to start responding again. Untill that the api is completely unresponsive and laggy.
Audio Scrambling/Garbage Transcripts: When this lag occurs, the server-side transcript eventually degrades into nonsense or scrambled text, suggesting that audio frames are being dropped or processed out of order due to the backlog.

Environment:

OS: macOS
Python: 3.9
SDK Version: google-genai (latest)
Model: gemini-2.0-flash-exp
Code Pattern: I am using a standard PyAudio producer / API consumer loop with asyncio.

Chunk Size: Tried 1024 (also tried 4096, same result).
Rate: 16kHz
Format: Int16 PCM
Method: session.send_realtime_input

Steps to Reproduce:

Open a client.aio.live.connect session.
Stream audio continuously from a microphone using send_realtime_input.
Speak continuously for 30-40 seconds.
Observe that the intermediate transcripts start lagging behind the spoken words, eventually becoming scrambled, and the model takes a long time to respond after silence.
Expected Behavior: The API should handle real-time 16kHz PCM streams without accumulating seconds of latency, or at least drop frames gracefully without corrupting the transcription stream.

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions