File size: 1,039 Bytes
f4931e8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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}"},
)
|