Hi
is anyone know the actual quota limit of gemini-2.0-flash-live-001
My code is like this:
import asyncio
import os.path
from google import genai
from google.genai import types
import wave
from pydub import AudioSegment
import websockets.exceptions # 导入 websockets.exceptions
# Constants
MODEL_NAME = 'gemini-2.0-flash-live-001'
AUDIO_FOLDERNAME = "AUDIO"
def wave_file(filename, pcm, channels=1, rate=24000, sample_width=2):
with wave.open(filename, "wb") as wf:
wf.setnchannels(channels)
wf.setsampwidth(sample_width)
wf.setframerate(rate)
wf.writeframes(pcm)
client = genai.Client()
model = "gemini-2.0-flash-live-001"
config = types.LiveConnectConfig(
response_modalities=["AUDIO"],
output_audio_transcription=types.AudioTranscriptionConfig(),
system_instruction=types.Content(
parts=[types.Part(text="you are a helpful assistant.")]
),
speech_config=types.SpeechConfig(
voice_config=types.VoiceConfig(
prebuilt_voice_config=types.PrebuiltVoiceConfig(voice_name="Kore")
),
language_code='en-US',
),)
async def main():
n = 0
while True:
try:
n += 1
async with client.aio.live.connect(model=model, config=config) as session:
wave_file_name = "auduio_"+str(n)+".wav"
path = os.path.join(AUDIO_FOLDERNAME, wave_file_name)
message = "Hi, Do you know Elon Musk? give me 100+ words about him"
await session.send_client_content(
turns={"role": "user", "parts": [{"text": message}]}, turn_complete=True
)
audio_data = []
async for response in session.receive():
if response.data is not None:
audio_data.append(response.data)
if response.server_content.output_transcription:
transcription_text = response.server_content.output_transcription.text
print(transcription_text,end="")
if response.server_content.generation_complete:
print("Generation Complete detected......")
break
audio_data = b"".join(audio_data)
audio_segment = AudioSegment(
data=audio_data,
sample_width=2,
frame_rate=24000,
channels=1)
os.makedirs(AUDIO_FOLDERNAME, exist_ok=True)
audio_segment.export(path, format="wav")
await session.close()
async for response in session.receive():
if response.data is not None:
print(response.data)
except websockets.exceptions.ConnectionClosedOK as e:
print(f"WebSocket connection closed successfully: {e}")
if __name__ == "__main__":
asyncio.run(main())
to save time, I set a break after generation_complete, instead of turn_complete.
but this will cause exceeding quota limit:
websockets.exceptions.ConnectionClosedError: received 1011 (internal error) You exceeded your current quota, please check your plan and billing details. For more information on this error, head to: h;
I check the rate limits, there is no possiablity to exceed.
I know live API is used for chatting. Saving files is not recommended, but what i want is saving the audio and listening again and again.
Thanks for your support.