Styner1 commited on
Commit
043490a
·
verified ·
1 Parent(s): a4d5583

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -1,7 +1,8 @@
1
  import gradio as gr
2
  import os
3
  import traceback
4
- from Zonos_main.tts import ZonosTTS # Adjust import path as needed
 
5
 
6
  # Initialize TTS with error handling
7
  try:
@@ -21,8 +22,12 @@ def generate_audio(text):
21
 
22
  if not os.path.exists(output_path):
23
  raise FileNotFoundError("Audio file was not generated")
 
 
 
 
 
24
 
25
- return output_path
26
  except Exception as e:
27
  traceback.print_exc()
28
  raise gr.Error(f"Audio generation failed: {str(e)}")
 
1
  import gradio as gr
2
  import os
3
  import traceback
4
+ import base64 # Add this
5
+ from Zonos_main.tts import ZonosTTS
6
 
7
  # Initialize TTS with error handling
8
  try:
 
22
 
23
  if not os.path.exists(output_path):
24
  raise FileNotFoundError("Audio file was not generated")
25
+
26
+ # Return audio as base64 string
27
+ with open(output_path, "rb") as audio_file:
28
+ audio_base64 = base64.b64encode(audio_file.read()).decode('utf-8')
29
+ return f"data:audio/wav;base64,{audio_base64}"
30
 
 
31
  except Exception as e:
32
  traceback.print_exc()
33
  raise gr.Error(f"Audio generation failed: {str(e)}")