Spaces:
Runtime error
Runtime error
keshav6936
commited on
Commit
•
4c46f82
1
Parent(s):
33959c0
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
-
import spaces
|
2 |
import gradio as gr
|
3 |
import edge_tts
|
4 |
import asyncio
|
5 |
import tempfile
|
6 |
-
import os
|
7 |
|
8 |
# Get all available voices
|
9 |
async def get_voices():
|
@@ -13,9 +11,9 @@ async def get_voices():
|
|
13 |
# Text-to-speech function
|
14 |
async def text_to_speech(text, voice, rate, pitch):
|
15 |
if not text.strip():
|
16 |
-
return None,
|
17 |
if not voice:
|
18 |
-
return None,
|
19 |
|
20 |
voice_short_name = voice.split(" - ")[0]
|
21 |
rate_str = f"{rate:+d}%"
|
@@ -27,14 +25,12 @@ async def text_to_speech(text, voice, rate, pitch):
|
|
27 |
return tmp_path, None
|
28 |
|
29 |
# Gradio interface function
|
30 |
-
@spaces.GPU
|
31 |
def tts_interface(text, voice, rate, pitch):
|
|
|
32 |
audio, warning = asyncio.run(text_to_speech(text, voice, rate, pitch))
|
33 |
return audio, warning
|
34 |
|
35 |
# Create Gradio application
|
36 |
-
import gradio as gr
|
37 |
-
|
38 |
async def create_demo():
|
39 |
voices = await get_voices()
|
40 |
|
@@ -58,11 +54,12 @@ async def create_demo():
|
|
58 |
description=description,
|
59 |
article="Experience the power of Voicecloning.be for text-to-speech conversion.",
|
60 |
analytics_enabled=False,
|
61 |
-
allow_flagging=False
|
|
|
62 |
)
|
63 |
return demo
|
64 |
|
65 |
# Run the application
|
66 |
if __name__ == "__main__":
|
67 |
demo = asyncio.run(create_demo())
|
68 |
-
demo.launch()
|
|
|
|
|
1 |
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():
|
|
|
11 |
# Text-to-speech function
|
12 |
async def text_to_speech(text, voice, rate, pitch):
|
13 |
if not text.strip():
|
14 |
+
return None, "Please enter text to convert."
|
15 |
if not voice:
|
16 |
+
return None, "Please select a voice."
|
17 |
|
18 |
voice_short_name = voice.split(" - ")[0]
|
19 |
rate_str = f"{rate:+d}%"
|
|
|
25 |
return tmp_path, None
|
26 |
|
27 |
# Gradio interface function
|
|
|
28 |
def tts_interface(text, voice, rate, pitch):
|
29 |
+
# Run the text_to_speech function within the Gradio interface
|
30 |
audio, warning = asyncio.run(text_to_speech(text, voice, rate, pitch))
|
31 |
return audio, warning
|
32 |
|
33 |
# Create Gradio application
|
|
|
|
|
34 |
async def create_demo():
|
35 |
voices = await get_voices()
|
36 |
|
|
|
54 |
description=description,
|
55 |
article="Experience the power of Voicecloning.be for text-to-speech conversion.",
|
56 |
analytics_enabled=False,
|
57 |
+
allow_flagging=False,
|
58 |
+
share=True # Make the Gradio app shareable with a public link
|
59 |
)
|
60 |
return demo
|
61 |
|
62 |
# Run the application
|
63 |
if __name__ == "__main__":
|
64 |
demo = asyncio.run(create_demo())
|
65 |
+
demo.launch(share=True)
|