Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ async def _text_to_speech(text, short_name, rate_str, pitch_str):
|
|
21 |
await comm.save(tmp.name)
|
22 |
return tmp.name
|
23 |
|
24 |
-
# 3)
|
25 |
def tts_interface(text, voice_choice, rate, pitch):
|
26 |
if not text.strip():
|
27 |
return None, "🚨 Please enter some text."
|
@@ -38,13 +38,13 @@ def tts_interface(text, voice_choice, rate, pitch):
|
|
38 |
except Exception as e:
|
39 |
return None, f"❌ TTS failed: {e}"
|
40 |
|
41 |
-
# 4) Build
|
42 |
def create_demo():
|
43 |
with gr.Blocks(analytics_enabled=False) as demo:
|
44 |
gr.Markdown("# 🎙️ Edge TTS on Hugging Face Spaces")
|
45 |
|
46 |
gr.Markdown(
|
47 |
-
"**Convert your text to speech** using Microsoft Edge
|
48 |
"Adjust rate and pitch to fine-tune the output."
|
49 |
)
|
50 |
|
@@ -58,19 +58,18 @@ def create_demo():
|
|
58 |
audio_out = gr.Audio(type="filepath", label="Audio Output")
|
59 |
warn_md = gr.Markdown("", label="Warnings / Errors")
|
60 |
|
61 |
-
# Wire the callback and register the /api endpoints
|
62 |
btn.click(
|
63 |
fn=tts_interface,
|
64 |
inputs=[txt, vox, rate, pitch],
|
65 |
outputs=[audio_out, warn_md]
|
66 |
)
|
67 |
|
68 |
-
# Enable
|
69 |
demo.queue()
|
70 |
|
71 |
return demo
|
72 |
|
73 |
-
# 5) Launch
|
74 |
if __name__ == "__main__":
|
75 |
demo = create_demo()
|
76 |
-
demo.launch()
|
|
|
21 |
await comm.save(tmp.name)
|
22 |
return tmp.name
|
23 |
|
24 |
+
# 3) Sync wrapper for Gradio callback
|
25 |
def tts_interface(text, voice_choice, rate, pitch):
|
26 |
if not text.strip():
|
27 |
return None, "🚨 Please enter some text."
|
|
|
38 |
except Exception as e:
|
39 |
return None, f"❌ TTS failed: {e}"
|
40 |
|
41 |
+
# 4) Build the UI
|
42 |
def create_demo():
|
43 |
with gr.Blocks(analytics_enabled=False) as demo:
|
44 |
gr.Markdown("# 🎙️ Edge TTS on Hugging Face Spaces")
|
45 |
|
46 |
gr.Markdown(
|
47 |
+
"**Convert your text to speech** using Microsoft Edge’s neural voices. "
|
48 |
"Adjust rate and pitch to fine-tune the output."
|
49 |
)
|
50 |
|
|
|
58 |
audio_out = gr.Audio(type="filepath", label="Audio Output")
|
59 |
warn_md = gr.Markdown("", label="Warnings / Errors")
|
60 |
|
|
|
61 |
btn.click(
|
62 |
fn=tts_interface,
|
63 |
inputs=[txt, vox, rate, pitch],
|
64 |
outputs=[audio_out, warn_md]
|
65 |
)
|
66 |
|
67 |
+
# Enable the queue so the API actually gets registered
|
68 |
demo.queue()
|
69 |
|
70 |
return demo
|
71 |
|
72 |
+
# 5) Launch with SSR disabled
|
73 |
if __name__ == "__main__":
|
74 |
demo = create_demo()
|
75 |
+
demo.launch(ssr=False)
|