Spaces:
Runtime error
Runtime error
user01
commited on
Commit
·
c98c876
1
Parent(s):
2a6c846
[demo] refine code
Browse files- app.py +0 -10
- packages.txt +0 -1
app.py
CHANGED
@@ -15,11 +15,8 @@
|
|
15 |
|
16 |
import json
|
17 |
import gradio as gr
|
18 |
-
# import torch
|
19 |
import wenet
|
20 |
-
# import librosa
|
21 |
|
22 |
-
# wenet.set_log_level(2)
|
23 |
# TODO: add hotword
|
24 |
chs_model = wenet.load_model('chinese')
|
25 |
en_model = wenet.load_model('english')
|
@@ -28,11 +25,8 @@ en_model = wenet.load_model('english')
|
|
28 |
def recognition(audio, lang='CN'):
|
29 |
if audio is None:
|
30 |
return "Input Error! Please enter one audio!"
|
31 |
-
# y, _ = librosa.load(audio, sr=16000)
|
32 |
# NOTE: model supports 16k sample_rate
|
33 |
-
# y = (y * (1 << 15)).astype("int16")
|
34 |
if lang == 'CN':
|
35 |
-
# ans = chs_decoder.decode(y.tobytes(), True)
|
36 |
ans = chs_model.transcribe(audio)
|
37 |
elif lang == 'EN':
|
38 |
ans = en_model.transcribe(audio)
|
@@ -41,10 +35,6 @@ def recognition(audio, lang='CN'):
|
|
41 |
|
42 |
if ans is None:
|
43 |
return "ERROR! No text output! Please try again!"
|
44 |
-
# NOTE: ans (json)
|
45 |
-
# {
|
46 |
-
# 'nbest' : [{"sentence" : ""}], 'type' : 'final_result
|
47 |
-
# }
|
48 |
txt = ans['text']
|
49 |
return txt
|
50 |
|
|
|
15 |
|
16 |
import json
|
17 |
import gradio as gr
|
|
|
18 |
import wenet
|
|
|
19 |
|
|
|
20 |
# TODO: add hotword
|
21 |
chs_model = wenet.load_model('chinese')
|
22 |
en_model = wenet.load_model('english')
|
|
|
25 |
def recognition(audio, lang='CN'):
|
26 |
if audio is None:
|
27 |
return "Input Error! Please enter one audio!"
|
|
|
28 |
# NOTE: model supports 16k sample_rate
|
|
|
29 |
if lang == 'CN':
|
|
|
30 |
ans = chs_model.transcribe(audio)
|
31 |
elif lang == 'EN':
|
32 |
ans = en_model.transcribe(audio)
|
|
|
35 |
|
36 |
if ans is None:
|
37 |
return "ERROR! No text output! Please try again!"
|
|
|
|
|
|
|
|
|
38 |
txt = ans['text']
|
39 |
return txt
|
40 |
|
packages.txt
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
sox
|
|
|
|