Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,13 @@ import numpy as np
|
|
5 |
from sklearn.metrics.pairwise import cosine_similarity
|
6 |
import os
|
7 |
|
8 |
-
#
|
9 |
-
|
10 |
|
11 |
-
# Load
|
|
|
|
|
|
|
12 |
speaker_embeddings = {}
|
13 |
for speaker in os.listdir("known_speakers"):
|
14 |
if speaker.endswith(".wav"):
|
@@ -29,7 +32,7 @@ def identify_speaker(audio):
|
|
29 |
|
30 |
return f"π§ Identified Speaker: {best_speaker}\nπ§ͺ Similarity Score: {best_score:.2f}"
|
31 |
|
32 |
-
# Gradio
|
33 |
gr.Interface(
|
34 |
fn=identify_speaker,
|
35 |
inputs=gr.Audio(source="microphone", type="filepath", label="ποΈ Upload or record voice"),
|
|
|
5 |
from sklearn.metrics.pairwise import cosine_similarity
|
6 |
import os
|
7 |
|
8 |
+
# β
Use HF token from Hugging Face Space secrets
|
9 |
+
hf_token = os.getenv("HF_TOKEN")
|
10 |
|
11 |
+
# π Load model with authentication
|
12 |
+
model = Inference("pyannote/embedding", use_auth_token=hf_token, window="whole")
|
13 |
+
|
14 |
+
# π§ Load known speaker embeddings
|
15 |
speaker_embeddings = {}
|
16 |
for speaker in os.listdir("known_speakers"):
|
17 |
if speaker.endswith(".wav"):
|
|
|
32 |
|
33 |
return f"π§ Identified Speaker: {best_speaker}\nπ§ͺ Similarity Score: {best_score:.2f}"
|
34 |
|
35 |
+
# π Launch Gradio UI
|
36 |
gr.Interface(
|
37 |
fn=identify_speaker,
|
38 |
inputs=gr.Audio(source="microphone", type="filepath", label="ποΈ Upload or record voice"),
|