"""Shared pytest fixtures.""" from __future__ import annotations import wave from pathlib import Path import numpy as np import pytest def _write_sine_wav(path: Path, duration: float = 3.0, sr: int = 16000) -> Path: t = np.linspace(0, duration, int(sr * duration), endpoint=False) tone = 0.3 * np.sin(2 * np.pi * 220 * t) ints = (tone * 32767).astype(np.int16) with wave.open(str(path), "wb") as wf: wf.setnchannels(1) wf.setsampwidth(2) wf.setframerate(sr) wf.writeframes(ints.tobytes()) return path @pytest.fixture def sine_wav(tmp_path: Path) -> Path: return _write_sine_wav(tmp_path / "tone.wav") @pytest.fixture def sample_rate() -> int: return 16000