Spaces:
Running
Running
Liangcd
commited on
Commit
•
0e3cd29
1
Parent(s):
0ec8ac1
[demo] update wespeakerruntime version
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
|
16 |
import gradio as gr
|
17 |
import wespeakerruntime as wespeaker
|
18 |
-
from sklearn.metrics.pairwise import cosine_similarity
|
19 |
|
20 |
STYLE = """
|
21 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha256-YvdLHPgkqJ8DVUxjjnGVlMMJtNimJ6dYkowFFvp4kKs=" crossorigin="anonymous">
|
@@ -46,8 +46,8 @@ OUTPUT_ERROR = (STYLE + """
|
|
46 |
</div>
|
47 |
""")
|
48 |
|
49 |
-
vox_model = wespeaker.
|
50 |
-
cnc_model = wespeaker.
|
51 |
|
52 |
|
53 |
def speaker_verification(audio_path1, audio_path2, lang='CN'):
|
@@ -61,10 +61,9 @@ def speaker_verification(audio_path1, audio_path2, lang='CN'):
|
|
61 |
else:
|
62 |
output = OUTPUT_ERROR.format('Please select a language')
|
63 |
return output
|
64 |
-
emb1 = model.
|
65 |
-
emb2 = model.
|
66 |
-
cos_score =
|
67 |
-
-1))[0][0]
|
68 |
cos_score = (cos_score + 1) / 2.0
|
69 |
|
70 |
if cos_score >= 0.70:
|
|
|
15 |
|
16 |
import gradio as gr
|
17 |
import wespeakerruntime as wespeaker
|
18 |
+
# from sklearn.metrics.pairwise import cosine_similarity
|
19 |
|
20 |
STYLE = """
|
21 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha256-YvdLHPgkqJ8DVUxjjnGVlMMJtNimJ6dYkowFFvp4kKs=" crossorigin="anonymous">
|
|
|
46 |
</div>
|
47 |
""")
|
48 |
|
49 |
+
vox_model = wespeaker.Speaker('pre_model/voxceleb_resnet34.onnx')
|
50 |
+
cnc_model = wespeaker.Speaker('pre_model/cnceleb_resnet34.onnx')
|
51 |
|
52 |
|
53 |
def speaker_verification(audio_path1, audio_path2, lang='CN'):
|
|
|
61 |
else:
|
62 |
output = OUTPUT_ERROR.format('Please select a language')
|
63 |
return output
|
64 |
+
emb1 = model.extract_embedding(audio_path1)
|
65 |
+
emb2 = model.extract_embedding(audio_path2)
|
66 |
+
cos_score = model.compute_cosine_score(emb1[0], emb2[0])
|
|
|
67 |
cos_score = (cos_score + 1) / 2.0
|
68 |
|
69 |
if cos_score >= 0.70:
|