Athspi commited on
Commit
8bdf1fa
·
verified ·
1 Parent(s): 43ac355

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -9
app.py CHANGED
@@ -13,12 +13,9 @@ async def generate_audio(text):
13
  response_modalities=["audio"],
14
  speech_config=types.SpeechConfig(
15
  voice_config=types.VoiceConfig(
16
- prebuilt_voice_config=types.PrebuiltVoiceConfig(
17
- voice_name="Puck"
18
- )
19
  )
20
  ),
21
- # Fixed Part.from_text() usage (positional argument)
22
  system_instruction=types.Content(
23
  parts=[types.Part.from_text("Repeat user input exactly without explanation")],
24
  role="user"
@@ -42,15 +39,12 @@ async def generate_audio(text):
42
 
43
  except Exception as e:
44
  print(f"Error: {str(e)}")
45
- raise # Re-raise to trigger Gradio's error handling
46
 
47
  def tts(text):
48
  if not text.strip():
49
  return None
50
- try:
51
- return asyncio.run(generate_audio(text))
52
- except Exception as e:
53
- return f"Error: {str(e)}" # Now Gradio will show this message instead of trying to play it
54
 
55
  iface = gr.Interface(
56
  fn=tts,
 
13
  response_modalities=["audio"],
14
  speech_config=types.SpeechConfig(
15
  voice_config=types.VoiceConfig(
16
+ prebuilt_voice_config=types.PrebuiltVoiceConfig(voice_name="Puck")
 
 
17
  )
18
  ),
 
19
  system_instruction=types.Content(
20
  parts=[types.Part.from_text("Repeat user input exactly without explanation")],
21
  role="user"
 
39
 
40
  except Exception as e:
41
  print(f"Error: {str(e)}")
42
+ raise # Let Gradio handle the error display
43
 
44
  def tts(text):
45
  if not text.strip():
46
  return None
47
+ return asyncio.run(generate_audio(text)) # Propagate exceptions
 
 
 
48
 
49
  iface = gr.Interface(
50
  fn=tts,