Spaces:
Sleeping
Sleeping
Update sonogram_utility.py
Browse files- 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(
|
| 220 |
-
return
|
| 221 |
|
| 222 |
-
def sumTimesPerSpeaker(
|
| 223 |
speakerList = []
|
| 224 |
timeList = []
|
| 225 |
-
for speaker
|
| 226 |
if speaker not in speakerList:
|
| 227 |
speakerList.append(speaker)
|
| 228 |
timeList.append(0)
|
| 229 |
-
timeList[speakerList.index(speaker)] +=
|
| 230 |
return speakerList, timeList
|
| 231 |
|
| 232 |
-
def sumMultiTimesPerSpeaker(
|
| 233 |
speakerList = []
|
| 234 |
timeList = []
|
| 235 |
-
sList,tList = sumTimesPerSpeaker(
|
| 236 |
for i,speakerGroup in enumerate(sList):
|
| 237 |
-
|
|
|
|
| 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)
|