Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,14 +5,14 @@ import tempfile
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
async def get_voices():
|
| 8 |
-
voices = await 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):
|
| 12 |
if not text.strip():
|
| 13 |
-
return None, "
|
| 14 |
if not voice:
|
| 15 |
-
return None, "
|
| 16 |
|
| 17 |
voice_short_name = voice.split(" - ")[0]
|
| 18 |
rate_str = f"{rate:+d}%"
|
|
@@ -31,28 +31,41 @@ async def tts_interface(text, voice, rate, pitch):
|
|
| 31 |
|
| 32 |
async def create_demo():
|
| 33 |
voices = await get_voices()
|
| 34 |
-
|
| 35 |
description = """
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
"""
|
| 38 |
|
| 39 |
demo = gr.Interface(
|
| 40 |
fn=tts_interface,
|
| 41 |
inputs=[
|
| 42 |
-
gr.Textbox(label="Text", lines=5),
|
| 43 |
-
gr.Dropdown(choices=[""] + list(voices.keys()), label="
|
| 44 |
-
|
| 45 |
-
|
| 46 |
],
|
| 47 |
outputs=[
|
| 48 |
gr.Audio(label="Generated Audio", type="filepath"),
|
| 49 |
gr.Markdown(label="Warning", visible=False)
|
| 50 |
],
|
| 51 |
-
title="Text-
|
| 52 |
description=description,
|
| 53 |
-
article="",
|
| 54 |
analytics_enabled=False,
|
| 55 |
-
|
| 56 |
api_name=None
|
| 57 |
)
|
| 58 |
return demo
|
|
@@ -63,4 +76,4 @@ async def main():
|
|
| 63 |
demo.launch(show_api=False)
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|
| 66 |
-
asyncio.run(main())
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
async def get_voices():
|
| 8 |
+
voices = await 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):
|
| 12 |
if not text.strip():
|
| 13 |
+
return None, "Please enter text to convert."
|
| 14 |
if not voice:
|
| 15 |
+
return None, "Please select a voice."
|
| 16 |
|
| 17 |
voice_short_name = voice.split(" - ")[0]
|
| 18 |
rate_str = f"{rate:+d}%"
|
|
|
|
| 31 |
|
| 32 |
async def create_demo():
|
| 33 |
voices = await get_voices()
|
| 34 |
+
|
| 35 |
description = """
|
| 36 |
+
Convert text to speech using Microsoft Edge TTS. Adjust speech rate and pitch: 0 is default, positive values increase, negative values decrease.
|
| 37 |
+
|
| 38 |
+
🎥 **Exciting News: Introducing our Text-to-Video Converter!** 🎥
|
| 39 |
+
|
| 40 |
+
Take your content creation to the next level with our cutting-edge Text-to-Video Converter!
|
| 41 |
+
Transform your words into stunning, professional-quality videos in just a few clicks.
|
| 42 |
+
|
| 43 |
+
✨ Features:
|
| 44 |
+
• Convert text to engaging videos with customizable visuals
|
| 45 |
+
• Choose from 40+ languages and 300+ voices
|
| 46 |
+
• Perfect for creating audiobooks, storytelling, and language learning materials
|
| 47 |
+
• Ideal for educators, content creators, and language enthusiasts
|
| 48 |
+
|
| 49 |
+
Ready to revolutionize your content? [Click here to try our Text-to-Video Converter now!](https://text2video.wingetgui.com/)
|
| 50 |
"""
|
| 51 |
|
| 52 |
demo = gr.Interface(
|
| 53 |
fn=tts_interface,
|
| 54 |
inputs=[
|
| 55 |
+
gr.Textbox(label="Input Text", lines=5),
|
| 56 |
+
gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value=""),
|
| 57 |
+
gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1),
|
| 58 |
+
gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1)
|
| 59 |
],
|
| 60 |
outputs=[
|
| 61 |
gr.Audio(label="Generated Audio", type="filepath"),
|
| 62 |
gr.Markdown(label="Warning", visible=False)
|
| 63 |
],
|
| 64 |
+
title="Edge TTS Text-to-Speech",
|
| 65 |
description=description,
|
| 66 |
+
article="Experience the power of Edge TTS for text-to-speech conversion, and explore our advanced Text-to-Video Converter for even more creative possibilities!",
|
| 67 |
analytics_enabled=False,
|
| 68 |
+
allow_flagging="manual",
|
| 69 |
api_name=None
|
| 70 |
)
|
| 71 |
return demo
|
|
|
|
| 76 |
demo.launch(show_api=False)
|
| 77 |
|
| 78 |
if __name__ == "__main__":
|
| 79 |
+
asyncio.run(main())
|