Update app.py
Browse files
app.py
CHANGED
|
@@ -43,6 +43,21 @@ celebrity_voices = {
|
|
| 43 |
"LeBron James": "./voices/LeBron James.mp3",
|
| 44 |
"Usain Bolt": "./voices/Usain.mp3" # Note: The file is named "Usain.mp3"
|
| 45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
@spaces.GPU(duration=120)
|
| 47 |
def tts_generate(text, voice, language):
|
| 48 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as temp_audio:
|
|
@@ -79,6 +94,10 @@ def talking_image_placeholder():
|
|
| 79 |
with gr.Blocks() as demo:
|
| 80 |
gr.Markdown("# Advanced Voice Synthesis")
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
with gr.Tabs():
|
| 83 |
with gr.TabItem("TTS"):
|
| 84 |
with gr.Row():
|
|
@@ -123,10 +142,9 @@ function refresh() {
|
|
| 123 |
"""
|
| 124 |
|
| 125 |
# Launch the interface
|
| 126 |
-
# with gr.Blocks(js=js_func) as demo:
|
| 127 |
demo.launch()
|
| 128 |
|
| 129 |
# Clean up temporary files (this will run after the Gradio server is closed)
|
| 130 |
for file in os.listdir():
|
| 131 |
if file.endswith('.wav') and file.startswith('tmp'):
|
| 132 |
-
os.remove(file)
|
|
|
|
| 43 |
"LeBron James": "./voices/LeBron James.mp3",
|
| 44 |
"Usain Bolt": "./voices/Usain.mp3" # Note: The file is named "Usain.mp3"
|
| 45 |
}
|
| 46 |
+
|
| 47 |
+
def check_voice_files():
|
| 48 |
+
"""
|
| 49 |
+
Checks if all voice files exist in the celebrity_voices dictionary.
|
| 50 |
+
Returns a message listing missing files or confirming all files are present.
|
| 51 |
+
"""
|
| 52 |
+
missing = []
|
| 53 |
+
for voice, path in celebrity_voices.items():
|
| 54 |
+
if not os.path.exists(path):
|
| 55 |
+
missing.append(f"{voice}: {path}")
|
| 56 |
+
if missing:
|
| 57 |
+
return "**Missing Voice Files:**\n" + "\n".join(missing)
|
| 58 |
+
else:
|
| 59 |
+
return "**All voice files are present.** 🎉"
|
| 60 |
+
|
| 61 |
@spaces.GPU(duration=120)
|
| 62 |
def tts_generate(text, voice, language):
|
| 63 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as temp_audio:
|
|
|
|
| 94 |
with gr.Blocks() as demo:
|
| 95 |
gr.Markdown("# Advanced Voice Synthesis")
|
| 96 |
|
| 97 |
+
# Display voice files status
|
| 98 |
+
voice_status = check_voice_files()
|
| 99 |
+
gr.Markdown(voice_status)
|
| 100 |
+
|
| 101 |
with gr.Tabs():
|
| 102 |
with gr.TabItem("TTS"):
|
| 103 |
with gr.Row():
|
|
|
|
| 142 |
"""
|
| 143 |
|
| 144 |
# Launch the interface
|
|
|
|
| 145 |
demo.launch()
|
| 146 |
|
| 147 |
# Clean up temporary files (this will run after the Gradio server is closed)
|
| 148 |
for file in os.listdir():
|
| 149 |
if file.endswith('.wav') and file.startswith('tmp'):
|
| 150 |
+
os.remove(file)
|