czyoung commited on
Commit
612bfe6
·
verified ·
1 Parent(s): eec853e

Update sonogram_utility.py

Browse files
Files changed (1) hide show
  1. sonogram_utility.py +23 -0
sonogram_utility.py CHANGED
@@ -339,7 +339,30 @@ def annotationToDataFrame(myAnnotation):
339
  df = pd.DataFrame(dataList)
340
  return df, timeSummary
341
 
 
 
 
 
 
 
 
 
342
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
 
344
  def calcCategories(myAnnotation,categories):
345
  categorySlots = []
 
339
  df = pd.DataFrame(dataList)
340
  return df, timeSummary
341
 
342
+ def annotationToSimpleDataFrame(myAnnotation):
343
+ dataList = []
344
+ speakerDict = {}
345
+ for currSpeaker in myAnnotation.labels():
346
+ if currSpeaker not in speakerDict.keys():
347
+ speakerDict[currSpeaker] = []
348
+ for currSegment in myAnnotation.subset([currSpeaker]).itersegments():
349
+ speakerDict[currSpeaker].append(currSegment)
350
 
351
+ timeSummary = {}
352
+ for key in speakerDict.keys():
353
+ if key not in timeSummary.keys():
354
+ timeSummary[key] = 0
355
+ for speakingSegment in speakerDict[key]:
356
+ timeSummary[key] += speakingSegment.duration
357
+
358
+ for key in speakerDict.keys():
359
+ for k, speakingSegment in enumerate(speakerDict[key]):
360
+ speakerName = key
361
+ startPoint = speakingSegment.start
362
+ endPoint = speakingSegment.end
363
+ dataList.append(dict(Task=speakerName + f".{k}", Start=startPoint, Finish=endPoint, Resource=speakerName))
364
+ df = pd.DataFrame(dataList)
365
+ return df, timeSummary
366
 
367
  def calcCategories(myAnnotation,categories):
368
  categorySlots = []