Files
mission-control-v2/client/lucy-tts/ptts_test.py
T
Hitonabi 09a1c98514 Lucy-TTS/F5: Skripte + Batches versionieren, schwere Assets ignoriert
- pocket_server.py (Produktions-TTS mit Stimmen-Waechter), text_norm, Bench-/Diag-Skripte
- lucy-f5: f5_server/f5_test/bench_dml (DirectML-Experiment, Phase C/D offen)
- .gitignore: venvs/Modelle/Audio/Logs der beiden Ordner + box_recon/gemma_swap-Scratch

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 10:29:33 +02:00

46 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
import os, time, numpy as np, soundfile as sf, librosa
from pocket_tts import TTSModel
BASE = r"F:\Coding Stuff\mission-control-2\client\lucy-tts"
OUT = os.path.join(BASE, "out_ptts"); os.makedirs(OUT, exist_ok=True)
# Referenz ~18s wav fuer Klon
y, _ = librosa.load(os.path.join(BASE, "ref.mp3"), sr=24000, mono=True)
yt, _ = librosa.effects.trim(y, top_db=30)
ref = os.path.join(BASE, "ptts_ref.wav")
sf.write(ref, yt[:int(18*24000)], 24000)
print(f"[ref] {min(len(yt)/24000,18):.1f}s", flush=True)
t0 = time.time()
m = TTSModel.load_model(language="german_24l")
print(f"[load] {time.time()-t0:.1f}s sr={m.sample_rate}", flush=True)
t0 = time.time()
vs = m.get_state_for_audio_prompt(ref)
print(f"[clone] {time.time()-t0:.1f}s", flush=True)
SENT = {
"kurz": "Hallo Commander, ich höre dich.",
"mittel":"Guten Morgen, Commander. Das Backup ist sauber durchgelaufen und es gab keine Fehler.",
"lang": "Natürlich kümmere ich mich darum, Commander. Ich starte den Dienst neu, prüfe die Protokolle und melde mich, sobald alles wieder läuft.",
}
for name, text in SENT.items():
for run in ("cold", "warm"):
t0 = time.time()
audio = m.generate_audio(vs, text)
dt = time.time() - t0
a = audio.numpy() if hasattr(audio, "numpy") else np.asarray(audio, dtype=np.float32)
a = np.asarray(a, dtype=np.float32).reshape(-1)
secs = len(a) / m.sample_rate
p = os.path.join(OUT, f"{name}.wav"); sf.write(p, a, m.sample_rate)
print(f"[{name:6} {run:4}] gen={dt:5.2f}s audio={secs:5.2f}s RTF={dt/max(secs,0.01):.2f}", flush=True)
print("=== Whisper ===", flush=True)
from faster_whisper import WhisperModel
wm = WhisperModel("small", device="cpu", compute_type="int8")
import glob
for p in sorted(glob.glob(os.path.join(OUT, "*.wav"))):
segs, _ = wm.transcribe(p, language="de", beam_size=5)
print(os.path.basename(p), "::", " ".join(s.text.strip() for s in segs), flush=True)
print("PTTS_DONE", flush=True)