txya900619 commited on
Commit
f6c54a9
1 Parent(s): a523a5e

fix: zero gpu bug

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -46,7 +46,8 @@ OmegaConf.register_new_resolver("load_model", load_model)
46
  models_config = OmegaConf.to_object(OmegaConf.load("configs/models.yaml"))
47
 
48
  @spaces.GPU
49
- def _do_tts(model, ipa, language_name,speaker_name=None, speaker_wav=None):
 
50
  if speaker_wav is not None:
51
  return model.tts(
52
  ipa,
@@ -70,7 +71,6 @@ def text_to_speech(
70
  dialect,
71
  text: str,
72
  ):
73
- model = models_config[model_id]["model"]
74
  if len(text) == 0:
75
  raise gr.Error("請勿輸入空字串。")
76
  words, ipa, pinyin, missing_words = get_ipa(text, dialect=dialect)
@@ -81,7 +81,7 @@ def text_to_speech(
81
  parsed_ipa = parse_ipa(ipa)
82
  if use_default_emb_or_custom == "default":
83
  wav = _do_tts(
84
- model,
85
  parsed_ipa,
86
  speaker_name=speaker
87
  if len(models_config[model_id]["speaker_mapping"]) > 1
@@ -91,7 +91,7 @@ def text_to_speech(
91
  )
92
  else:
93
  wav = _do_tts(
94
- model,
95
  parsed_ipa,
96
  speaker_wav=speaker_wav,
97
  language_name=dialect,
@@ -100,7 +100,7 @@ def text_to_speech(
100
  return (
101
  words,
102
  pinyin,
103
- (model.tts_model.config.audio.sample_rate, np.array(wav)),
104
  )
105
 
106
 
 
46
  models_config = OmegaConf.to_object(OmegaConf.load("configs/models.yaml"))
47
 
48
  @spaces.GPU
49
+ def _do_tts(model_id, ipa, language_name,speaker_name=None, speaker_wav=None):
50
+ model = models_config[model_id]["model"]
51
  if speaker_wav is not None:
52
  return model.tts(
53
  ipa,
 
71
  dialect,
72
  text: str,
73
  ):
 
74
  if len(text) == 0:
75
  raise gr.Error("請勿輸入空字串。")
76
  words, ipa, pinyin, missing_words = get_ipa(text, dialect=dialect)
 
81
  parsed_ipa = parse_ipa(ipa)
82
  if use_default_emb_or_custom == "default":
83
  wav = _do_tts(
84
+ model_id,
85
  parsed_ipa,
86
  speaker_name=speaker
87
  if len(models_config[model_id]["speaker_mapping"]) > 1
 
91
  )
92
  else:
93
  wav = _do_tts(
94
+ model_id,
95
  parsed_ipa,
96
  speaker_wav=speaker_wav,
97
  language_name=dialect,
 
100
  return (
101
  words,
102
  pinyin,
103
+ (models_config[model_id]["model"].tts_model.config.audio.sample_rate, np.array(wav)),
104
  )
105
 
106