litagin commited on
Commit
1bdc958
β€’
1 Parent(s): dfa8419

Upload 6 files

Browse files
Files changed (2) hide show
  1. app.py +5 -2
  2. common/tts_model.py +12 -0
app.py CHANGED
@@ -39,6 +39,8 @@ languages = [l.value for l in Languages]
39
 
40
 
41
  def tts_fn(
 
 
42
  text,
43
  language,
44
  reference_audio_path,
@@ -64,7 +66,7 @@ def tts_fn(
64
  None,
65
  kata_tone_json_str,
66
  )
67
- assert model_holder.current_model is not None
68
 
69
  wrong_tone_message = ""
70
  kata_tone: Optional[list[tuple[str, int]]] = None
@@ -255,7 +257,8 @@ if __name__ == "__main__":
255
  text_input = gr.TextArea(label="γƒ†γ‚­γ‚Ήγƒˆ", value=initial_text)
256
 
257
  line_split = gr.Checkbox(
258
- label="ζ”Ήθ‘Œγ§εˆ†γ‘γ¦η”Ÿζˆ", value=DEFAULT_LINE_SPLIT
 
259
  )
260
  split_interval = gr.Slider(
261
  minimum=0.0,
 
39
 
40
 
41
  def tts_fn(
42
+ model_name,
43
+ model_path,
44
  text,
45
  language,
46
  reference_audio_path,
 
66
  None,
67
  kata_tone_json_str,
68
  )
69
+ model_holder.load_model_gr(model_name, model_path)
70
 
71
  wrong_tone_message = ""
72
  kata_tone: Optional[list[tuple[str, int]]] = None
 
257
  text_input = gr.TextArea(label="γƒ†γ‚­γ‚Ήγƒˆ", value=initial_text)
258
 
259
  line_split = gr.Checkbox(
260
+ label="ζ”Ήθ‘Œγ§εˆ†γ‘γ¦η”ŸζˆοΌˆεˆ†γ‘γŸγ»γ†γŒζ„Ÿζƒ…γŒδΉ—γ‚ŠγΎγ™οΌ‰",
261
+ value=DEFAULT_LINE_SPLIT,
262
  )
263
  split_interval = gr.Slider(
264
  minimum=0.0,
common/tts_model.py CHANGED
@@ -209,6 +209,18 @@ class ModelHolder:
209
  raise ValueError(f"Model `{model_name}` is not found")
210
  if model_path not in self.model_files_dict[model_name]:
211
  raise ValueError(f"Model file `{model_path}` is not found")
 
 
 
 
 
 
 
 
 
 
 
 
212
  self.current_model = Model(
213
  model_path=model_path,
214
  config_path=os.path.join(self.root_dir, model_name, "config.json"),
 
209
  raise ValueError(f"Model `{model_name}` is not found")
210
  if model_path not in self.model_files_dict[model_name]:
211
  raise ValueError(f"Model file `{model_path}` is not found")
212
+ if (
213
+ self.current_model is not None
214
+ and self.current_model.model_path == model_path
215
+ ):
216
+ # Already loaded
217
+ speakers = list(self.current_model.spk2id.keys())
218
+ styles = list(self.current_model.style2id.keys())
219
+ return (
220
+ gr.Dropdown(choices=styles, value=styles[0]),
221
+ gr.Button(interactive=True, value="音声合成"),
222
+ gr.Dropdown(choices=speakers, value=speakers[0]),
223
+ )
224
  self.current_model = Model(
225
  model_path=model_path,
226
  config_path=os.path.join(self.root_dir, model_name, "config.json"),