Spaces:
Runtime error
Runtime error
Liangcd
commited on
Commit
·
15307f9
1
Parent(s):
2a2c14b
[demo] support resampling audio
Browse files- app.py +5 -3
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -17,6 +17,8 @@ import json
|
|
| 17 |
import gradio as gr
|
| 18 |
import numpy as np
|
| 19 |
import wenetruntime as wenet
|
|
|
|
|
|
|
| 20 |
|
| 21 |
wenet.set_log_level(2)
|
| 22 |
decoder_cn = wenet.Decoder(lang='chs')
|
|
@@ -26,9 +28,9 @@ def recognition(audio):
|
|
| 26 |
if audio is None:
|
| 27 |
return "Input Error! Please enter one audio!"
|
| 28 |
sr, y = audio
|
| 29 |
-
|
| 30 |
-
if sr
|
| 31 |
-
y =
|
| 32 |
ans = decoder_cn.decode(y.tobytes(), True)
|
| 33 |
if ans is None:
|
| 34 |
return "ERROR! No text output! Please try again!"
|
|
|
|
| 17 |
import gradio as gr
|
| 18 |
import numpy as np
|
| 19 |
import wenetruntime as wenet
|
| 20 |
+
import librosa
|
| 21 |
+
|
| 22 |
|
| 23 |
wenet.set_log_level(2)
|
| 24 |
decoder_cn = wenet.Decoder(lang='chs')
|
|
|
|
| 28 |
if audio is None:
|
| 29 |
return "Input Error! Please enter one audio!"
|
| 30 |
sr, y = audio
|
| 31 |
+
# NOTE: model supports 16k sample_rate
|
| 32 |
+
if sr != 16000:
|
| 33 |
+
y = librosa.resample(y, sr, 16000)
|
| 34 |
ans = decoder_cn.decode(y.tobytes(), True)
|
| 35 |
if ans is None:
|
| 36 |
return "ERROR! No text output! Please try again!"
|
requirements.txt
CHANGED
|
@@ -1,2 +1,3 @@
|
|
| 1 |
wenetruntime
|
| 2 |
gradio
|
|
|
|
|
|
| 1 |
wenetruntime
|
| 2 |
gradio
|
| 3 |
+
librosa
|