"""The development audio: the Open Yap 1K conversation and offsets every phone test used. Open Yap 1K sample, TheAgenticDataCompany/open-yap-1k on Hugging Face, CC-BY-4.0 (shard-00000.tar and shard-00001.tar in data/openyap). No audio is in this repository. """ from __future__ import annotations import io import json import sys import tarfile from pathlib import Path import numpy as np HERE = Path(__file__).parent sys.path[:0] = [str(HERE), str(HERE.parent)] # vendor/ is one level up from vendor.tyger_s2s.constants import HOP_N # noqa: E402 SHARDS = sorted((HERE / "data" / "openyap").glob("shard-*.tar")) VALIDATION = "conv_f5c0b02f01e2" HOPS, WARMUP, TIMED = 230, 25, 200 USER_S, AGENT_S = 30, 90 def conversations(): """(conversation id, a, b): both channels as 16 kHz float32, cut to whole hops.""" import soundfile from scipy.signal import resample_poly for shard in SHARDS: with tarfile.open(shard) as tf: members = {m.name: m for m in tf.getmembers()} for name in sorted(n for n in members if n.endswith(".json")): key = name[:-len(".json")] meta = json.load(tf.extractfile(members[name])) chans = [] for side in ("a", "b"): x, rate = soundfile.read(io.BytesIO(tf.extractfile(members[f"{key}.{side}.flac"]).read()), dtype="float32", always_2d=True) assert rate == 48000 chans.append(resample_poly(x.mean(1).astype(np.float64), 1, 3).astype(np.float32)) n = min(len(c) for c in chans) // HOP_N * HOP_N yield meta["conversation_id"], chans[0][:n], chans[1][:n] def audio() -> tuple[np.ndarray, np.ndarray]: """230 hops of channel a, 30 s in (the user) and 90 s in (the agent): speech in both.""" for conv, a, _ in conversations(): if conv == VALIDATION: n = HOPS * HOP_N return a[USER_S * 16000:USER_S * 16000 + n], a[AGENT_S * 16000:AGENT_S * 16000 + n] raise SystemExit("validation conversation not found")