Nông Văn Thắng commited on
Commit
1dd72ff
1 Parent(s): c39652e
Files changed (1) hide show
  1. app.py +34 -11
app.py CHANGED
@@ -19,8 +19,35 @@ from underthesea import sent_tokenize
19
  from unidecode import unidecode
20
  from vinorm import TTSnorm
21
 
22
- from TTS.tts.configs.xtts_config import XttsConfig
23
- from TTS.tts.models.xtts import Xtts
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  XTTS_MODEL = None
26
  SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -56,7 +83,9 @@ def load_model(checkpoint_dir="model/", repo_id="capleaf/viXTTS", use_deepspeed=
56
  )
57
  yield f"Model download finished..."
58
 
59
- xtts_config = os.path.join(checkpoint_dir, "config.json")
 
 
60
  config = XttsConfig()
61
  config.load_json(xtts_config)
62
  XTTS_MODEL = Xtts.init_from_config(config)
@@ -279,14 +308,6 @@ def read_logs():
279
  return f.read()
280
 
281
 
282
- def run_docker_setup():
283
- """Run the Docker setup commands."""
284
- subprocess.run("python -m venv .env && . .env/bin/activate && git submodule update --init --recursive && cd TTS && git fetch --tags && git checkout 0.1.1 && echo 'Installing TTS...' && pip install --use-deprecated=legacy-resolver -e . -q && cd .. && echo 'Installing other requirements...' && pip install -r requirements.txt -q && echo 'Downloading Japanese/Chinese tokenizer...' && python -m unidic download && pip install --upgrade gradio && touch .env/ok", shell=True)
285
-
286
- # Call the function at the appropriate place in your code
287
- run_docker_setup()
288
-
289
-
290
  if __name__ == "__main__":
291
  parser = argparse.ArgumentParser(
292
  description="""viXTTS inference demo\n\n""",
@@ -417,3 +438,5 @@ if __name__ == "__main__":
417
  )
418
 
419
  demo.launch()
 
 
 
19
  from unidecode import unidecode
20
  from vinorm import TTSnorm
21
 
22
+ print("Setting up the environment...")
23
+ import subprocess
24
+
25
+ setup_command = [
26
+ "pip", "install", "--use-deprecated=legacy-resolver", "-e", ".", "-q",
27
+ "&&", "cd", "TTS ",
28
+ "&&", "git submodule update --init --recursive",
29
+ "&&", "echo", "Installing other requirements...",
30
+ "&&", "pip", "install", "-r", "requirements.txt", "-q",
31
+ "&&", "echo", "Downloading Japanese/Chinese tokenizer...",
32
+ "&&", "python", "-m", "unidic", "download",
33
+ "&&", "pip", "install", "--upgrade", "gradio"
34
+ ]
35
+
36
+ try:
37
+ subprocess.run(setup_command, check=True, shell=True)
38
+ print("Environment setup completed successfully.")
39
+ except subprocess.CalledProcessError as e:
40
+ print(f"Error during environment setup: {e}")
41
+ print("Please run the setup command manually if needed.")
42
+
43
+ print("\nTo set up the environment manually, run the following command:")
44
+ print("pip install --use-deprecated=legacy-resolver -e . -q && \\ ")
45
+ print("cd .. && \\ ")
46
+ print("echo \"Installing other requirements...\" && \\ ")
47
+ print("pip install -r requirements.txt -q && \\ ")
48
+ print("echo \"Downloading Japanese/Chinese tokenizer...\" && \\ ")
49
+ print("python -m unidic download && \\ ")
50
+ print("pip install --upgrade gradio")
51
 
52
  XTTS_MODEL = None
53
  SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
 
83
  )
84
  yield f"Model download finished..."
85
 
86
+ xtts_config = os.path.join(checkpoint_dir, "config.json")\
87
+ from TTS.tts.configs.xtts_config import XttsConfig
88
+ from TTS.tts.models.xtts import Xtts
89
  config = XttsConfig()
90
  config.load_json(xtts_config)
91
  XTTS_MODEL = Xtts.init_from_config(config)
 
308
  return f.read()
309
 
310
 
 
 
 
 
 
 
 
 
311
  if __name__ == "__main__":
312
  parser = argparse.ArgumentParser(
313
  description="""viXTTS inference demo\n\n""",
 
438
  )
439
 
440
  demo.launch()
441
+
442
+