Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
a258a34e
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a258a34e
编写于
12月 02, 2021
作者:
H
huangyuxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
revise the convert pcm
上级
2135aeb0
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
17 addition
and
6 deletion
+17
-6
paddlespeech/cli/asr/infer.py
paddlespeech/cli/asr/infer.py
+17
-6
未找到文件。
paddlespeech/cli/asr/infer.py
浏览文件 @
a258a34e
...
@@ -225,19 +225,16 @@ class ASRExecutor(BaseExecutor):
...
@@ -225,19 +225,16 @@ class ASRExecutor(BaseExecutor):
if
self
.
change_format
:
if
self
.
change_format
:
if
audio
.
shape
[
1
]
>=
2
:
if
audio
.
shape
[
1
]
>=
2
:
audio
=
audio
.
mean
(
axis
=
1
)
audio
=
audio
.
mean
(
axis
=
1
,
dtype
=
np
.
int16
)
else
:
else
:
audio
=
audio
[:,
0
]
audio
=
audio
[:,
0
]
# pcm16 -> pcm 32
# pcm16 -> pcm 32
audio
=
audio
.
astype
(
"float32"
)
audio
=
self
.
_pcm16to32
(
audio
)
bits
=
np
.
iinfo
(
np
.
int16
).
bits
audio
=
audio
/
(
2
**
(
bits
-
1
))
audio
=
librosa
.
resample
(
audio
,
audio_sample_rate
,
audio
=
librosa
.
resample
(
audio
,
audio_sample_rate
,
self
.
sample_rate
)
self
.
sample_rate
)
audio_sample_rate
=
self
.
sample_rate
audio_sample_rate
=
self
.
sample_rate
# pcm32 -> pcm 16
# pcm32 -> pcm 16
audio
=
audio
*
(
2
**
(
bits
-
1
))
audio
=
self
.
_pcm32to16
(
audio
)
audio
=
np
.
round
(
audio
).
astype
(
"int16"
)
else
:
else
:
audio
=
audio
[:,
0
]
audio
=
audio
[:,
0
]
...
@@ -312,6 +309,20 @@ class ASRExecutor(BaseExecutor):
...
@@ -312,6 +309,20 @@ class ASRExecutor(BaseExecutor):
"""
"""
return
self
.
_outputs
[
"result"
]
return
self
.
_outputs
[
"result"
]
def
_pcm16to32
(
self
,
audio
):
assert
(
audio
.
dtype
==
np
.
int16
)
audio
=
audio
.
astype
(
"float32"
)
bits
=
np
.
iinfo
(
np
.
int16
).
bits
audio
=
audio
/
(
2
**
(
bits
-
1
))
return
audio
def
_pcm32to16
(
self
,
audio
):
assert
(
audio
.
dtype
==
np
.
float32
)
bits
=
np
.
iinfo
(
np
.
int16
).
bits
audio
=
audio
*
(
2
**
(
bits
-
1
))
audio
=
np
.
round
(
audio
).
astype
(
"int16"
)
return
audio
def
_check
(
self
,
audio_file
:
str
,
sample_rate
:
int
):
def
_check
(
self
,
audio_file
:
str
,
sample_rate
:
int
):
self
.
sample_rate
=
sample_rate
self
.
sample_rate
=
sample_rate
if
self
.
sample_rate
!=
16000
and
self
.
sample_rate
!=
8000
:
if
self
.
sample_rate
!=
16000
and
self
.
sample_rate
!=
8000
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录