raphaelmerx commited on
Commit
87bb320
·
1 Parent(s): a2d405c

update app.py for gradio 6 compat

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -31,11 +31,13 @@ def synthesize_speech(text):
31
  buffer.seek(0)
32
  audio_data = np.frombuffer(buffer.read(), dtype=np.int16)
33
 
34
- return audio_data.tobytes(), None
 
35
 
36
 
37
  # Using Gradio Blocks
38
- with gr.Blocks(theme=gr.themes.Base()) as blocks:
 
39
  gr.Markdown("# Text to Speech Synthesizer")
40
  gr.Markdown("Enter text to synthesize it into speech using PiperVoice.")
41
  input_text = gr.Textbox(label="Input Text")
@@ -50,4 +52,4 @@ with gr.Blocks(theme=gr.themes.Base()) as blocks:
50
  )
51
 
52
  # Run the app
53
- blocks.launch()
 
31
  buffer.seek(0)
32
  audio_data = np.frombuffer(buffer.read(), dtype=np.int16)
33
 
34
+ # In Gradio 6, Audio with type="numpy" expects a tuple of (sample_rate, audio_array)
35
+ return (voice.config.sample_rate, audio_data), None
36
 
37
 
38
  # Using Gradio Blocks
39
+ # In Gradio 6, theme moved from Blocks() constructor to launch()
40
+ with gr.Blocks() as blocks:
41
  gr.Markdown("# Text to Speech Synthesizer")
42
  gr.Markdown("Enter text to synthesize it into speech using PiperVoice.")
43
  input_text = gr.Textbox(label="Input Text")
 
52
  )
53
 
54
  # Run the app
55
+ blocks.launch(theme="base")