Spaces:
Sleeping
Sleeping
Convert all labels to string IDs
Browse files- sonogram.py +12 -0
sonogram.py
CHANGED
|
@@ -129,6 +129,18 @@ class Sonogram():
|
|
| 129 |
diarization[segment] = 'group'
|
| 130 |
|
| 131 |
totalTimeInSeconds = int(waveform.shape[-1]/sample_rate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
print("Time in seconds calculated")
|
| 133 |
return diarization, totalTimeInSeconds, waveform, sample_rate
|
| 134 |
|
|
|
|
| 129 |
diarization[segment] = 'group'
|
| 130 |
|
| 131 |
totalTimeInSeconds = int(waveform.shape[-1]/sample_rate)
|
| 132 |
+
|
| 133 |
+
# Rename labels
|
| 134 |
+
currId = 0
|
| 135 |
+
mapping = {}
|
| 136 |
+
for label in diarization.lables():
|
| 137 |
+
if label == 'group':
|
| 138 |
+
continue
|
| 139 |
+
else:
|
| 140 |
+
currId += 1
|
| 141 |
+
newLabel = f'SPEAKER_{currId:03d}'
|
| 142 |
+
mapping[label] = newLabel
|
| 143 |
+
diarization = diarization.rename_lables(mapping)
|
| 144 |
print("Time in seconds calculated")
|
| 145 |
return diarization, totalTimeInSeconds, waveform, sample_rate
|
| 146 |
|