Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,17 +4,19 @@ import numpy as np
|
|
4 |
import tensorflow as tf
|
5 |
import gradio as gr
|
6 |
from sklearn.preprocessing import LabelEncoder
|
|
|
7 |
|
8 |
# Load the pre-trained model
|
9 |
model_path = 'sound_to_text_model.h5'
|
10 |
model = tf.keras.models.load_model(model_path)
|
11 |
|
12 |
-
#
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
encoder = LabelEncoder()
|
16 |
-
#
|
17 |
-
# encoder.fit(y) # Uncomment and run this if you haven't already fitted the encoder
|
18 |
|
19 |
# Function to extract features from audio
|
20 |
def extract_features(file_path):
|
|
|
4 |
import tensorflow as tf
|
5 |
import gradio as gr
|
6 |
from sklearn.preprocessing import LabelEncoder
|
7 |
+
import pandas as pd
|
8 |
|
9 |
# Load the pre-trained model
|
10 |
model_path = 'sound_to_text_model.h5'
|
11 |
model = tf.keras.models.load_model(model_path)
|
12 |
|
13 |
+
# Load the labels from labels.csv
|
14 |
+
labels_df = pd.read_csv('labels.csv') # Make sure this path is correct
|
15 |
+
training_labels = labels_df['Label'].tolist() # Assuming the column name is 'Label'
|
16 |
+
|
17 |
+
# Initialize the encoder and fit it to your labels
|
18 |
encoder = LabelEncoder()
|
19 |
+
encoder.fit(training_labels) # Fit the encoder to your labels
|
|
|
20 |
|
21 |
# Function to extract features from audio
|
22 |
def extract_features(file_path):
|