Byte-parity with pyannote-PyTorch reference (cosine 0.763718 identical at 6 decimals on 200 cross-window slot pairs). 2.5x faster than pyannote-MPS on Apple Silicon native. Extracted from gitea.tavportal.com/olivier/MLX_CONVERTOR commit 5f9eafa.
17 lines
554 B
Python
17 lines
554 B
Python
from pyannote_diarization_3_1_mlx._window import sliding_windows
|
|
import numpy as np
|
|
|
|
|
|
def test_sliding_windows_full_coverage():
|
|
sr = 16000
|
|
audio = np.zeros(int(25 * sr), dtype=np.float32)
|
|
windows = list(sliding_windows(audio, sr=sr, duration_s=10.0, hop_s=1.0))
|
|
# Expect (25-10)/1 + 1 = 16 windows, all 10 s long
|
|
assert len(windows) == 16
|
|
for start, end, slice_ in windows:
|
|
assert end - start == 10.0
|
|
assert len(slice_) == 10 * sr
|
|
# boundaries
|
|
assert windows[0][0] == 0.0
|
|
assert windows[-1][1] == 25.0
|