Spaces:
Running
Running
Liangcd
commited on
Commit
·
446aabb
1
Parent(s):
e3b59b4
[demo] support English
Browse files
app.py
CHANGED
@@ -20,7 +20,8 @@ import wenetruntime as wenet
|
|
20 |
import librosa
|
21 |
|
22 |
wenet.set_log_level(2)
|
23 |
-
|
|
|
24 |
|
25 |
|
26 |
def recognition(audio, lang='CN'):
|
@@ -30,9 +31,9 @@ def recognition(audio, lang='CN'):
|
|
30 |
# NOTE: model supports 16k sample_rate
|
31 |
y = (y * (1 << 15)).astype("int16")
|
32 |
if lang == 'CN':
|
33 |
-
ans =
|
34 |
elif lang == 'EN':
|
35 |
-
|
36 |
else:
|
37 |
return "ERROR! Please select a language!"
|
38 |
|
|
|
20 |
import librosa
|
21 |
|
22 |
wenet.set_log_level(2)
|
23 |
+
chs_decoder = wenet.Decoder(lang='chs')
|
24 |
+
en_decoder = wenet.Decoder(lang='en')
|
25 |
|
26 |
|
27 |
def recognition(audio, lang='CN'):
|
|
|
31 |
# NOTE: model supports 16k sample_rate
|
32 |
y = (y * (1 << 15)).astype("int16")
|
33 |
if lang == 'CN':
|
34 |
+
ans = chs_decoder.decode(y.tobytes(), True)
|
35 |
elif lang == 'EN':
|
36 |
+
ans = en_decoder.decode(y.tobytes(), True)
|
37 |
else:
|
38 |
return "ERROR! Please select a language!"
|
39 |
|