duongthienz commited on
Commit
e194377
·
verified ·
1 Parent(s): 37dca06

Update state.py

Browse files
Files changed (1) hide show
  1. state.py +14 -1
state.py CHANGED
@@ -604,7 +604,20 @@ def analyze(inFileName):
604
  printV("Loaded results", 4)
605
 
606
  pipeline = st.session_state.pipeline
607
- noVoice, oneVoice, multiVoice = su.calcSpeakingTypes(pipeline,currAnnotation, currTotalTime)
 
 
 
 
 
 
 
 
 
 
 
 
 
608
  sumNoVoice = su.sumTimes(noVoice)
609
  sumOneVoice = su.sumTimes(oneVoice)
610
  sumMultiVoice = su.sumTimes(multiVoice)
 
604
  printV("Loaded results", 4)
605
 
606
  pipeline = st.session_state.pipeline
607
+ try:
608
+ noVoice, oneVoice, multiVoice = su.calcSpeakingTypes(pipeline, currAnnotation, currTotalTime)
609
+ except Exception as e:
610
+ print(f"calcSpeakingTypes failed ({e}), falling back to annotation-based voice split")
611
+ # Fall back: build a clean annotation containing only properly named
612
+ # speakers (non-None, non-empty) so build_df5 never receives None labels.
613
+ from pyannote.core import Annotation
614
+ noVoice = Annotation()
615
+ multiVoice = Annotation()
616
+ oneVoice = Annotation()
617
+ for label in currAnnotation.labels():
618
+ if label is not None and str(label).strip() != "":
619
+ for seg in currAnnotation.subset([label]).itersegments():
620
+ oneVoice[seg] = label
621
  sumNoVoice = su.sumTimes(noVoice)
622
  sumOneVoice = su.sumTimes(oneVoice)
623
  sumMultiVoice = su.sumTimes(multiVoice)