YatharthS commited on
Commit
928010a
·
verified ·
1 Parent(s): b744a9a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -13
app.py CHANGED
@@ -2,21 +2,22 @@ import os
2
  import sys
3
  import subprocess
4
 
5
- ## restart
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.luxvoice import LuxTTS
18
 
19
- # Standard setup continues...
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 (Automatic Setup)")
 
41
  with gr.Row():
42
  with gr.Column():
43
- input_text = gr.Textbox(label="Text", value="Hello there!")
44
- input_audio = gr.Audio(label="Reference Voice", type="filepath")
 
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
- btn = gr.Button("Synthesize")
 
 
 
 
 
 
50
  with gr.Column():
51
- audio_out = gr.Audio(label="Output")
52
 
53
- btn.click(infer, [input_text, input_audio, rms_val, t_shift_val, steps_val], audio_out)
 
 
 
 
 
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()