lalalic commited on
Commit
bc1d7a3
·
verified ·
1 Parent(s): ababc28

Update xtts.py

Browse files
Files changed (1) hide show
  1. xtts.py +3 -16
xtts.py CHANGED
@@ -30,24 +30,10 @@ if not os.path.exists(sample_root):
30
  os.makedirs(sample_root)
31
 
32
  default_sample=f'{os.path.dirname(os.path.abspath(__file__))}/sample.wav', f'{sample_root}/sample.pt'
33
-
34
  ffmpeg=f'{os.path.dirname(os.path.abspath(__file__))}/ffmpeg'
35
- try:
36
- st = os.stat(ffmpeg)
37
- os.chmod(ffmpeg, st.st_mode | stat.S_IEXEC)
38
- except:
39
- traceback.print_exc()
40
 
41
  tts=None
42
  model=None
43
-
44
- model_name="tts_models/multilingual/multi-dataset/xtts_v2"
45
- try:
46
- tts = TTS(model_name=model_name)
47
- model=tts.synthesizer.tts_model
48
- except:
49
- traceback.print_exc()
50
-
51
  @app.route("/convert")
52
  def predict():
53
  global tts
@@ -66,12 +52,13 @@ def predict():
66
  if tts is None:
67
  TTS=import_module("TTS.api").TTS
68
  model_name="tts_models/multilingual/multi-dataset/xtts_v2"
69
- tts = TTS(model_name=model_name)
 
70
  model=tts.synthesizer.tts_model
71
- if not hasattr(model, '__get_conditioning_latents'):
72
  #hack to use cache
73
  model.__get_conditioning_latents=model.get_conditioning_latents
74
  model.get_conditioning_latents=get_conditioning_latents
 
75
 
76
  wav = tts.tts(
77
  text,
 
30
  os.makedirs(sample_root)
31
 
32
  default_sample=f'{os.path.dirname(os.path.abspath(__file__))}/sample.wav', f'{sample_root}/sample.pt'
 
33
  ffmpeg=f'{os.path.dirname(os.path.abspath(__file__))}/ffmpeg'
 
 
 
 
 
34
 
35
  tts=None
36
  model=None
 
 
 
 
 
 
 
 
37
  @app.route("/convert")
38
  def predict():
39
  global tts
 
52
  if tts is None:
53
  TTS=import_module("TTS.api").TTS
54
  model_name="tts_models/multilingual/multi-dataset/xtts_v2"
55
+ print(f"loading model {model_name} ...")
56
+ tts = TTS(model_name=model_name, progress_bar=False)
57
  model=tts.synthesizer.tts_model
 
58
  #hack to use cache
59
  model.__get_conditioning_latents=model.get_conditioning_latents
60
  model.get_conditioning_latents=get_conditioning_latents
61
+ print("model is ready")
62
 
63
  wav = tts.tts(
64
  text,