Nithish310 commited on
Commit
f63e200
·
verified ·
1 Parent(s): 8abbf0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -37
app.py CHANGED
@@ -2,17 +2,13 @@ import gradio as gr
2
  import edge_tts
3
  import asyncio
4
  import tempfile
 
5
 
6
  # Get all available voices
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
- # Expose voice list as an API
12
- def fetch_voices():
13
- voices = asyncio.run(get_voices())
14
- return list(voices.keys())
15
-
16
  # Text-to-speech function
17
  async def text_to_speech(text, voice, rate, pitch):
18
  if not text.strip():
@@ -35,46 +31,49 @@ def tts_interface(text, voice, rate, pitch):
35
  return audio, warning
36
 
37
  # Create Gradio application
38
- def create_demo():
39
- voices = asyncio.run(get_voices())
 
 
40
 
41
  description = """
42
  Convert text to speech using Microsoft Edge TTS. Adjust speech rate and pitch: 0 is default, positive values increase, negative values decrease.
43
- """
44
 
45
- demo = gr.Blocks()
46
 
47
- with demo:
48
- gr.Markdown(description)
49
-
50
- # Create voice fetching API
51
- with gr.Row():
52
- gr.Interface(
53
- fn=fetch_voices,
54
- inputs=[],
55
- outputs=[gr.JSON()],
56
- live=False,
57
- title="Get Available Voices"
58
- ).launch(share=True)
59
-
60
- gr.Interface(
61
- fn=tts_interface,
62
- inputs=[
63
- gr.Textbox(label="Input Text", lines=5),
64
- gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value=""),
65
- gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1),
66
- gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1)
67
- ],
68
- outputs=[
69
- gr.Audio(label="Generated Audio", type="filepath"),
70
- gr.Markdown(label="Warning", visible=False)
71
- ],
72
- title="Edge TTS Text-to-Speech"
73
- ).launch(share=True)
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  return demo
76
 
77
  # Run the application
78
  if __name__ == "__main__":
79
- demo = create_demo()
80
  demo.launch()
 
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():
 
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
  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=[
59
+ gr.Textbox(label="Input Text", lines=5),
60
+ gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value=""),
61
+ gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1),
62
+ gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1)
63
+ ],
64
+ outputs=[
65
+ gr.Audio(label="Generated Audio", type="filepath"),
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, and explore our advanced Text-to-Video Converter for even more creative possibilities!",
71
+ analytics_enabled=False,
72
+ allow_flagging=False
73
+ )
74
  return demo
75
 
76
  # Run the application
77
  if __name__ == "__main__":
78
+ demo = asyncio.run(create_demo())
79
  demo.launch()