Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,8 @@ import asyncio
|
|
| 4 |
import tempfile
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
|
| 8 |
-
voices =
|
| 9 |
return {f"{v['ShortName']} - {v['Locale']} ({v['Gender']})": v['ShortName'] for v in voices}
|
| 10 |
|
| 11 |
async def text_to_speech(text, voice, rate, pitch):
|
|
@@ -32,8 +32,8 @@ async def tts_interface(text, voice, rate, pitch):
|
|
| 32 |
return audio, gr.Warning(warning)
|
| 33 |
return audio, None
|
| 34 |
|
| 35 |
-
|
| 36 |
-
voices =
|
| 37 |
|
| 38 |
with gr.Blocks(analytics_enabled=False) as demo:
|
| 39 |
gr.Markdown("# 🎙️ Edge TTS Text-to-Speech")
|
|
@@ -117,12 +117,17 @@ async def create_demo():
|
|
| 117 |
fn=tts_interface,
|
| 118 |
inputs=[text_input, voice_dropdown, rate_slider, pitch_slider],
|
| 119 |
outputs=[audio_output, warning_md],
|
| 120 |
-
api_name="
|
| 121 |
)
|
| 122 |
|
| 123 |
gr.Markdown("Experience the power of Edge TTS for text-to-speech conversion, and explore our advanced Text-to-Video Converter for even more creative possibilities!")
|
| 124 |
|
| 125 |
return demo
|
| 126 |
|
| 127 |
-
|
| 128 |
-
demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import tempfile
|
| 5 |
import os
|
| 6 |
|
| 7 |
+
def get_voices():
|
| 8 |
+
voices = asyncio.run(edge_tts.list_voices())
|
| 9 |
return {f"{v['ShortName']} - {v['Locale']} ({v['Gender']})": v['ShortName'] for v in voices}
|
| 10 |
|
| 11 |
async def text_to_speech(text, voice, rate, pitch):
|
|
|
|
| 32 |
return audio, gr.Warning(warning)
|
| 33 |
return audio, None
|
| 34 |
|
| 35 |
+
def create_demo():
|
| 36 |
+
voices = get_voices()
|
| 37 |
|
| 38 |
with gr.Blocks(analytics_enabled=False) as demo:
|
| 39 |
gr.Markdown("# 🎙️ Edge TTS Text-to-Speech")
|
|
|
|
| 117 |
fn=tts_interface,
|
| 118 |
inputs=[text_input, voice_dropdown, rate_slider, pitch_slider],
|
| 119 |
outputs=[audio_output, warning_md],
|
| 120 |
+
api_name="text_to_speech"
|
| 121 |
)
|
| 122 |
|
| 123 |
gr.Markdown("Experience the power of Edge TTS for text-to-speech conversion, and explore our advanced Text-to-Video Converter for even more creative possibilities!")
|
| 124 |
|
| 125 |
return demo
|
| 126 |
|
| 127 |
+
def main():
|
| 128 |
+
demo = create_demo()
|
| 129 |
+
demo.queue(default_concurrency_limit=50)
|
| 130 |
+
demo.launch(show_api=True)
|
| 131 |
+
|
| 132 |
+
if __name__ == "__main__":
|
| 133 |
+
main()
|