#!/usr/bin/env python3 """Exactly one existing local ASR request per task dance; no transcript persistence or verdict.""" import argparse import base64 import hashlib import importlib.util import io import json from pathlib import Path import subprocess import wave ROOT=Path(__file__).resolve().parents[1] spec=importlib.util.spec_from_file_location('pack',ROOT/'scripts/package-avatar-emotion.py') pack=importlib.util.module_from_spec(spec);spec.loader.exec_module(pack) REMOTE=r''' import base64,json,ssl,urllib.request from pathlib import Path import httpx report={'status':'failed','asr_requests':0,'http_attempts':0,'paid_calls':0,'results':[], 'scope':'task-generated music auxiliary ASR only; no actor attribution', 'human_listening':'not_run','actor_no_speech':'not_certified','device':'not_run'} def health(): context=ssl.create_default_context(cafile='/home/gorios-spark-2/lan-voice/.runtime/gateway-cert.pem') opener=urllib.request.build_opener(urllib.request.ProxyHandler({}),urllib.request.HTTPSHandler(context=context)) with opener.open('https://192.168.31.61:5011/health',timeout=5) as response:return json.load(response) try: assert len(inputs)==2 with httpx.Client(timeout=60,trust_env=False) as client: for item in inputs: if health().get('busy'):raise RuntimeError('busy_no_probe') report['http_attempts']+=1 response=client.post('http://192.168.31.61:5001/v1/audio/transcriptions', files={'file':('task-music.wav',base64.b64decode(item['wav']),'audio/wav')}) report['asr_requests']+=1 row={'id':item['id'],'http_status':response.status_code} report['results'].append(row) if response.status_code!=200:raise RuntimeError('asr_http_error') data=response.json();text=data.get('text') if not isinstance(text,str):raise TypeError('asr_text_shape') row.update(text_nonempty=bool(text.strip()),text_length=len(text),model_is_unknown=not bool(data.get('model'))) del text,data,response report['status']='passed_auxiliary_only' except Exception as error: report['error_type']=type(error).__name__ report['reason']='busy_no_probe' if isinstance(error,RuntimeError) and str(error)=='busy_no_probe' else 'auxiliary_probe_failed_no_retry' print(json.dumps(report)) raise SystemExit(0 if report['status']=='passed_auxiliary_only' else 1) ''' def finite_wav(pcm): pack.require(0