Spaces:
Running
Running
Liangcd
commited on
Commit
·
0d5f907
1
Parent(s):
dbee243
[demo] add vox_res34.onnx and cnc_res34.onnx
Browse files- app.py +14 -9
- pre_model/cnceleb_resnet34.onnx +3 -0
- pre_model/voxceleb_resnet34.onnx +3 -0
app.py
CHANGED
|
@@ -99,10 +99,14 @@ def speaker_verification(audio_path1, audio_path2, lang='CN'):
|
|
| 99 |
if audio_path1 == None or audio_path2 == None:
|
| 100 |
output = OUTPUT_ERROR.format('Please enter two audios')
|
| 101 |
return output
|
| 102 |
-
if lang == '
|
| 103 |
model = OnnxModel('pre_model/voxceleb_resnet34_LM.onnx')
|
| 104 |
-
elif lang == '
|
| 105 |
model = OnnxModel('pre_model/cnceleb_resnet34_LM.onnx')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
else:
|
| 107 |
output = OUTPUT_ERROR.format('Please select a language')
|
| 108 |
return output
|
|
@@ -110,6 +114,7 @@ def speaker_verification(audio_path1, audio_path2, lang='CN'):
|
|
| 110 |
emb2 = model.extract_embedding(audio_path2)
|
| 111 |
cos_score = cosine_similarity(emb1.reshape(1, -1), emb2.reshape(1,
|
| 112 |
-1))[0][0]
|
|
|
|
| 113 |
|
| 114 |
if cos_score >= 0.5:
|
| 115 |
output = OUTPUT_OK.format(cos_score * 100)
|
|
@@ -129,7 +134,7 @@ inputs = [
|
|
| 129 |
type="filepath",
|
| 130 |
optional=True,
|
| 131 |
label='Speaker#2'),
|
| 132 |
-
gr.Radio(['
|
| 133 |
]
|
| 134 |
|
| 135 |
output = gr.outputs.HTML(label="")
|
|
@@ -143,12 +148,12 @@ article = (
|
|
| 143 |
"</p>")
|
| 144 |
|
| 145 |
examples = [
|
| 146 |
-
['examples/BAC009S0764W0228.wav', 'examples/BAC009S0764W0328.wav', '
|
| 147 |
-
['examples/BAC009S0913W0133.wav', 'examples/BAC009S0764W0228.wav', '
|
| 148 |
-
['examples/00001_spk1.wav', 'examples/00003_spk2.wav', '
|
| 149 |
-
['examples/00010_spk2.wav', 'examples/00024_spk1.wav', '
|
| 150 |
-
['examples/00001_spk1.wav', 'examples/00024_spk1.wav', '
|
| 151 |
-
['examples/00010_spk2.wav', 'examples/00003_spk2.wav', '
|
| 152 |
]
|
| 153 |
|
| 154 |
interface = gr.Interface(
|
|
|
|
| 99 |
if audio_path1 == None or audio_path2 == None:
|
| 100 |
output = OUTPUT_ERROR.format('Please enter two audios')
|
| 101 |
return output
|
| 102 |
+
if lang == 'vox_res34_LM':
|
| 103 |
model = OnnxModel('pre_model/voxceleb_resnet34_LM.onnx')
|
| 104 |
+
elif lang == 'cnc_res34_LM':
|
| 105 |
model = OnnxModel('pre_model/cnceleb_resnet34_LM.onnx')
|
| 106 |
+
elif lang == 'vox_res34':
|
| 107 |
+
model = OnnxModel('pre_model/voxceleb_resnet34.onnx')
|
| 108 |
+
elif lang == 'cnc_res34':
|
| 109 |
+
model = OnnxModel('pre_model/cnceleb_resnet34.onnx')
|
| 110 |
else:
|
| 111 |
output = OUTPUT_ERROR.format('Please select a language')
|
| 112 |
return output
|
|
|
|
| 114 |
emb2 = model.extract_embedding(audio_path2)
|
| 115 |
cos_score = cosine_similarity(emb1.reshape(1, -1), emb2.reshape(1,
|
| 116 |
-1))[0][0]
|
| 117 |
+
cos_score = (cos_score + 1) / 2.0
|
| 118 |
|
| 119 |
if cos_score >= 0.5:
|
| 120 |
output = OUTPUT_OK.format(cos_score * 100)
|
|
|
|
| 134 |
type="filepath",
|
| 135 |
optional=True,
|
| 136 |
label='Speaker#2'),
|
| 137 |
+
gr.Radio(['vox_res34_LM', 'vox_res34', 'cnc_res34_LM', 'cnc_res34'], label='Language'),
|
| 138 |
]
|
| 139 |
|
| 140 |
output = gr.outputs.HTML(label="")
|
|
|
|
| 148 |
"</p>")
|
| 149 |
|
| 150 |
examples = [
|
| 151 |
+
['examples/BAC009S0764W0228.wav', 'examples/BAC009S0764W0328.wav', 'cnc_res34'],
|
| 152 |
+
['examples/BAC009S0913W0133.wav', 'examples/BAC009S0764W0228.wav', 'cnc_res34'],
|
| 153 |
+
['examples/00001_spk1.wav', 'examples/00003_spk2.wav', 'vox_res34'],
|
| 154 |
+
['examples/00010_spk2.wav', 'examples/00024_spk1.wav', 'vox_res34_LM'],
|
| 155 |
+
['examples/00001_spk1.wav', 'examples/00024_spk1.wav', 'vox_res34'],
|
| 156 |
+
['examples/00010_spk2.wav', 'examples/00003_spk2.wav', 'vox_res34_LM'],
|
| 157 |
]
|
| 158 |
|
| 159 |
interface = gr.Interface(
|
pre_model/cnceleb_resnet34.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9af662558ff0b5aaa3bd31a4d10c3adc55d9fcdd376b7db6f0fbdaa8a49df31
|
| 3 |
+
size 26530309
|
pre_model/voxceleb_resnet34.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a7f0b7cb467fee82d251d980c47a93dd47387f80be58d389419e0a588338801a
|
| 3 |
+
size 26530309
|