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
2025-01-03 10:37:39 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2025-01-03 10:37:39 +0800
Commit
a4365dad82dc856c73ab9eb90ecf6997451ba5ec
a4365dad
1 parent
a00d3b48
Avoid adding tail padding for VAD in generate-subtitles.py (#1674)
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
10 行增加
和
16 行删除
python-api-examples/generate-subtitles.py
python-api-examples/generate-subtitles.py
查看文件 @
a4365da
...
...
@@ -516,28 +516,22 @@ def main():
is_eof
=
False
# TODO(fangjun): Support multithreads
while
True
:
while
not
is_eof
:
# *2 because int16_t has two bytes
data
=
process
.
stdout
.
read
(
frames_per_read
*
2
)
if
not
data
:
if
is_eof
:
break
vad
.
flush
()
is_eof
=
True
# pad 1 second at the end of the file for the VAD
data
=
np
.
zeros
(
1
*
args
.
sample_rate
,
dtype
=
np
.
int16
)
samples
=
np
.
frombuffer
(
data
,
dtype
=
np
.
int16
)
samples
=
samples
.
astype
(
np
.
float32
)
/
32768
else
:
samples
=
np
.
frombuffer
(
data
,
dtype
=
np
.
int16
)
samples
=
samples
.
astype
(
np
.
float32
)
/
32768
num_processed_samples
+=
samples
.
shape
[
0
]
num_processed_samples
+=
samples
.
shape
[
0
]
buffer
=
np
.
concatenate
([
buffer
,
samples
])
while
len
(
buffer
)
>
window_size
:
vad
.
accept_waveform
(
buffer
[:
window_size
])
buffer
=
buffer
[
window_size
:]
if
is_eof
:
vad
.
flush
()
buffer
=
np
.
concatenate
([
buffer
,
samples
])
while
len
(
buffer
)
>
window_size
:
vad
.
accept_waveform
(
buffer
[:
window_size
])
buffer
=
buffer
[
window_size
:]
streams
=
[]
segments
=
[]
...
...
请
注册
或
登录
后发表评论