Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
3301c53a
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看板
提交
3301c53a
编写于
7月 05, 2022
作者:
Y
Yang Zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add pitch
上级
cc277d09
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
5 deletion
+89
-5
paddlespeech/audio/src/pybind/kaldi/kaldi_feature.cc
paddlespeech/audio/src/pybind/kaldi/kaldi_feature.cc
+67
-0
paddlespeech/audio/src/pybind/kaldi/kaldi_feature.h
paddlespeech/audio/src/pybind/kaldi/kaldi_feature.h
+22
-1
paddlespeech/audio/src/pybind/kaldi/kaldi_feature_wrapper.cc
paddlespeech/audio/src/pybind/kaldi/kaldi_feature_wrapper.cc
+0
-4
未找到文件。
paddlespeech/audio/src/pybind/kaldi/kaldi_feature.cc
浏览文件 @
3301c53a
...
...
@@ -13,6 +13,7 @@
// limitations under the License.
#include "paddlespeech/audio/src/pybind/kaldi/kaldi_feature.h"
#include "feat/pitch-functions.h"
namespace
paddleaudio
{
namespace
kaldi
{
...
...
@@ -145,5 +146,71 @@ void ResetFbank() {
paddleaudio
::
kaldi
::
KaldiFeatureWrapper
::
GetInstance
()
->
ResetFbank
();
}
py
::
array_t
<
double
>
ComputeKaldiPitch
(
int
samp_freq
,
float
frame_shift_ms
,
float
frame_length_ms
,
float
preemph_coeff
,
int
min_f0
,
int
max_f0
,
float
soft_min_f0
,
float
penalty_factor
,
int
lowpass_cutoff
,
int
resample_freq
,
float
delta_pitch
,
int
nccf_ballast
,
int
lowpass_filter_width
,
int
upsample_filter_width
,
int
max_frames_latency
,
int
frames_per_chunk
,
bool
simulate_first_pass_online
,
int
recompute_frame
,
bool
nccf_ballast_online
,
bool
snip_edges
,
const
py
::
array_t
<
double
>&
wav
)
{
::
kaldi
::
PitchExtractionOptions
opts
;
opts
.
samp_freq
=
samp_freq
;
opts
.
frame_shift_ms
=
frame_shift_ms
;
opts
.
frame_length_ms
=
frame_length_ms
;
opts
.
preemph_coeff
=
preemph_coeff
;
opts
.
min_f0
=
min_f0
;
opts
.
max_f0
=
max_f0
;
opts
.
soft_min_f0
=
soft_min_f0
;
opts
.
penalty_factor
=
penalty_factor
;
opts
.
lowpass_cutoff
=
lowpass_cutoff
;
opts
.
resample_freq
=
resample_freq
;
opts
.
delta_pitch
=
delta_pitch
;
opts
.
nccf_ballast
=
nccf_ballast
;
opts
.
lowpass_filter_width
=
lowpass_filter_width
;
opts
.
upsample_filter_width
=
upsample_filter_width
;
opts
.
max_frames_latency
=
max_frames_latency
;
opts
.
frames_per_chunk
=
frames_per_chunk
;
opts
.
simulate_first_pass_online
=
simulate_first_pass_online
;
opts
.
recompute_frame
=
recompute_frame
;
opts
.
nccf_ballast_online
=
nccf_ballast_online
;
opts
.
snip_edges
=
snip_edges
;
py
::
buffer_info
info
=
wav
.
request
();
kaldi
::
Vector
<::
kaldi
::
BaseFloat
>
input_wav
(
info
.
size
);
double
*
wav_ptr
=
(
double
*
)
info
.
ptr
;
for
(
int
idx
=
0
;
idx
<
info
.
size
;
++
idx
)
{
input_wav
(
idx
)
=
*
wav_ptr
;
wav_ptr
++
;
}
kaldi
::
Matrix
<
kaldi
::
BaseFloat
>
features
;
kaldi
::
ComputeKaldiPitch
(
opts
,
input_wav
,
&
features
);
auto
result
=
py
::
array_t
<
double
>
({
features
.
NumRows
(),
features
.
NumCols
()});
for
(
int
row_idx
=
0
;
row_idx
<
features
.
NumRows
();
++
row_idx
)
{
for
(
int
col_idx
=
0
;
col_idx
<
features
.
NumCols
();
++
col_idx
)
{
result
.
mutable_at
(
row_idx
,
col_idx
)
=
features
(
row_idx
,
col_idx
);
}
}
return
result
;
}
}
// namespace kaldi
}
// namespace paddleaudio
paddlespeech/audio/src/pybind/kaldi/kaldi_feature.h
浏览文件 @
3301c53a
...
...
@@ -87,7 +87,28 @@ void ResetFbank();
py
::
array_t
<
double
>
ComputeFbankStreaming
(
const
py
::
array_t
<
double
>&
wav
);
py
::
array_t
<
double
>
TestFun
(
const
py
::
array_t
<
double
>&
wav
);
py
::
array_t
<
double
>
ComputeKaldiPitch
(
int
samp_freq
,
float
frame_shift_ms
,
float
frame_length_ms
,
float
preemph_coeff
,
int
min_f0
,
int
max_f0
,
float
soft_min_f0
,
float
penalty_factor
,
int
lowpass_cutoff
,
int
resample_freq
,
float
delta_pitch
,
int
nccf_ballast
,
int
lowpass_filter_width
,
int
upsample_filter_width
,
int
max_frames_latency
,
int
frames_per_chunk
,
bool
simulate_first_pass_online
,
int
recompute_frame
,
bool
nccf_ballast_online
,
bool
snip_edges
,
const
py
::
array_t
<
double
>&
wav
);
}
// namespace kaldi
}
// namespace paddleaudio
paddlespeech/audio/src/pybind/kaldi/kaldi_feature_wrapper.cc
浏览文件 @
3301c53a
...
...
@@ -43,10 +43,6 @@ py::array_t<double> KaldiFeatureWrapper::ComputeFbank(
if
(
flag
==
false
||
feats
.
Dim
()
==
0
)
return
py
::
array_t
<
double
>
();
auto
result
=
py
::
array_t
<
double
>
(
feats
.
Dim
());
py
::
buffer_info
xs
=
result
.
request
();
for
(
int
idx
=
0
;
idx
<
10
;
++
idx
)
{
float
val
=
feats
(
idx
);
std
::
cout
<<
val
<<
" "
;
}
std
::
cout
<<
std
::
endl
;
double
*
res_ptr
=
(
double
*
)
xs
.
ptr
;
for
(
int
idx
=
0
;
idx
<
feats
.
Dim
();
++
idx
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录