Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

21 righe
1.4 KiB

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