Spaces:
Running
Running
Liangcd
commited on
Commit
·
da86ffd
1
Parent(s):
cbdf41c
[demo] remove English
Browse files
app.py
CHANGED
@@ -20,8 +20,6 @@ import librosa
|
|
20 |
|
21 |
wenet.set_log_level(2)
|
22 |
decoder = wenet.Decoder(lang='chs')
|
23 |
-
cur_lang = 'EN'
|
24 |
-
# decoder_en = wenet.Decoder(lang='en')
|
25 |
|
26 |
|
27 |
def recognition(audio, lang='CN'):
|
@@ -30,24 +28,13 @@ def recognition(audio, lang='CN'):
|
|
30 |
y, _ = librosa.load(audio, sr=16000)
|
31 |
# NOTE: model supports 16k sample_rate
|
32 |
y = (y * (1 << 15)).astype("int16")
|
33 |
-
global cur_lang
|
34 |
-
global decoder
|
35 |
if lang == 'CN':
|
36 |
-
if cur_lang != lang:
|
37 |
-
del decoder
|
38 |
-
decoder = wenet.Decoder(lang='chs')
|
39 |
-
cur_lang = 'CN'
|
40 |
ans = decoder.decode(y.tobytes(), True)
|
41 |
elif lang == 'EN':
|
42 |
-
if cur_lang != lang:
|
43 |
-
del decoder
|
44 |
-
decoder = wenet.Decoder(lang='en')
|
45 |
-
cur_lang = 'EN'
|
46 |
-
ans = decoder.decode(y.tobytes(), True)
|
47 |
return "ERROR! English is not supported yet!"
|
48 |
else:
|
49 |
return "ERROR! Please select a language!"
|
50 |
-
|
51 |
if ans is None:
|
52 |
return "ERROR! No text output! Please try again!"
|
53 |
# NOTE: ans (json)
|
|
|
20 |
|
21 |
wenet.set_log_level(2)
|
22 |
decoder = wenet.Decoder(lang='chs')
|
|
|
|
|
23 |
|
24 |
|
25 |
def recognition(audio, lang='CN'):
|
|
|
28 |
y, _ = librosa.load(audio, sr=16000)
|
29 |
# NOTE: model supports 16k sample_rate
|
30 |
y = (y * (1 << 15)).astype("int16")
|
|
|
|
|
31 |
if lang == 'CN':
|
|
|
|
|
|
|
|
|
32 |
ans = decoder.decode(y.tobytes(), True)
|
33 |
elif lang == 'EN':
|
|
|
|
|
|
|
|
|
|
|
34 |
return "ERROR! English is not supported yet!"
|
35 |
else:
|
36 |
return "ERROR! Please select a language!"
|
37 |
+
|
38 |
if ans is None:
|
39 |
return "ERROR! No text output! Please try again!"
|
40 |
# NOTE: ans (json)
|