Spaces:
Sleeping
Sleeping
fixing the load_audio_to_tensor function
Browse files
app.py
CHANGED
|
@@ -10,7 +10,9 @@ model = from_pretrained_keras("CXDJY/snore_ai")
|
|
| 10 |
def load_audio_to_tensor(filename):
|
| 11 |
audio, sampling_rate = librosa.load(filename, sr=None, mono=True) # load audio and convert to mono
|
| 12 |
wave = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000) # resample to 16KHz
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def preprocess_mp3(sample, index):
|
| 16 |
sample = sample[0]
|
|
|
|
| 10 |
def load_audio_to_tensor(filename):
|
| 11 |
audio, sampling_rate = librosa.load(filename, sr=None, mono=True) # load audio and convert to mono
|
| 12 |
wave = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000) # resample to 16KHz
|
| 13 |
+
rms = librosa.feature.rms(y=audio)[0] # get root mean square of audio
|
| 14 |
+
volume = np.mean(rms) # get volume of audio
|
| 15 |
+
return wave, volume
|
| 16 |
|
| 17 |
def preprocess_mp3(sample, index):
|
| 18 |
sample = sample[0]
|