Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,6 +36,9 @@ def augment_and_extract_features(audio_path, sr=16000, n_mfcc=40, n_fft=2048, ho
|
|
36 |
def predict_voice(audio_file_path):
|
37 |
try:
|
38 |
features_tensor = augment_and_extract_features(audio_file_path)
|
|
|
|
|
|
|
39 |
with torch.no_grad():
|
40 |
outputs = model(features_tensor)
|
41 |
|
@@ -60,3 +63,4 @@ iface = gr.Interface(
|
|
60 |
)
|
61 |
|
62 |
iface.launch()
|
|
|
|
36 |
def predict_voice(audio_file_path):
|
37 |
try:
|
38 |
features_tensor = augment_and_extract_features(audio_file_path)
|
39 |
+
# Reshape tensor to match model input size, avoiding dimension mismatch errors
|
40 |
+
if features_tensor.shape[-1] != model.config.num_labels:
|
41 |
+
features_tensor = torch.nn.functional.interpolate(features_tensor, size=(model.config.num_labels,), mode='linear', align_corners=False)
|
42 |
with torch.no_grad():
|
43 |
outputs = model(features_tensor)
|
44 |
|
|
|
63 |
)
|
64 |
|
65 |
iface.launch()
|
66 |
+
|