Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ model = load_model('voice_authentication_model.keras') # Replace with your mode
|
|
| 11 |
def predict_user_or_non_user(audio):
|
| 12 |
try:
|
| 13 |
# Load the audio file using librosa
|
| 14 |
-
y, sr = librosa.load(audio, sr=
|
| 15 |
|
| 16 |
# Optional: Normalize the audio volume (if necessary)
|
| 17 |
y = librosa.util.normalize(y)
|
|
@@ -31,7 +31,7 @@ def predict_user_or_non_user(audio):
|
|
| 31 |
|
| 32 |
# Apply thresholding based on the raw prediction value
|
| 33 |
# If the model outputs a probability, try adjusting the threshold (e.g., 0.6 instead of 0.5)
|
| 34 |
-
if prediction[0] > 0.
|
| 35 |
return "User"
|
| 36 |
else:
|
| 37 |
return "Non-User"
|
|
|
|
| 11 |
def predict_user_or_non_user(audio):
|
| 12 |
try:
|
| 13 |
# Load the audio file using librosa
|
| 14 |
+
y, sr = librosa.load(audio, sr=16000) # sr=None to keep the original sampling rate
|
| 15 |
|
| 16 |
# Optional: Normalize the audio volume (if necessary)
|
| 17 |
y = librosa.util.normalize(y)
|
|
|
|
| 31 |
|
| 32 |
# Apply thresholding based on the raw prediction value
|
| 33 |
# If the model outputs a probability, try adjusting the threshold (e.g., 0.6 instead of 0.5)
|
| 34 |
+
if prediction[0] > 0.5:
|
| 35 |
return "User"
|
| 36 |
else:
|
| 37 |
return "Non-User"
|