Update app.py
Browse files
app.py
CHANGED
|
@@ -2,21 +2,22 @@ import os
|
|
| 2 |
import sys
|
| 3 |
import subprocess
|
| 4 |
|
| 5 |
-
#
|
| 6 |
if not os.path.exists("LuxTTS"):
|
| 7 |
subprocess.run(["git", "clone", "https://github.com/ysharma3501/LuxTTS.git"])
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
subprocess.run([sys.executable, "-m", "pip", "install", "-r", "LuxTTS/requirements.txt"])
|
| 11 |
|
| 12 |
-
|
| 13 |
sys.path.append(os.path.abspath("LuxTTS"))
|
| 14 |
|
| 15 |
import gradio as gr
|
| 16 |
import torch
|
| 17 |
-
from zipvoice.
|
| 18 |
|
| 19 |
-
#
|
| 20 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 21 |
lux_tts = LuxTTS('YatharthS/LuxTTS', device=device, threads=2)
|
| 22 |
|
|
@@ -24,7 +25,10 @@ def infer(text, audio_prompt, rms, t_shift, num_steps, speed, return_smooth):
|
|
| 24 |
if audio_prompt is None or not text:
|
| 25 |
return None
|
| 26 |
|
|
|
|
| 27 |
encoded_prompt = lux_tts.encode_prompt(audio_prompt, rms=rms)
|
|
|
|
|
|
|
| 28 |
final_wav = lux_tts.generate_speech(
|
| 29 |
text,
|
| 30 |
encoded_prompt,
|
|
@@ -37,19 +41,32 @@ def infer(text, audio_prompt, rms, t_shift, num_steps, speed, return_smooth):
|
|
| 37 |
|
| 38 |
# Gradio UI
|
| 39 |
with gr.Blocks() as demo:
|
| 40 |
-
gr.Markdown("# LuxTTS
|
|
|
|
| 41 |
with gr.Row():
|
| 42 |
with gr.Column():
|
| 43 |
-
input_text = gr.Textbox(label="Text", value="
|
| 44 |
-
input_audio = gr.Audio(label="Reference
|
|
|
|
| 45 |
with gr.Row():
|
| 46 |
-
rms_val = gr.Number(value=0.01, label="RMS")
|
| 47 |
t_shift_val = gr.Number(value=0.9, label="T-Shift")
|
| 48 |
-
steps_val = gr.Slider(1, 10, value=4, step=1, label="Steps")
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
with gr.Column():
|
| 51 |
-
audio_out = gr.Audio(label="
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
demo.launch()
|
|
|
|
| 2 |
import sys
|
| 3 |
import subprocess
|
| 4 |
|
| 5 |
+
# 1. Clone the repo if it doesn't exist
|
| 6 |
if not os.path.exists("LuxTTS"):
|
| 7 |
subprocess.run(["git", "clone", "https://github.com/ysharma3501/LuxTTS.git"])
|
| 8 |
|
| 9 |
+
# 2. Install requirements from the cloned folder
|
| 10 |
+
# This ensures all dependencies (transformers, librosa, etc.) are present
|
| 11 |
subprocess.run([sys.executable, "-m", "pip", "install", "-r", "LuxTTS/requirements.txt"])
|
| 12 |
|
| 13 |
+
# 3. Add to path so the 'zipvoice' module is importable
|
| 14 |
sys.path.append(os.path.abspath("LuxTTS"))
|
| 15 |
|
| 16 |
import gradio as gr
|
| 17 |
import torch
|
| 18 |
+
from zipvoice.luxtts import LuxTTS
|
| 19 |
|
| 20 |
+
# Init Model
|
| 21 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 22 |
lux_tts = LuxTTS('YatharthS/LuxTTS', device=device, threads=2)
|
| 23 |
|
|
|
|
| 25 |
if audio_prompt is None or not text:
|
| 26 |
return None
|
| 27 |
|
| 28 |
+
# Encode reference
|
| 29 |
encoded_prompt = lux_tts.encode_prompt(audio_prompt, rms=rms)
|
| 30 |
+
|
| 31 |
+
# Generate speech with ALL params
|
| 32 |
final_wav = lux_tts.generate_speech(
|
| 33 |
text,
|
| 34 |
encoded_prompt,
|
|
|
|
| 41 |
|
| 42 |
# Gradio UI
|
| 43 |
with gr.Blocks() as demo:
|
| 44 |
+
gr.Markdown("# 🎙️ LuxTTS Voice Cloning")
|
| 45 |
+
|
| 46 |
with gr.Row():
|
| 47 |
with gr.Column():
|
| 48 |
+
input_text = gr.Textbox(label="Text to Synthesize", value="Hey, what's up? I'm feeling really great!")
|
| 49 |
+
input_audio = gr.Audio(label="Reference Audio (.wav)", type="filepath")
|
| 50 |
+
|
| 51 |
with gr.Row():
|
| 52 |
+
rms_val = gr.Number(value=0.01, label="RMS (Loudness)")
|
| 53 |
t_shift_val = gr.Number(value=0.9, label="T-Shift")
|
| 54 |
+
steps_val = gr.Slider(1, 10, value=4, step=1, label="Num Steps")
|
| 55 |
+
|
| 56 |
+
with gr.Row():
|
| 57 |
+
speed_val = gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="Speed (Lower = Faster)")
|
| 58 |
+
smooth_val = gr.Checkbox(label="Return Smooth", value=False)
|
| 59 |
+
|
| 60 |
+
btn = gr.Button("Generate Speech", variant="primary")
|
| 61 |
+
|
| 62 |
with gr.Column():
|
| 63 |
+
audio_out = gr.Audio(label="Result")
|
| 64 |
|
| 65 |
+
# Fixed: Passing all inputs to match the infer function signature
|
| 66 |
+
btn.click(
|
| 67 |
+
fn=infer,
|
| 68 |
+
inputs=[input_text, input_audio, rms_val, t_shift_val, steps_val, speed_val, smooth_val],
|
| 69 |
+
outputs=audio_out
|
| 70 |
+
)
|
| 71 |
|
| 72 |
demo.launch()
|