Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from TTS.api import TTS
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
# Load the model
|
| 6 |
+
tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", gpu=True)
|
| 7 |
+
|
| 8 |
+
def generate(text, lang, speaker_wav=None):
|
| 9 |
+
out_path = "output.wav"
|
| 10 |
+
|
| 11 |
+
if speaker_wav:
|
| 12 |
+
tts.tts_to_file(
|
| 13 |
+
text=text,
|
| 14 |
+
speaker_wav=speaker_wav,
|
| 15 |
+
language=lang,
|
| 16 |
+
file_path=out_path
|
| 17 |
+
)
|
| 18 |
+
else:
|
| 19 |
+
tts.tts_to_file(
|
| 20 |
+
text=text,
|
| 21 |
+
language=lang,
|
| 22 |
+
file_path=out_path
|
| 23 |
+
)
|
| 24 |
+
return out_path
|
| 25 |
+
|
| 26 |
+
demo = gr.Interface(
|
| 27 |
+
fn=generate,
|
| 28 |
+
inputs=[
|
| 29 |
+
gr.Textbox(label="Horror Text"),
|
| 30 |
+
gr.Dropdown(choices=["en", "es", "fr", "de", "it", "pt"], label="Language", value="en"),
|
| 31 |
+
gr.Audio(source="upload", type="filepath", label="🎙 Voice Clone (optional)")
|
| 32 |
+
],
|
| 33 |
+
outputs=gr.Audio(type="filepath"),
|
| 34 |
+
title="👻 XTTS Horror Voice Generator",
|
| 35 |
+
description="Type some cursed text, clone a scary voice, and summon audio from the void."
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
demo.launch()
|