Download tests/conftest.py from k9cli/video-vec2wav2-tokenizer: direct link, hf CLI and curl.
- Browser
- Download file 728 Bytes
-
https://huggingface.co/datasets/k9cli/video-vec2wav2-tokenizer/resolve/main/tests/conftest.py
- Command line
-
hf download hf://datasets/k9cli/video-vec2wav2-tokenizer/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/datasets/k9cli/video-vec2wav2-tokenizer/resolve/main/tests/conftest.py
728 Bytes
| """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 | |
| def sine_wav(tmp_path: Path) -> Path: | |
| return _write_sine_wav(tmp_path / "tone.wav") | |
| def sample_rate() -> int: | |
| return 16000 | |