Spaces:
Running
Running
user01
commited on
Commit
·
cebdfdb
1
Parent(s):
0e3cd29
[update] cli package
Browse files- app.py +11 -9
- requirements.txt +1 -1
app.py
CHANGED
@@ -14,7 +14,8 @@
|
|
14 |
# limitations under the License.
|
15 |
|
16 |
import gradio as gr
|
17 |
-
import
|
|
|
18 |
# from sklearn.metrics.pairwise import cosine_similarity
|
19 |
|
20 |
STYLE = """
|
@@ -46,8 +47,8 @@ OUTPUT_ERROR = (STYLE + """
|
|
46 |
</div>
|
47 |
""")
|
48 |
|
49 |
-
|
50 |
-
|
51 |
|
52 |
|
53 |
def speaker_verification(audio_path1, audio_path2, lang='CN'):
|
@@ -55,16 +56,17 @@ def speaker_verification(audio_path1, audio_path2, lang='CN'):
|
|
55 |
output = OUTPUT_ERROR.format('Please enter two audios')
|
56 |
return output
|
57 |
if lang == 'EN':
|
58 |
-
model =
|
59 |
elif lang == 'CN':
|
60 |
-
model =
|
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:
|
70 |
output = OUTPUT_OK.format(cos_score * 100)
|
|
|
14 |
# limitations under the License.
|
15 |
|
16 |
import gradio as gr
|
17 |
+
import wespeaker
|
18 |
+
# import wespeakerruntime as wespeaker
|
19 |
# from sklearn.metrics.pairwise import cosine_similarity
|
20 |
|
21 |
STYLE = """
|
|
|
47 |
</div>
|
48 |
""")
|
49 |
|
50 |
+
cn_model = wespeaker.load_model("chinese")
|
51 |
+
en_model = wespeaker.load_model("english")
|
52 |
|
53 |
|
54 |
def speaker_verification(audio_path1, audio_path2, lang='CN'):
|
|
|
56 |
output = OUTPUT_ERROR.format('Please enter two audios')
|
57 |
return output
|
58 |
if lang == 'EN':
|
59 |
+
model = cn_model
|
60 |
elif lang == 'CN':
|
61 |
+
model = en_model
|
62 |
else:
|
63 |
output = OUTPUT_ERROR.format('Please select a language')
|
64 |
return output
|
65 |
+
# emb1 = model.extract_embedding(audio_path1)
|
66 |
+
# emb2 = model.extract_embedding(audio_path2)
|
67 |
+
# cos_score = model.compute_cosine_score(emb1[0], emb2[0])
|
68 |
+
# cos_score = (cos_score + 1) / 2.0
|
69 |
+
cos_score = wespeaker.compute_similarity(audio_path1, audio_path2)
|
70 |
|
71 |
if cos_score >= 0.70:
|
72 |
output = OUTPUT_OK.format(cos_score * 100)
|
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
gradio
|
2 |
-
|
3 |
scikit-learn
|
|
|
1 |
gradio
|
2 |
+
wespeaker @ git+https://github.com/wenet-e2e/wespeaker.git
|
3 |
scikit-learn
|