fix: made crtl+c work

This commit is contained in:
Honney OC committed 2026-09-13 23:47:51 +00:00
1 parent 4c8ac4f9b7
commit 82f9e6baea
3 files changed
+9 -37

No files matched your search

-29
View File
@@ -1,29 +0,0 @@
"""
Shared waveform cache — avoids re-reading and re-decoding large WAV files
when the same file is loaded multiple times (e.g. sync_audio_test → verify).
"""
from __future__ import annotations
import os
import numpy as np
_cache: dict[tuple[str, int], np.ndarray] = {}
def cached_load_wav(path: str, target_sr: int = 48000) -> tuple[np.ndarray, int]:
"""Load a WAV file with caching. Returns (audio_array, sample_rate)."""
real_path = os.path.realpath(path)
key = (real_path, target_sr)
if key in _cache:
print(f" (cached: {os.path.basename(path)})")
return _cache[key].copy(), target_sr
# Import here to avoid circular imports
from sync_audio import load_wav
data, sr = load_wav(path, target_sr=target_sr)
_cache[key] = data
return data, sr
def clear_cache():
_cache.clear()