Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,8 @@ vgg16 = models.vgg16(pretrained=True).features
|
|
44 |
def preprocess_single_audio_vgg16(audio_data, sr, vgg16_model, pca_instance):
|
45 |
# Your existing preprocessing code goes here
|
46 |
y= audio_data
|
47 |
-
sr
|
|
|
48 |
mel_spec = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128) # Compute Mel spectrogram
|
49 |
log_mel_spec = librosa.power_to_db(mel_spec, ref=np.max) # Apply log transformation
|
50 |
norm_mel_spec = (log_mel_spec - np.mean(log_mel_spec)) / np.std(log_mel_spec) # Normalize
|
@@ -80,7 +81,7 @@ def predict_language(audio_input):
|
|
80 |
# Load VGG16 model
|
81 |
if isinstance(audio_input, str):
|
82 |
# Load the audio file
|
83 |
-
audio, sr = librosa.load(audio_input, sr=
|
84 |
else:
|
85 |
# Get the sample rate and convert the audio data to float
|
86 |
sr, audio = audio_input
|
|
|
44 |
def preprocess_single_audio_vgg16(audio_data, sr, vgg16_model, pca_instance):
|
45 |
# Your existing preprocessing code goes here
|
46 |
y= audio_data
|
47 |
+
sr=sr
|
48 |
+
# Load audio
|
49 |
mel_spec = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128) # Compute Mel spectrogram
|
50 |
log_mel_spec = librosa.power_to_db(mel_spec, ref=np.max) # Apply log transformation
|
51 |
norm_mel_spec = (log_mel_spec - np.mean(log_mel_spec)) / np.std(log_mel_spec) # Normalize
|
|
|
81 |
# Load VGG16 model
|
82 |
if isinstance(audio_input, str):
|
83 |
# Load the audio file
|
84 |
+
audio, sr = librosa.load(audio_input, sr=22050)
|
85 |
else:
|
86 |
# Get the sample rate and convert the audio data to float
|
87 |
sr, audio = audio_input
|