cookbook icon indicating copy to clipboard operation
cookbook copied to clipboard

Streaming in speech generation is not working

Open plchld opened this issue 7 months ago • 2 comments

Description of the bug:

from google import genai from google.genai import types import pyaudio # You'll need to install PyAudio

client = genai.Client(api_key="GEMINI_API_KEY")

... response code

stream = pya.open( format=FORMAT, channels=CHANNELS, rate=RECEIVE_SAMPLE_RATE, output=True)

def play_audio(chunks): chunk: Blob for chunk in chunks: stream.write(chunk.data)


The example of getting streaming data is not complete, the standard response code is sending the whole file.

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

plchld avatar May 22 '25 13:05 plchld

Also facing the same issue, any plan to add support for streaming for gemini-2.5-flash-preview-tts and gemini-2.5-pro-preview-tts?

AyrennC avatar Jun 13 '25 02:06 AyrennC

The documentation has a streaming support section, but generate_content_stream returns only one chunk which contains the complete response.

Please add streaming support!

taelid avatar Jun 17 '25 06:06 taelid