sancho10 commited on
Commit
aa1b4d1
·
verified ·
1 Parent(s): 849911b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -3,7 +3,6 @@ import numpy as np
3
  import tensorflow as tf
4
  import librosa
5
  import librosa.util
6
- import pickle
7
  from sklearn.preprocessing import LabelEncoder
8
 
9
  # Feature extraction function
@@ -43,9 +42,20 @@ def predict_class(file_path, model, label_encoder):
43
  # Load the pre-trained model
44
  model = tf.keras.models.load_model("voice_classification_modelm.h5")
45
 
46
- # Load the label encoder
47
- with open("label_encoder.pkl", "rb") as f:
48
- label_encoder = pickle.load(f)
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  # Define the Gradio function
51
  def classify_audio(audio_file):
 
3
  import tensorflow as tf
4
  import librosa
5
  import librosa.util
 
6
  from sklearn.preprocessing import LabelEncoder
7
 
8
  # Feature extraction function
 
42
  # Load the pre-trained model
43
  model = tf.keras.models.load_model("voice_classification_modelm.h5")
44
 
45
+ # Define the class labels (same as used during training)
46
+ class_labels = [
47
+ "all_vowels_healthy",
48
+ "allvowels_functional",
49
+ "allvowels_laryngitis",
50
+ "allvowels_lukoplakia",
51
+ "allvowels_psychogenic",
52
+ "allvowels_rlnp",
53
+ "allvowels_sd"
54
+ ]
55
+
56
+ # Initialize the LabelEncoder
57
+ label_encoder = LabelEncoder()
58
+ label_encoder.fit(class_labels)
59
 
60
  # Define the Gradio function
61
  def classify_audio(audio_file):