|
- """Independent ASR and mux alignment checks for the intro release (resumable)."""
- import importlib.util
- import difflib
- import json
- from pathlib import Path
- spec=importlib.util.spec_from_file_location('quality',Path(__file__).with_name('bridge-narration-quality.py'))
- quality=importlib.util.module_from_spec(spec);spec.loader.exec_module(quality)
- quality.REPORT=Path(__file__).resolve().parents[1]/'reports/bridge-introduction-narration-20260924'
- if __name__=='__main__':
- quality.main()
- path=quality.REPORT/'quality.json';rows=json.loads(path.read_text('utf-8'))
- for row in rows:
- expected,actual=quality.normalize(row['text']),quality.normalize(row['asrText'])
- row['missingPhrases']=[expected[a:b] for tag,a,b,c,d in difflib.SequenceMatcher(None,expected,actual,autojunk=False).get_opcodes()
- if tag!='equal' and b-a>=12 and d-c<(b-a)*.5]
- row['extraPhrases']=[actual[c:d] for tag,a,b,c,d in difflib.SequenceMatcher(None,expected,actual,autojunk=False).get_opcodes()
- if tag!='equal' and d-c>=10 and b-a<(d-c)*.5]
- row['needsTranscriptReview']=row['asrSimilarity']<.85 or bool(row['missingPhrases'] or row['extraPhrases'])
- print(row['key'],'review:',row['needsTranscriptReview'],'missing:',row['missingPhrases'],'extra:',row['extraPhrases'],flush=True)
- temp=path.with_suffix('.review.tmp');temp.write_text(json.dumps(rows,ensure_ascii=False,indent=2),'utf-8');temp.replace(path)
|