Spaces:
Sleeping
Sleeping
Update tasks/audio.py
Browse files- tasks/audio.py +11 -10
tasks/audio.py
CHANGED
|
@@ -48,6 +48,17 @@ async def evaluate_audio(request: AudioEvaluationRequest):
|
|
| 48 |
train_test = dataset["train"]
|
| 49 |
test_dataset = dataset["test"]
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
def preprocess_data(row, sr):
|
| 52 |
new_row = librosa.resample(row['audio']['array'], orig_sr=row['audio']['sampling_rate'], target_sr=sr)
|
| 53 |
new_row = np.pad(new_row, (0, 3 * sr - len(new_row)), 'constant')
|
|
@@ -59,16 +70,6 @@ async def evaluate_audio(request: AudioEvaluationRequest):
|
|
| 59 |
model_filename = "lightgbm_10_mfcc.pkl"
|
| 60 |
clf = joblib.load(model_filename)
|
| 61 |
|
| 62 |
-
# Start tracking emissions
|
| 63 |
-
tracker.start()
|
| 64 |
-
tracker.start_task("inference")
|
| 65 |
-
|
| 66 |
-
#--------------------------------------------------------------------------------------------
|
| 67 |
-
# YOUR MODEL INFERENCE CODE HERE
|
| 68 |
-
# Update the code below to replace the random baseline by your model inference within the inference pass where the energy consumption and emissions are tracked.
|
| 69 |
-
#--------------------------------------------------------------------------------------------
|
| 70 |
-
|
| 71 |
-
# Make random predictions (placeholder for actual model inference)
|
| 72 |
true_labels = test_dataset["label"]
|
| 73 |
predictions = clf.predict(test_list_mfcc)
|
| 74 |
|
|
|
|
| 48 |
train_test = dataset["train"]
|
| 49 |
test_dataset = dataset["test"]
|
| 50 |
|
| 51 |
+
|
| 52 |
+
# Start tracking emissions
|
| 53 |
+
tracker.start()
|
| 54 |
+
tracker.start_task("inference")
|
| 55 |
+
|
| 56 |
+
#--------------------------------------------------------------------------------------------
|
| 57 |
+
# YOUR MODEL INFERENCE CODE HERE
|
| 58 |
+
# Update the code below to replace the random baseline by your model inference within the inference pass where the energy consumption and emissions are tracked.
|
| 59 |
+
#--------------------------------------------------------------------------------------------
|
| 60 |
+
|
| 61 |
+
|
| 62 |
def preprocess_data(row, sr):
|
| 63 |
new_row = librosa.resample(row['audio']['array'], orig_sr=row['audio']['sampling_rate'], target_sr=sr)
|
| 64 |
new_row = np.pad(new_row, (0, 3 * sr - len(new_row)), 'constant')
|
|
|
|
| 70 |
model_filename = "lightgbm_10_mfcc.pkl"
|
| 71 |
clf = joblib.load(model_filename)
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
true_labels = test_dataset["label"]
|
| 74 |
predictions = clf.predict(test_list_mfcc)
|
| 75 |
|