Spaces:
Running
Running
deveix
commited on
Commit
·
95641f9
1
Parent(s):
675cfa2
remove nb
Browse files- app/main.py +9 -9
app/main.py
CHANGED
@@ -183,10 +183,10 @@ async def get_answer(item: Item, token: str = Depends(verify_token)):
|
|
183 |
raise HTTPException(status_code=500, detail=str(e))
|
184 |
|
185 |
# naive bayes
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
|
191 |
# def preprocess_audio(path, save_dir):
|
192 |
# y, sr = librosa.load(path)
|
@@ -333,16 +333,16 @@ async def handle_audio(file: UploadFile = File(...)):
|
|
333 |
# features = extract_features(temp_filename)
|
334 |
print("Extracted Features:", features)
|
335 |
|
336 |
-
# features =
|
337 |
-
# features =
|
338 |
features = np.array(features).reshape(1, -1)
|
339 |
|
340 |
# proceed with an inference
|
341 |
-
results =
|
342 |
-
# decoded_predictions = [
|
343 |
|
344 |
# # Decode the predictions using the label encoder
|
345 |
-
# decoded_predictions =
|
346 |
# .tolist()
|
347 |
# Clean up the temporary file
|
348 |
os.remove(temp_filename)
|
|
|
183 |
raise HTTPException(status_code=500, detail=str(e))
|
184 |
|
185 |
# naive bayes
|
186 |
+
model = joblib.load('app/1713630229.4965415_trained_model.joblib')
|
187 |
+
pca = joblib.load('app/pca.pkl')
|
188 |
+
scaler = joblib.load('app/scaler.pkl')
|
189 |
+
label_encoder = joblib.load('app/label_encoder.pkl')
|
190 |
|
191 |
# def preprocess_audio(path, save_dir):
|
192 |
# y, sr = librosa.load(path)
|
|
|
333 |
# features = extract_features(temp_filename)
|
334 |
print("Extracted Features:", features)
|
335 |
|
336 |
+
# features = scaler.transform(features)
|
337 |
+
# features = pca.transform(features)
|
338 |
features = np.array(features).reshape(1, -1)
|
339 |
|
340 |
# proceed with an inference
|
341 |
+
results = model.predict(features)
|
342 |
+
# decoded_predictions = [label_encoder.classes_[i] for i in results]
|
343 |
|
344 |
# # Decode the predictions using the label encoder
|
345 |
+
# decoded_predictions = label_encoder.inverse_transform(results)
|
346 |
# .tolist()
|
347 |
# Clean up the temporary file
|
348 |
os.remove(temp_filename)
|