Spaces:
Running
on
Zero
Running
on
Zero
Sync from GitHub repo
Browse filesThis Space is synced from the GitHub repo: https://github.com/SWivid/F5-TTS. Please submit contributions to the Space there
app.py
CHANGED
@@ -80,6 +80,8 @@ def load_custom(ckpt_path: str, vocab_path="", model_cfg=None):
|
|
80 |
vocab_path = str(cached_path(vocab_path))
|
81 |
if model_cfg is None:
|
82 |
model_cfg = json.loads(DEFAULT_TTS_MODEL_CFG[2])
|
|
|
|
|
83 |
return load_model(DiT, model_cfg, ckpt_path, vocab_file=vocab_path)
|
84 |
|
85 |
|
@@ -124,7 +126,7 @@ def load_text_from_file(file):
|
|
124 |
return gr.update(value=text)
|
125 |
|
126 |
|
127 |
-
@lru_cache(maxsize=100)
|
128 |
@gpu_decorator
|
129 |
def infer(
|
130 |
ref_audio_orig,
|
@@ -163,7 +165,7 @@ def infer(
|
|
163 |
show_info("Loading E2-TTS model...")
|
164 |
E2TTS_ema_model = load_e2tts()
|
165 |
ema_model = E2TTS_ema_model
|
166 |
-
elif isinstance(model,
|
167 |
assert not USING_SPACES, "Only official checkpoints allowed in Spaces."
|
168 |
global custom_ema_model, pre_custom_path
|
169 |
if pre_custom_path != model[1]:
|
@@ -959,7 +961,7 @@ If you're having issues, try converting your reference audio to WAV or MP3, clip
|
|
959 |
global tts_model_choice
|
960 |
if new_choice == "Custom": # override in case webpage is refreshed
|
961 |
custom_ckpt_path, custom_vocab_path, custom_model_cfg = load_last_used_custom()
|
962 |
-
tts_model_choice =
|
963 |
return (
|
964 |
gr.update(visible=True, value=custom_ckpt_path),
|
965 |
gr.update(visible=True, value=custom_vocab_path),
|
@@ -971,7 +973,7 @@ If you're having issues, try converting your reference audio to WAV or MP3, clip
|
|
971 |
|
972 |
def set_custom_model(custom_ckpt_path, custom_vocab_path, custom_model_cfg):
|
973 |
global tts_model_choice
|
974 |
-
tts_model_choice =
|
975 |
with open(last_used_custom, "w", encoding="utf-8") as f:
|
976 |
f.write(custom_ckpt_path + "\n" + custom_vocab_path + "\n" + custom_model_cfg + "\n")
|
977 |
|
|
|
80 |
vocab_path = str(cached_path(vocab_path))
|
81 |
if model_cfg is None:
|
82 |
model_cfg = json.loads(DEFAULT_TTS_MODEL_CFG[2])
|
83 |
+
elif isinstance(model_cfg, str):
|
84 |
+
model_cfg = json.loads(model_cfg)
|
85 |
return load_model(DiT, model_cfg, ckpt_path, vocab_file=vocab_path)
|
86 |
|
87 |
|
|
|
126 |
return gr.update(value=text)
|
127 |
|
128 |
|
129 |
+
@lru_cache(maxsize=100) # NOTE. need to ensure params of infer() hashable
|
130 |
@gpu_decorator
|
131 |
def infer(
|
132 |
ref_audio_orig,
|
|
|
165 |
show_info("Loading E2-TTS model...")
|
166 |
E2TTS_ema_model = load_e2tts()
|
167 |
ema_model = E2TTS_ema_model
|
168 |
+
elif isinstance(model, tuple) and model[0] == "Custom":
|
169 |
assert not USING_SPACES, "Only official checkpoints allowed in Spaces."
|
170 |
global custom_ema_model, pre_custom_path
|
171 |
if pre_custom_path != model[1]:
|
|
|
961 |
global tts_model_choice
|
962 |
if new_choice == "Custom": # override in case webpage is refreshed
|
963 |
custom_ckpt_path, custom_vocab_path, custom_model_cfg = load_last_used_custom()
|
964 |
+
tts_model_choice = ("Custom", custom_ckpt_path, custom_vocab_path, custom_model_cfg)
|
965 |
return (
|
966 |
gr.update(visible=True, value=custom_ckpt_path),
|
967 |
gr.update(visible=True, value=custom_vocab_path),
|
|
|
973 |
|
974 |
def set_custom_model(custom_ckpt_path, custom_vocab_path, custom_model_cfg):
|
975 |
global tts_model_choice
|
976 |
+
tts_model_choice = ("Custom", custom_ckpt_path, custom_vocab_path, custom_model_cfg)
|
977 |
with open(last_used_custom, "w", encoding="utf-8") as f:
|
978 |
f.write(custom_ckpt_path + "\n" + custom_vocab_path + "\n" + custom_model_cfg + "\n")
|
979 |
|