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

Fix an issue where None speaker label can cause sunburst and treemap charts unbuildable

Browse files

Plotly's sunburst and treemap require all ids to be non-null strings. But calcSpeakingTypes in sonogram_utility.py is producing it. Fix update to filter the None speaker.

Files changed (1) hide show
  1. utils.py +13 -0
utils.py CHANGED
@@ -168,6 +168,19 @@ def build_df5(oneVoice, multiVoice, sumNoVoice, sumOneVoice, sumMultiVoice, curr
168
  multiSpeakerList = list(multiSpeakerList) if multiSpeakerList else []
169
  multiTimeList = list(multiTimeList) if multiTimeList else []
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  summativeMulti = sum(multiTimeList) if multiTimeList else 1
172
  safeOneVoice = sumOneVoice if sumOneVoice > 0 else 1
173
 
 
168
  multiSpeakerList = list(multiSpeakerList) if multiSpeakerList else []
169
  multiTimeList = list(multiTimeList) if multiTimeList else []
170
 
171
+ # Filter out None/empty speaker labels — these come from annotationToNoiseList
172
+ # when a time window has no identified speaker. Plotly silently drops or
173
+ # crashes on None ids, causing the entire chart to disappear.
174
+ ov_pairs = [(s, t) for s, t in zip(speakerList, timeList)
175
+ if s is not None and str(s).strip() != ""]
176
+ speakerList = [p[0] for p in ov_pairs]
177
+ timeList = [p[1] for p in ov_pairs]
178
+
179
+ mv_pairs = [(s, t) for s, t in zip(multiSpeakerList, multiTimeList)
180
+ if s is not None and str(s).strip() != ""]
181
+ multiSpeakerList = [p[0] for p in mv_pairs]
182
+ multiTimeList = [p[1] for p in mv_pairs]
183
+
184
  summativeMulti = sum(multiTimeList) if multiTimeList else 1
185
  safeOneVoice = sumOneVoice if sumOneVoice > 0 else 1
186