fix error message output
Browse files
app.py
CHANGED
@@ -34,7 +34,8 @@ def synthesize_speech(text):
|
|
34 |
audio_data = np.frombuffer(buffer.read(), dtype=np.int16)
|
35 |
return audio_data.tobytes(), None
|
36 |
|
37 |
-
|
|
|
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 models from the State Library of Queensland's collection using Piper.")
|
@@ -43,7 +44,16 @@ with gr.Blocks(theme=gr.themes.Base()) as blocks:
|
|
43 |
output_text = gr.Textbox(label="Output Text", visible=True) # Make this visible for error messages
|
44 |
submit_button = gr.Button("Synthesize")
|
45 |
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
# Run the app
|
49 |
blocks.launch()
|
|
|
34 |
audio_data = np.frombuffer(buffer.read(), dtype=np.int16)
|
35 |
return audio_data.tobytes(), None
|
36 |
|
37 |
+
|
38 |
+
# Gradio Interface
|
39 |
with gr.Blocks(theme=gr.themes.Base()) as blocks:
|
40 |
gr.Markdown("# Text to Speech Synthesizer")
|
41 |
gr.Markdown("Enter text to synthesize it into speech using models from the State Library of Queensland's collection using Piper.")
|
|
|
44 |
output_text = gr.Textbox(label="Output Text", visible=True) # Make this visible for error messages
|
45 |
submit_button = gr.Button("Synthesize")
|
46 |
|
47 |
+
def process_and_output(text):
|
48 |
+
audio, message = synthesize_speech(text)
|
49 |
+
if message:
|
50 |
+
output_text.update(message)
|
51 |
+
output_audio.update(None)
|
52 |
+
else:
|
53 |
+
output_audio.update(audio)
|
54 |
+
output_text.update(None)
|
55 |
+
|
56 |
+
submit_button.click(process_and_output, inputs=input_text, outputs=[output_audio, output_text])
|
57 |
|
58 |
# Run the app
|
59 |
blocks.launch()
|