Spaces:
Sleeping
Sleeping
Update sonogram_utility.py
Browse files- sonogram_utility.py +17 -0
sonogram_utility.py
CHANGED
|
@@ -140,6 +140,23 @@ def loadAudioTXT(sampleTXT):
|
|
| 140 |
|
| 141 |
return [], prediction
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
def splitIntoTimeSegments(testFile,maxDurationInSeconds=60):
|
| 144 |
|
| 145 |
waveform, sample_rate = torchaudio.load(testFile)
|
|
|
|
| 140 |
|
| 141 |
return [], prediction
|
| 142 |
|
| 143 |
+
def loadAudioCSV(sampleCSV):
|
| 144 |
+
# Read in prediction data
|
| 145 |
+
df = pd.read_csv(sampleCSV)
|
| 146 |
+
|
| 147 |
+
df = df.reset_index() # make sure indexes pair with number of rows
|
| 148 |
+
|
| 149 |
+
# Data in Annotation form, for convenient error rate calculation
|
| 150 |
+
prediction = Annotation(uri=sampleRTTM)
|
| 151 |
+
|
| 152 |
+
for i, row in df.iterrows():
|
| 153 |
+
index = row['Resource']
|
| 154 |
+
start = (row['Start'] - row['Start'].date()).total_seconds()
|
| 155 |
+
end = (row['Finish'] - row['Finish'].date()).total_seconds()
|
| 156 |
+
prediction[Segment(start,end)] = index
|
| 157 |
+
|
| 158 |
+
return [], prediction
|
| 159 |
+
|
| 160 |
def splitIntoTimeSegments(testFile,maxDurationInSeconds=60):
|
| 161 |
|
| 162 |
waveform, sample_rate = torchaudio.load(testFile)
|