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-03-11 11:05:42 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-03-11 11:05:42 +0800
Commit
44d0ef9ae3f0a2576bfc28278e5b6c470f01b4e5
44d0ef9a
1 parent
f43139e8
Print the time about the first message in tts. (#655)
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
13 行增加
和
3 行删除
python-api-examples/offline-tts-play.py
python-api-examples/offline-tts-play.py
查看文件 @
44d0ef9
...
...
@@ -180,6 +180,8 @@ sample_rate = None
event
=
threading
.
Event
()
first_message_time
=
None
def
generated_audio_callback
(
samples
:
np
.
ndarray
):
"""This function is called whenever max_num_sentences sentences
...
...
@@ -191,6 +193,10 @@ def generated_audio_callback(samples: np.ndarray):
samples:
A 1-D np.float32 array containing audio samples
"""
global
first_message_time
if
first_message_time
is
None
:
first_message_time
=
time
.
time
()
buffer
.
put
(
samples
)
global
started
...
...
@@ -297,14 +303,14 @@ def main():
play_back_thread
.
start
()
logging
.
info
(
"Start generating ..."
)
start
=
time
.
time
()
start
_time
=
time
.
time
()
audio
=
tts
.
generate
(
args
.
text
,
sid
=
args
.
sid
,
speed
=
args
.
speed
,
callback
=
generated_audio_callback
,
)
end
=
time
.
time
()
end
_time
=
time
.
time
()
logging
.
info
(
"Finished generating!"
)
global
stopped
stopped
=
True
...
...
@@ -316,7 +322,7 @@ def main():
play_back_thread
.
join
()
return
elapsed_seconds
=
end
-
start
elapsed_seconds
=
end
_time
-
start_time
audio_duration
=
len
(
audio
.
samples
)
/
audio
.
sample_rate
real_time_factor
=
elapsed_seconds
/
audio_duration
...
...
@@ -327,6 +333,10 @@ def main():
subtype
=
"PCM_16"
,
)
logging
.
info
(
f
"The text is '{args.text}'"
)
logging
.
info
(
"Time in seconds to receive the first "
f
"message: {first_message_time-start_time:.3f}"
)
logging
.
info
(
f
"Elapsed seconds: {elapsed_seconds:.3f}"
)
logging
.
info
(
f
"Audio duration in seconds: {audio_duration:.3f}"
)
logging
.
info
(
...
...
请
注册
或
登录
后发表评论