Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from TTS.api import TTS
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
tts = TTS(model_name="coqui/XTTS-v2", gpu=True)
|
| 6 |
+
|
| 7 |
+
def synthesize(text, speaker_wav):
|
| 8 |
+
output_path = "output.wav"
|
| 9 |
+
if speaker_wav is None:
|
| 10 |
+
return "No voice sample uploaded.", None
|
| 11 |
+
|
| 12 |
+
# Save uploaded file
|
| 13 |
+
speaker_path = "temp_speaker.wav"
|
| 14 |
+
speaker_wav.save(speaker_path)
|
| 15 |
+
|
| 16 |
+
# Run TTS
|
| 17 |
+
tts.tts_to_file(
|
| 18 |
+
text=text,
|
| 19 |
+
speaker_wav=speaker_path,
|
| 20 |
+
language="en",
|
| 21 |
+
file_path=output_path
|
| 22 |
+
)
|
| 23 |
+
return "Done. Listen below.", output_path
|
| 24 |
+
|
| 25 |
+
iface = gr.Interface(
|
| 26 |
+
fn=synthesize,
|
| 27 |
+
inputs=[
|
| 28 |
+
gr.Textbox(label="Text to Speak", placeholder="Come closer... I've been waiting in the dark."),
|
| 29 |
+
gr.Audio(source="upload", type="file", label="Creepy Voice Sample")
|
| 30 |
+
],
|
| 31 |
+
outputs=[
|
| 32 |
+
gr.Textbox(label="Status"),
|
| 33 |
+
gr.Audio(label="Result Audio")
|
| 34 |
+
],
|
| 35 |
+
title="XTTS‑V2 Horror Whisperer 👻",
|
| 36 |
+
description="Upload a voice and make it say creepy stuff. XTTS‑v2 powered, GPU-juiced. 🧟♂️💀"
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
if __name__ == "__main__":
|
| 40 |
+
iface.launch()
|