gsavin commited on
Commit
cf0b823
·
1 Parent(s): 8ac95c1

fix: music generation hangs the server

Browse files
Files changed (3) hide show
  1. src/agent/llm.py +1 -1
  2. src/audio/audio_generator.py +1 -1
  3. src/main.py +1 -2
src/agent/llm.py CHANGED
@@ -29,7 +29,7 @@ def create_llm(temperature: float = settings.temperature, top_p: float = setting
29
 
30
  _current_google_key_idx = (key_index_to_use + 1) % len(_google_api_keys_list)
31
 
32
- logger.info(f"Using Google API key at index {key_index_to_use} (ending with ...{selected_api_key[-4:] if len(selected_api_key) > 4 else selected_api_key}) for round-robin.")
33
 
34
  return ChatGoogleGenerativeAI(
35
  model="gemini-2.5-flash-preview-05-20",
 
29
 
30
  _current_google_key_idx = (key_index_to_use + 1) % len(_google_api_keys_list)
31
 
32
+ logger.debug(f"Using Google API key at index {key_index_to_use} (ending with ...{selected_api_key[-4:] if len(selected_api_key) > 4 else selected_api_key}) for round-robin.")
33
 
34
  return ChatGoogleGenerativeAI(
35
  model="gemini-2.5-flash-preview-05-20",
src/audio/audio_generator.py CHANGED
@@ -57,7 +57,7 @@ async def receive_audio(session):
57
  async for message in session.receive():
58
  if message.server_content and message.server_content.audio_chunks:
59
  audio_data = message.server_content.audio_chunks[0].data
60
- audio_queue.put(audio_data)
61
  await asyncio.sleep(10**-12)
62
  except Exception as e:
63
  logger.error(f"Error in receive_audio: {e}")
 
57
  async for message in session.receive():
58
  if message.server_content and message.server_content.audio_chunks:
59
  audio_data = message.server_content.audio_chunks[0].data
60
+ await asyncio.to_thread(audio_queue.put, audio_data)
61
  await asyncio.sleep(10**-12)
62
  except Exception as e:
63
  logger.error(f"Error in receive_audio: {e}")
src/main.py CHANGED
@@ -18,7 +18,6 @@ from game_constructor import (
18
  load_character_suggestion,
19
  start_game_with_settings,
20
  )
21
- import asyncio
22
 
23
  logger = logging.getLogger(__name__)
24
 
@@ -339,4 +338,4 @@ with gr.Blocks(
339
  outputs=[audio_out],
340
  )
341
 
342
- demo.launch()
 
18
  load_character_suggestion,
19
  start_game_with_settings,
20
  )
 
21
 
22
  logger = logging.getLogger(__name__)
23
 
 
338
  outputs=[audio_out],
339
  )
340
 
341
+ demo.launch(ssr_mode=False)