"""Next Echo inference (NumPy only): find occurrences of an example sound in a recording. Usage: python inference.py --query clap.wav --recording street.wav python inference.py --selftest Audio must be 16 kHz mono 16-bit WAV for the CLI (resample elsewhere if needed). """ import argparse import json import os import sys import wave HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, HERE) import numpy as np # noqa: E402 import echo_core as ec # noqa: E402 from nlrt import load_model as _load # noqa: E402 def load(path=os.path.join(HERE, "model.json")): return ec.load_model(_load(path)) def read_wav(path): with wave.open(path, "rb") as w: assert w.getframerate() == 16000 and w.getnchannels() == 1 and w.getsampwidth() == 2, "need 16 kHz mono 16-bit" return np.frombuffer(w.readframes(w.getnframes()), dtype="