Update app.py
Browse files
app.py
CHANGED
@@ -12,10 +12,9 @@ async def get_voices():
|
|
12 |
# Text-to-speech function
|
13 |
async def text_to_speech(text, voice, rate, pitch):
|
14 |
if not text.strip():
|
15 |
-
return None,
|
16 |
if not voice:
|
17 |
-
return None,
|
18 |
-
|
19 |
voice_short_name = voice.split(" - ")[0]
|
20 |
rate_str = f"{rate:+d}%"
|
21 |
pitch_str = f"{pitch:+d}Hz"
|
@@ -25,34 +24,12 @@ async def text_to_speech(text, voice, rate, pitch):
|
|
25 |
await communicate.save(tmp_path)
|
26 |
return tmp_path, None
|
27 |
|
28 |
-
# Gradio interface function
|
29 |
def tts_interface(text, voice, rate, pitch):
|
30 |
audio, warning = asyncio.run(text_to_speech(text, voice, rate, pitch))
|
31 |
return audio, warning
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
async def create_demo():
|
37 |
-
voices = await get_voices()
|
38 |
-
|
39 |
-
description = """
|
40 |
-
Convert text to speech using Microsoft Edge TTS. Adjust speech rate and pitch: 0 is default, positive values increase, negative values decrease.
|
41 |
-
|
42 |
-
🎥 **Exciting News: Introducing our Text-to-Video Converter!** 🎥
|
43 |
-
|
44 |
-
Take your content creation to the next level with our cutting-edge Text-to-Video Converter!
|
45 |
-
Transform your words into stunning, professional-quality videos in just a few clicks.
|
46 |
-
|
47 |
-
✨ Features:
|
48 |
-
• Convert text to engaging videos with customizable visuals
|
49 |
-
• Choose from 40+ languages and 300+ voices
|
50 |
-
• Perfect for creating audiobooks, storytelling, and language learning materials
|
51 |
-
• Ideal for educators, content creators, and language enthusiasts
|
52 |
-
|
53 |
-
Ready to revolutionize your content? [Click here to try our Text-to-Video Converter now!](https://text2video.wingetgui.com/)
|
54 |
-
"""
|
55 |
-
|
56 |
demo = gr.Interface(
|
57 |
fn=tts_interface,
|
58 |
inputs=[
|
@@ -63,17 +40,12 @@ async def create_demo():
|
|
63 |
],
|
64 |
outputs=[
|
65 |
gr.Audio(label="Generated Audio", type="filepath"),
|
66 |
-
gr.
|
67 |
],
|
68 |
-
title="
|
69 |
-
description=
|
70 |
-
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!",
|
71 |
analytics_enabled=False,
|
72 |
allow_flagging="manual"
|
73 |
)
|
74 |
-
return demo
|
75 |
-
|
76 |
-
# Run the application
|
77 |
-
if __name__ == "__main__":
|
78 |
-
demo = asyncio.run(create_demo())
|
79 |
demo.launch()
|
|
|
|
12 |
# Text-to-speech function
|
13 |
async def text_to_speech(text, voice, rate, pitch):
|
14 |
if not text.strip():
|
15 |
+
return None, "Please enter text to convert."
|
16 |
if not voice:
|
17 |
+
return None, "Please select a voice."
|
|
|
18 |
voice_short_name = voice.split(" - ")[0]
|
19 |
rate_str = f"{rate:+d}%"
|
20 |
pitch_str = f"{pitch:+d}Hz"
|
|
|
24 |
await communicate.save(tmp_path)
|
25 |
return tmp_path, None
|
26 |
|
|
|
27 |
def tts_interface(text, voice, rate, pitch):
|
28 |
audio, warning = asyncio.run(text_to_speech(text, voice, rate, pitch))
|
29 |
return audio, warning
|
30 |
|
31 |
+
if __name__ == "__main__":
|
32 |
+
voices = asyncio.run(get_voices())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
demo = gr.Interface(
|
34 |
fn=tts_interface,
|
35 |
inputs=[
|
|
|
40 |
],
|
41 |
outputs=[
|
42 |
gr.Audio(label="Generated Audio", type="filepath"),
|
43 |
+
gr.Textbox(label="Warning", visible=False)
|
44 |
],
|
45 |
+
title="ᴛᴀʟᴋᗷo᙭",
|
46 |
+
description="📟",
|
|
|
47 |
analytics_enabled=False,
|
48 |
allow_flagging="manual"
|
49 |
)
|
|
|
|
|
|
|
|
|
|
|
50 |
demo.launch()
|
51 |
+
|