czyoung commited on
Commit
3bd2a42
·
verified ·
1 Parent(s): d1e1561

Update sonogram_utility.py

Browse files
Files changed (1) hide show
  1. sonogram_utility.py +9 -8
sonogram_utility.py CHANGED
@@ -216,25 +216,26 @@ def sumSegments(segmentList):
216
  total += s.duration
217
  return total
218
 
219
- def sumTimes(annotation):
220
- return annotation.get_timeline(False).duration()
221
 
222
- def sumTimesPerSpeaker(timeSlotList):
223
  speakerList = []
224
  timeList = []
225
- for speaker,timeSlot in timeSlotList:
226
  if speaker not in speakerList:
227
  speakerList.append(speaker)
228
  timeList.append(0)
229
- timeList[speakerList.index(speaker)] += timeSlot.duration
230
  return speakerList, timeList
231
 
232
- def sumMultiTimesPerSpeaker(timeSlotList):
233
  speakerList = []
234
  timeList = []
235
- sList,tList = sumTimesPerSpeaker(timeSlotList)
236
  for i,speakerGroup in enumerate(sList):
237
- for speaker in speakerGroup:
 
238
  if speaker not in speakerList:
239
  speakerList.append(speaker)
240
  timeList.append(0)
 
216
  total += s.duration
217
  return total
218
 
219
+ def sumTimes(myAnnotation):
220
+ return myAnnotation.get_timeline(False).duration()
221
 
222
+ def sumTimesPerSpeaker(myAnnotation):
223
  speakerList = []
224
  timeList = []
225
+ for speaker in myAnnotation.labels():
226
  if speaker not in speakerList:
227
  speakerList.append(speaker)
228
  timeList.append(0)
229
+ timeList[speakerList.index(speaker)] += sumTimes(myAnnotation.subset([speaker]))
230
  return speakerList, timeList
231
 
232
+ def sumMultiTimesPerSpeaker(myAnnotation):
233
  speakerList = []
234
  timeList = []
235
+ sList,tList = sumTimesPerSpeaker(myAnnotation)
236
  for i,speakerGroup in enumerate(sList):
237
+ speakerSplit = speakerGroup.split('+')
238
+ for speaker in speakerSplit:
239
  if speaker not in speakerList:
240
  speakerList.append(speaker)
241
  timeList.append(0)