"""macOS check / reference streaming decode for Shenava Rizeh v1.5 CoreML iOS15 (pip install coremltools numpy). Feeds the stored reference chunks (45 fbank frames each, hop 32 = 320 ms) through the encoder step, threading all caches, greedy RNN-T with the English block masked; prints whether tokens match the onnxruntime reference.""" import json,glob,numpy as np,coremltools as ct import sys;enc=ct.models.MLModel(sys.argv[1] if len(sys.argv)>1 else glob.glob('*encoder_streaming*_fp16.mlmodel')[0]);dec=ct.models.MLModel(glob.glob('*decoder*.mlmodel')[0]);joi=ct.models.MLModel(glob.glob('*joiner*.mlmodel')[0]) man=json.load(open(glob.glob('*_manifest.json')[0]));exp=json.load(open('reference/expected.json',encoding='utf-8')) toks=[l.rstrip('\n').rsplit(' ',1)[0] for l in open('tokens.txt',encoding='utf-8')] names=[k for k in man['inputs'] if k!='x'] state={k:np.zeros(man['inputs'][k],np.int32 if k=='processed_lens' else np.float32) for k in names} mask=np.full(2080,-1e9,np.float32);mask[np.r_[0:32,1056:2080]]=0 ch=np.fromfile('reference/chunks.f32','