#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""对 05 s12/s13 探针候选做 ASR 回读（funasr SenseVoiceSmall, itn）。
声调 ASR 验不了，只看音节/完整/有无吞字；最终由花酱→刚耳检拍板。
"""
import os, glob
from funasr import AutoModel

HERE = r"D:/Download/muse_exchange"
OUT = r"D:/WorkBuddyProd/sci05/probe_s12s13"

sense = AutoModel(model="iic/SenseVoiceSmall", trust_remote_code=True,
                  vad_model="fsmn-vad", vad_kwargs={"max_single_segment_time": 30000},
                  device="cpu", disable_update=True)

for p in sorted(glob.glob(os.path.join(OUT, "*.wav"))):
    name = os.path.basename(p)
    try:
        r = sense.generate(input=p, cache={}, language="zh", use_itn=True)
        txt = r[0]["text"] if r else ""
    except Exception as e:
        txt = "ERR " + str(e)
    print("%-22s ASR='%s'" % (name, txt), flush=True)
