feat(f5tts): HF-URL Support fuer Custom Checkpoints (aihpi/F5-TTS-German)
_resolve_hf_path wandelt hf://user/repo/path → lokaler Download via
huggingface_hub.hf_hub_download. So kann man in Diagnostic einfach die
HF-Pfade fuer custom Modelle reinschreiben, ohne erst manuell zu
downloaden + zu mounten.
Format: hf://aihpi/F5-TTS-German/F5TTS_Base/model_365000.safetensors
hf://aihpi/F5-TTS-German/vocab.txt
Diagnostic UI: Placeholders + Labels angepasst mit Beispiel-HF-Pfaden
und Hinweis dass fuer Fine-Tunes "F5TTS_Base" statt "F5TTS_v1_Base"
als Architektur-Name gesetzt werden muss.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -469,23 +469,25 @@
|
||||
Hardcoded Defaults: F5TTS_v1_Base, cfg_strength=2.5, nfe_step=32.
|
||||
</div>
|
||||
|
||||
<label style="color:#8888AA;font-size:12px;">Modell-ID:</label>
|
||||
<label style="color:#8888AA;font-size:12px;">
|
||||
Modell-Architektur (F5TTS_v1_Base = Default multilingual, F5TTS_Base = fuer die meisten Fine-Tunes):
|
||||
</label>
|
||||
<input type="text" id="diag-f5tts-model"
|
||||
placeholder="F5TTS_v1_Base"
|
||||
style="background:#1E1E2E;color:#fff;border:1px solid #2A2A3E;border-radius:6px;padding:6px 10px;font-size:13px;">
|
||||
|
||||
<label style="color:#8888AA;font-size:12px;">
|
||||
Custom Checkpoint (HF-Repo "user/repo" oder Container-Pfad, leer = Default):
|
||||
Custom Checkpoint — HF-Pfad (hf://user/repo/file) oder lokaler Container-Pfad. Leer = Default.
|
||||
</label>
|
||||
<input type="text" id="diag-f5tts-ckpt"
|
||||
placeholder="z.B. aoxo/F5-TTS-German"
|
||||
placeholder="z.B. hf://aihpi/F5-TTS-German/F5TTS_Base/model_365000.safetensors"
|
||||
style="background:#1E1E2E;color:#fff;border:1px solid #2A2A3E;border-radius:6px;padding:6px 10px;font-size:13px;">
|
||||
|
||||
<label style="color:#8888AA;font-size:12px;">
|
||||
Custom Vocab (passend zum Checkpoint, optional):
|
||||
Custom Vocab — muss zum Checkpoint passen. Leer = Default.
|
||||
</label>
|
||||
<input type="text" id="diag-f5tts-vocab"
|
||||
placeholder="leer = Default"
|
||||
placeholder="z.B. hf://aihpi/F5-TTS-German/vocab.txt"
|
||||
style="background:#1E1E2E;color:#fff;border:1px solid #2A2A3E;border-radius:6px;padding:6px 10px;font-size:13px;">
|
||||
|
||||
<div style="display:flex;gap:12px;">
|
||||
|
||||
+34
-5
@@ -99,6 +99,33 @@ def _get_f5tts_cls():
|
||||
return _F5TTS_cls
|
||||
|
||||
|
||||
def _resolve_hf_path(p: str) -> str:
|
||||
"""Wenn p mit 'hf://' anfaengt → aus HuggingFace Hub runterladen,
|
||||
lokalen Pfad zurueckgeben. Sonst unveraendert.
|
||||
|
||||
Format: hf://user/repo/path/to/file.ext
|
||||
Beispiel: hf://aihpi/F5-TTS-German/F5TTS_Base/model_365000.safetensors
|
||||
"""
|
||||
if not p or not p.startswith("hf://"):
|
||||
return p
|
||||
try:
|
||||
from huggingface_hub import hf_hub_download
|
||||
rest = p[5:]
|
||||
parts = rest.split("/", 2)
|
||||
if len(parts) < 3:
|
||||
logger.warning("Ungueltiges hf:// Format: %s (erwarte hf://user/repo/path)", p)
|
||||
return p
|
||||
repo_id = f"{parts[0]}/{parts[1]}"
|
||||
filename = parts[2]
|
||||
logger.info("HF-Download: %s aus %s", filename, repo_id)
|
||||
local = hf_hub_download(repo_id=repo_id, filename=filename)
|
||||
logger.info("HF-Download fertig: %s", local)
|
||||
return local
|
||||
except Exception as e:
|
||||
logger.exception("HF-Download fehlgeschlagen fuer %s: %s", p, e)
|
||||
return p
|
||||
|
||||
|
||||
class F5Runner:
|
||||
"""Haelt das F5-TTS-Modell. Synthese laeuft im Executor (blocking).
|
||||
|
||||
@@ -122,14 +149,16 @@ class F5Runner:
|
||||
|
||||
def _load_blocking(self) -> None:
|
||||
cls = _get_f5tts_cls()
|
||||
ckpt_resolved = _resolve_hf_path(self.ckpt_file) if self.ckpt_file else ""
|
||||
vocab_resolved = _resolve_hf_path(self.vocab_file) if self.vocab_file else ""
|
||||
logger.info("Lade F5-TTS '%s' (device=%s, ckpt=%s)...",
|
||||
self.model_id, F5TTS_DEVICE, self.ckpt_file or "default")
|
||||
self.model_id, F5TTS_DEVICE, ckpt_resolved or "default")
|
||||
self._load_started_at = time.time()
|
||||
kwargs = {"model": self.model_id, "device": F5TTS_DEVICE}
|
||||
if self.ckpt_file:
|
||||
kwargs["ckpt_file"] = self.ckpt_file
|
||||
if self.vocab_file:
|
||||
kwargs["vocab_file"] = self.vocab_file
|
||||
if ckpt_resolved:
|
||||
kwargs["ckpt_file"] = ckpt_resolved
|
||||
if vocab_resolved:
|
||||
kwargs["vocab_file"] = vocab_resolved
|
||||
self.model = cls(**kwargs)
|
||||
elapsed = time.time() - self._load_started_at
|
||||
logger.info("F5-TTS geladen in %.1fs (cfg_strength=%.1f, nfe=%d)",
|
||||
|
||||
Reference in New Issue
Block a user