Files
livekit-cameras/scripts/bench_enhance.py
T

28 lines
679 B
Python

#!/usr/bin/env python3
"""RTF bench for hop/window speechbrain enhance."""
import sys
import time
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
import numpy as np
from audio_cleanup import AudioCleaner
c = AudioCleaner(mode="force", chunk_s=1.0, hop_s=0.2)
hop = 3200
pcm = (np.random.randn(hop) * 800).astype(np.int16)
for _ in range(8):
c.process(pcm)
n = 50
t0 = time.perf_counter()
for _ in range(n):
c.process(pcm)
dt = time.perf_counter() - t0
audio_s = n * 0.2
rtf = dt / audio_s
print(f"hops={n} wall={dt:.3f}s audio={audio_s:.1f}s rtf={rtf:.3f}")
if rtf > 0.8:
raise SystemExit("RTF too high for 20-way realtime")