Spaces:
Sleeping
Sleeping
Added TXT loading
Browse files- sonogram_utility.py +20 -0
sonogram_utility.py
CHANGED
|
@@ -100,6 +100,26 @@ def loadAudioRTTM(sampleRTTM):
|
|
| 100 |
|
| 101 |
return speakerList, prediction
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
def splitIntoTimeSegments(testFile,maxDurationInSeconds=60):
|
| 104 |
|
| 105 |
waveform, sample_rate = torchaudio.load(testFile)
|
|
|
|
| 100 |
|
| 101 |
return speakerList, prediction
|
| 102 |
|
| 103 |
+
def loadAudioTXT(sampleTXT):
|
| 104 |
+
# Read in prediction data
|
| 105 |
+
# Data in list form, for convenient plotting
|
| 106 |
+
speakerList = []
|
| 107 |
+
# Data in Annotation form, for convenient error rate calculation
|
| 108 |
+
prediction = Annotation(uri=sampleTXT)
|
| 109 |
+
with open(sampleTXT, "r") as txt:
|
| 110 |
+
for line in txt:
|
| 111 |
+
speakerResult = line.split('\t')
|
| 112 |
+
print(speakerResult)
|
| 113 |
+
if len(speakerResult) < 3:
|
| 114 |
+
continue
|
| 115 |
+
index = -1
|
| 116 |
+
start = float(speakerResult[0])
|
| 117 |
+
end = float(speakerResult[1])
|
| 118 |
+
duration = end - start
|
| 119 |
+
prediction[Segment(start,end)] = speakerResult[2]
|
| 120 |
+
|
| 121 |
+
return [], prediction
|
| 122 |
+
|
| 123 |
def splitIntoTimeSegments(testFile,maxDurationInSeconds=60):
|
| 124 |
|
| 125 |
waveform, sample_rate = torchaudio.load(testFile)
|