szili2011 commited on
Commit
45a8c56
·
verified ·
1 Parent(s): f4ddd28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
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
- # Initialize the encoder (make sure it's fitted to your labels)
13
- # Note: You need to fit the encoder to your actual labels before saving/loading the model
14
- # For example, you can use the same encoder you used during training
 
 
15
  encoder = LabelEncoder()
16
- # Assuming you have a list of labels used during training (e.g., y)
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):