"""WAI sink-side neural decoder for `wai.neural.encodec32`. This is the receiving half of the demonstration: a sink that has the EnCodec model installed locally resolves the `wai.neural.encodec32` capability by loading its own model and reconstructing audio from the shipped tokens. The WAI envelope did NOT carry any model bytes. If the sink doesn't have EnCodec installed, the file is inert here (unless the fallback capability is also wired up — out of scope for this single-capability demo). Usage: python tools/wai_encodec_decode.py -o """ from __future__ import annotations import argparse import json import struct import sys import wave from pathlib import Path import numpy as np ENCODEC_DIR = ( "/Volumes/macos_4TB_external/neuronexus_ai/model_library/encodec-32khz" ) def decode(wai_path: str, out_path: str) -> None: raw = Path(wai_path).read_bytes() if raw[:4] != b"WAI1": sys.exit("not a WAI v1 file (magic mismatch)") o = 4 (ml,) = struct.unpack_from("