Download tests/helpers.py from NabuxAi/buddi-asr-source-code: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/NabuxAi/buddi-asr-source-code/resolve/main/tests/helpers.py
- Command line
-
hf download hf://datasets/NabuxAi/buddi-asr-source-code/tests/helpers.py
-
curl -L -o helpers.py https://huggingface.co/datasets/NabuxAi/buddi-asr-source-code/resolve/main/tests/helpers.py
1.04 kB
| from __future__ import annotations | |
| import wave | |
| from pathlib import Path | |
| from buddi_asr.data.manifest import ManifestRecord | |
| def write_silent_wav(path: Path, *, seconds: float = 0.05, sample_rate: int = 16000) -> None: | |
| path.parent.mkdir(parents=True, exist_ok=True) | |
| frame_count = int(seconds * sample_rate) | |
| with wave.open(str(path), "wb") as audio: | |
| audio.setnchannels(1) | |
| audio.setsampwidth(2) | |
| audio.setframerate(sample_rate) | |
| audio.writeframes(b"\x00\x00" * frame_count) | |
| def record( | |
| index: int, | |
| *, | |
| speaker: str, | |
| text: str = "مرحبا", | |
| source: str = "fixture", | |
| split: str | None = None, | |
| ) -> ManifestRecord: | |
| return ManifestRecord( | |
| audio=f"audio/{index}.wav", | |
| text=text, | |
| language="ar", | |
| dialect="gulf_omani", | |
| age_group="6-8", | |
| speaker_id=speaker, | |
| source=source, | |
| category="conversation", | |
| license="test-only", | |
| split=split, | |
| metadata={"source_file_id": f"file_{index:04d}"}, | |
| ) | |