Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,58 +1,9 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import edge_tts
|
3 |
-
import asyncio
|
4 |
-
import tempfile
|
5 |
-
import os
|
6 |
-
|
7 |
-
# Get all available voices
|
8 |
-
async def get_voices():
|
9 |
-
voices = await edge_tts.list_voices()
|
10 |
-
return {f"{v['ShortName']} - {v['Locale']} ({v['Gender']})": v['ShortName'] for v in voices}
|
11 |
-
|
12 |
-
# Text-to-speech function
|
13 |
-
async def text_to_speech(text, voice, rate, pitch):
|
14 |
-
if not text.strip():
|
15 |
-
return None, gr.Warning("Please enter text to convert.")
|
16 |
-
if not voice:
|
17 |
-
return None, gr.Warning("Please select a voice.")
|
18 |
-
|
19 |
-
voice_short_name = voice.split(" - ")[0]
|
20 |
-
rate_str = f"{rate:+d}%"
|
21 |
-
pitch_str = f"{pitch:+d}Hz"
|
22 |
-
communicate = edge_tts.Communicate(text, voice_short_name, rate=rate_str, pitch=pitch_str)
|
23 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
24 |
-
tmp_path = tmp_file.name
|
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 |
-
# Create Gradio application
|
34 |
-
import gradio as gr
|
35 |
-
|
36 |
async def create_demo():
|
37 |
voices = await get_voices()
|
38 |
|
39 |
-
description
|
40 |
-
|
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=[
|
@@ -66,14 +17,9 @@ async def create_demo():
|
|
66 |
gr.Markdown(label="Warning", visible=False)
|
67 |
],
|
68 |
title="Edge TTS Text-to-Speech",
|
69 |
-
description=description,
|
70 |
-
article="Experience the power of Edge TTS for text-to-speech conversion
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
async def create_demo():
|
2 |
voices = await get_voices()
|
3 |
|
4 |
+
# Remove the description or replace it with a custom message
|
5 |
+
description = "" # Set to an empty string if you don't want any description
|
6 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
demo = gr.Interface(
|
8 |
fn=tts_interface,
|
9 |
inputs=[
|
|
|
17 |
gr.Markdown(label="Warning", visible=False)
|
18 |
],
|
19 |
title="Edge TTS Text-to-Speech",
|
20 |
+
description=description, # Updated to remove unwanted content
|
21 |
+
article="Experience the power of Edge TTS for text-to-speech conversion!",
|
22 |
analytics_enabled=False,
|
23 |
allow_flagging="manual"
|
24 |
)
|
25 |
return demo
|
|
|
|
|
|
|
|
|
|