09a1c98514
- 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>
41 lines
1.9 KiB
Python
41 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Letzter Schliff: lsd6 + ref18, temp 0.70 vs 0.90 auf ALLEN Längen (inkl. lang)."""
|
|
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 = r"C:\Users\TobisPC\Desktop\lucy_temp_final"; os.makedirs(OUT, exist_ok=True)
|
|
src, _ = librosa.load(os.path.join(BASE, "ref.mp3"), sr=24000, mono=True)
|
|
srt, _ = librosa.effects.trim(src, top_db=30); ref = os.path.join(BASE, "ref.wav")
|
|
sf.write(ref, srt[:int(18*24000)], 24000)
|
|
|
|
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.",
|
|
}
|
|
def cleanup_v2(a, sr):
|
|
a = np.asarray(a, dtype=np.float32).reshape(-1)
|
|
if a.size == 0: return a
|
|
peak = float(np.max(np.abs(a)))
|
|
if peak > 0: a = a*(0.95/peak)
|
|
yt,_ = librosa.effects.trim(a, top_db=45); a = yt if yt.size else a
|
|
fi = min(int(0.01*sr), a.size//2)
|
|
if fi>0:
|
|
a[:fi]*=np.linspace(0.,1.,fi,dtype=np.float32); a[-fi:]*=np.linspace(1.,0.,fi,dtype=np.float32)
|
|
pad = np.zeros(int(0.09*sr),dtype=np.float32)
|
|
return np.concatenate([pad,a,pad])
|
|
|
|
for temp in [0.70, 0.90]:
|
|
m = TTSModel.load_model(language="german_24l", lsd_decode_steps=6, temp=temp)
|
|
vs = m.get_state_for_audio_prompt(ref); sr = m.sample_rate
|
|
tag = f"t{int(temp*100):03d}"
|
|
print(f"== temp={temp} ==", flush=True)
|
|
for name, text in SENT.items():
|
|
a = m.generate_audio(vs, text, frames_after_eos=4)
|
|
a = a.numpy() if hasattr(a,"numpy") else np.asarray(a)
|
|
a = cleanup_v2(a, sr)
|
|
sf.write(os.path.join(OUT, f"{tag}_{name}.wav"), a, sr)
|
|
print(f" {name}", flush=True)
|
|
print("TEMP_FINAL_DONE", flush=True)
|