IFMedTechdemo commited on
Commit
dfe4207
·
verified ·
1 Parent(s): 044b3d1

Clone NeuTTS-Air at runtime to fix build error

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -2,19 +2,29 @@ import spaces
2
  import os
3
  import sys
4
  import tempfile
 
5
  import numpy as np
6
  import gradio as gr
7
  import soundfile as sf
8
 
 
 
 
 
 
 
 
 
 
9
  # Add NeuTTS-Air to path
10
- sys.path.append("neutts-air")
11
 
12
  # Global variables for lazy loading
13
  kokoro_pipe = None
14
  neutts_model = None
15
 
16
  # NeuTTS-Air configuration
17
- SAMPLES_PATH = os.path.join(os.getcwd(), "neutts-air", "samples")
18
  DEFAULT_REF_TEXT = "So I'm live on radio. And I say, well, my dear friend James here clearly, and the whole room just froze. Turns out I'd completely misspoken and mentioned our other friend."
19
  DEFAULT_REF_PATH = os.path.join(SAMPLES_PATH, "dave.wav")
20
  DEFAULT_GEN_TEXT = "My name is Dave, and um, I'm from London."
 
2
  import os
3
  import sys
4
  import tempfile
5
+ import subprocess
6
  import numpy as np
7
  import gradio as gr
8
  import soundfile as sf
9
 
10
+ # Clone NeuTTS-Air repository if not present
11
+ NEUTTS_DIR = "neutts-air"
12
+ if not os.path.exists(NEUTTS_DIR):
13
+ try:
14
+ subprocess.run(["git", "clone", "https://github.com/neuphonic/neutts-air.git", NEUTTS_DIR], check=True)
15
+ print(f"Successfully cloned NeuTTS-Air to {NEUTTS_DIR}")
16
+ except Exception as e:
17
+ print(f"Warning: Could not clone NeuTTS-Air: {e}")
18
+
19
  # Add NeuTTS-Air to path
20
+ sys.path.append(NEUTTS_DIR)
21
 
22
  # Global variables for lazy loading
23
  kokoro_pipe = None
24
  neutts_model = None
25
 
26
  # NeuTTS-Air configuration
27
+ SAMPLES_PATH = os.path.join(os.getcwd(), NEUTTS_DIR, "samples")
28
  DEFAULT_REF_TEXT = "So I'm live on radio. And I say, well, my dear friend James here clearly, and the whole room just froze. Turns out I'd completely misspoken and mentioned our other friend."
29
  DEFAULT_REF_PATH = os.path.join(SAMPLES_PATH, "dave.wav")
30
  DEFAULT_GEN_TEXT = "My name is Dave, and um, I'm from London."