Spaces:
Running
Running
Liangcd
commited on
Commit
·
6f82c1e
1
Parent(s):
15307f9
[demo] support resampling audio
Browse files
app.py
CHANGED
@@ -30,7 +30,9 @@ def recognition(audio):
|
|
30 |
sr, y = audio
|
31 |
# NOTE: model supports 16k sample_rate
|
32 |
if sr != 16000:
|
33 |
-
y = librosa.resample(y
|
|
|
|
|
34 |
ans = decoder_cn.decode(y.tobytes(), True)
|
35 |
if ans is None:
|
36 |
return "ERROR! No text output! Please try again!"
|
|
|
30 |
sr, y = audio
|
31 |
# NOTE: model supports 16k sample_rate
|
32 |
if sr != 16000:
|
33 |
+
y = librosa.resample((y / max(np.max(y), 1)).astype(np.float),
|
34 |
+
sr, 16000)
|
35 |
+
y = (y * (1 << 15)).astype("int16")
|
36 |
ans = decoder_cn.decode(y.tobytes(), True)
|
37 |
if ans is None:
|
38 |
return "ERROR! No text output! Please try again!"
|