Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
sherpaonnx
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Fangjun Kuang
2024-05-24 11:07:44 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-05-24 11:07:44 +0800
Commit
cf83412d0abb373afc9e004bebf4dc2a57f6ac1f
cf83412d
1 parent
e7b73481
Support reading waves from NAudio. (#914)
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
24 行增加
和
0 行删除
sherpa-onnx/csrc/wave-reader.cc
sherpa-onnx/csrc/wave-reader.cc
查看文件 @
cf83412
...
...
@@ -118,6 +118,30 @@ std::vector<float> ReadWaveImpl(std::istream &is, int32_t *sampling_rate,
return
{};
}
if
(
header
.
subchunk1_size
==
18
)
{
// this is for NAudio. It puts extra bytes after bits_per_sample
// See
// https://github.com/naudio/NAudio/blob/master/NAudio.Core/Wave/WaveFormats/WaveFormat.cs#L223
is
.
seekg
(
36
,
std
::
istream
::
beg
);
int16_t
extra_size
=
-
1
;
is
.
read
(
reinterpret_cast
<
char
*>
(
&
extra_size
),
sizeof
(
int16_t
));
if
(
extra_size
!=
0
)
{
SHERPA_ONNX_LOGE
(
"Extra size should be 0 for wave from NAudio. Current extra size "
"%d
\n
"
,
extra_size
);
*
is_ok
=
false
;
return
{};
}
is
.
read
(
reinterpret_cast
<
char
*>
(
&
header
.
subchunk2_id
),
sizeof
(
header
.
subchunk2_id
));
is
.
read
(
reinterpret_cast
<
char
*>
(
&
header
.
subchunk2_size
),
sizeof
(
header
.
subchunk2_size
));
}
header
.
SeekToDataChunk
(
is
);
if
(
!
is
)
{
*
is_ok
=
false
;
...
...
请
注册
或
登录
后发表评论