mrfakename commited on
Commit
2a3a3a4
1 Parent(s): 630814d

Sync from GitHub repo

Browse files

This Space is synced from the GitHub repo: https://github.com/SWivid/F5-TTS. Please submit contributions to the Space there

Files changed (2) hide show
  1. app.py +15 -12
  2. src/f5_tts/infer/utils_infer.py +1 -1
app.py CHANGED
@@ -757,17 +757,22 @@ If you're having issues, try converting your reference audio to WAV or MP3, clip
757
  "hf://SWivid/F5-TTS/F5TTS_Base/vocab.txt",
758
  ]
759
 
760
- def switch_tts_model(new_choice, custom_ckpt_path, custom_vocab_path):
761
  global tts_model_choice
762
- if new_choice == "Custom":
 
763
  tts_model_choice = ["Custom", custom_ckpt_path, custom_vocab_path]
764
- with open(last_used_custom, "w") as f:
765
- f.write(f"{custom_ckpt_path},{custom_vocab_path}")
766
- return gr.update(visible=True), gr.update(visible=True)
767
  else:
768
  tts_model_choice = new_choice
769
  return gr.update(visible=False), gr.update(visible=False)
770
 
 
 
 
 
 
 
771
  with gr.Row():
772
  if not USING_SPACES:
773
  choose_tts_model = gr.Radio(
@@ -794,20 +799,18 @@ If you're having issues, try converting your reference audio to WAV or MP3, clip
794
 
795
  choose_tts_model.change(
796
  switch_tts_model,
797
- inputs=[choose_tts_model, custom_ckpt_path, custom_vocab_path],
798
  outputs=[custom_ckpt_path, custom_vocab_path],
799
  show_progress="hidden",
800
  )
801
  custom_ckpt_path.change(
802
- switch_tts_model,
803
- inputs=[choose_tts_model, custom_ckpt_path, custom_vocab_path],
804
- outputs=[custom_ckpt_path, custom_vocab_path],
805
  show_progress="hidden",
806
  )
807
  custom_vocab_path.change(
808
- switch_tts_model,
809
- inputs=[choose_tts_model, custom_ckpt_path, custom_vocab_path],
810
- outputs=[custom_ckpt_path, custom_vocab_path],
811
  show_progress="hidden",
812
  )
813
 
 
757
  "hf://SWivid/F5-TTS/F5TTS_Base/vocab.txt",
758
  ]
759
 
760
+ def switch_tts_model(new_choice):
761
  global tts_model_choice
762
+ if new_choice == "Custom": # override in case webpage is refreshed
763
+ custom_ckpt_path, custom_vocab_path = load_last_used_custom()
764
  tts_model_choice = ["Custom", custom_ckpt_path, custom_vocab_path]
765
+ return gr.update(visible=True, value=custom_ckpt_path), gr.update(visible=True, value=custom_vocab_path)
 
 
766
  else:
767
  tts_model_choice = new_choice
768
  return gr.update(visible=False), gr.update(visible=False)
769
 
770
+ def set_custom_model(custom_ckpt_path, custom_vocab_path):
771
+ global tts_model_choice
772
+ tts_model_choice = ["Custom", custom_ckpt_path, custom_vocab_path]
773
+ with open(last_used_custom, "w") as f:
774
+ f.write(f"{custom_ckpt_path},{custom_vocab_path}")
775
+
776
  with gr.Row():
777
  if not USING_SPACES:
778
  choose_tts_model = gr.Radio(
 
799
 
800
  choose_tts_model.change(
801
  switch_tts_model,
802
+ inputs=[choose_tts_model],
803
  outputs=[custom_ckpt_path, custom_vocab_path],
804
  show_progress="hidden",
805
  )
806
  custom_ckpt_path.change(
807
+ set_custom_model,
808
+ inputs=[custom_ckpt_path, custom_vocab_path],
 
809
  show_progress="hidden",
810
  )
811
  custom_vocab_path.change(
812
+ set_custom_model,
813
+ inputs=[custom_ckpt_path, custom_vocab_path],
 
814
  show_progress="hidden",
815
  )
816
 
src/f5_tts/infer/utils_infer.py CHANGED
@@ -194,7 +194,7 @@ def load_model(
194
  tokenizer = "custom"
195
 
196
  print("\nvocab : ", vocab_file)
197
- print("tokenizer : ", tokenizer)
198
  print("model : ", ckpt_path, "\n")
199
 
200
  vocab_char_map, vocab_size = get_tokenizer(vocab_file, tokenizer)
 
194
  tokenizer = "custom"
195
 
196
  print("\nvocab : ", vocab_file)
197
+ print("token : ", tokenizer)
198
  print("model : ", ckpt_path, "\n")
199
 
200
  vocab_char_map, vocab_size = get_tokenizer(vocab_file, tokenizer)