Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update sonogram_utility.py
Browse files- sonogram_utility.py +3 -2
sonogram_utility.py
CHANGED
|
@@ -3,6 +3,7 @@ import random
|
|
| 3 |
import copy
|
| 4 |
from pyannote.core import Annotation, Segment
|
| 5 |
import numpy as np
|
|
|
|
| 6 |
import torch
|
| 7 |
import torchaudio
|
| 8 |
import pandas as pd
|
|
@@ -158,8 +159,8 @@ def loadAudioCSV(sampleCSV):
|
|
| 158 |
return [], prediction
|
| 159 |
|
| 160 |
def splitIntoTimeSegments(testFile,maxDurationInSeconds=60):
|
| 161 |
-
|
| 162 |
-
waveform
|
| 163 |
audioSegments = []
|
| 164 |
|
| 165 |
outOfBoundsIndex = waveform.shape[-1]
|
|
|
|
| 3 |
import copy
|
| 4 |
from pyannote.core import Annotation, Segment
|
| 5 |
import numpy as np
|
| 6 |
+
import soundfield as sf
|
| 7 |
import torch
|
| 8 |
import torchaudio
|
| 9 |
import pandas as pd
|
|
|
|
| 159 |
return [], prediction
|
| 160 |
|
| 161 |
def splitIntoTimeSegments(testFile,maxDurationInSeconds=60):
|
| 162 |
+
data, sample_rate = sf.read(testFile, dtype="float32", always_2d=True)
|
| 163 |
+
waveform = torch.from_numpy(data.T) # shape: [channels, samples]
|
| 164 |
audioSegments = []
|
| 165 |
|
| 166 |
outOfBoundsIndex = waveform.shape[-1]
|