Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import pandas as pd
|
|
4 |
|
5 |
## libraries for training dl models
|
6 |
import tensorflow as tf
|
7 |
-
|
8 |
|
9 |
## libraries for reading audio files
|
10 |
import librosa as lib
|
@@ -18,15 +18,15 @@ model = keras.models.load_model('heartbeatsound_classification.h5')
|
|
18 |
|
19 |
def loading_sound_file(sound_file, sr=22050, duration=10):
|
20 |
input_length = sr * duration
|
21 |
-
X, sr =
|
22 |
-
dur =
|
23 |
|
24 |
# pad audio file same duration
|
25 |
if (round(dur) < duration):
|
26 |
print ("fixing audio lenght :", file_name)
|
27 |
-
y =
|
28 |
# extract normalized mfcc feature from data
|
29 |
-
mfccs = np.mean(
|
30 |
|
31 |
data = np.array(mfccs).reshape([-1,1])
|
32 |
|
|
|
4 |
|
5 |
## libraries for training dl models
|
6 |
import tensorflow as tf
|
7 |
+
|
8 |
|
9 |
## libraries for reading audio files
|
10 |
import librosa as lib
|
|
|
18 |
|
19 |
def loading_sound_file(sound_file, sr=22050, duration=10):
|
20 |
input_length = sr * duration
|
21 |
+
X, sr = lib.load(sound_file, sr=sr, duration=duration)
|
22 |
+
dur = lib.get_duration(y=X, sr=sr)
|
23 |
|
24 |
# pad audio file same duration
|
25 |
if (round(dur) < duration):
|
26 |
print ("fixing audio lenght :", file_name)
|
27 |
+
y = lib.util.fix_length(X, input_length)
|
28 |
# extract normalized mfcc feature from data
|
29 |
+
mfccs = np.mean(lib.feature.mfcc(y=X, sr=sr, n_mfcc=25).T,axis=0)
|
30 |
|
31 |
data = np.array(mfccs).reshape([-1,1])
|
32 |
|