Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
f86f1a6b
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
12 个月 前同步成功
通知
204
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f86f1a6b
编写于
4月 21, 2022
作者:
L
lym0302
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test code, test=doc
上级
e398fe9c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
188 addition
and
0 deletion
+188
-0
tests/unit/server/online/tts/check_server/change_yaml.py
tests/unit/server/online/tts/check_server/change_yaml.py
+0
-0
tests/unit/server/online/tts/check_server/conf/application.yaml
...unit/server/online/tts/check_server/conf/application.yaml
+0
-0
tests/unit/server/online/tts/check_server/http_client.py
tests/unit/server/online/tts/check_server/http_client.py
+0
-0
tests/unit/server/online/tts/check_server/test.sh
tests/unit/server/online/tts/check_server/test.sh
+0
-0
tests/unit/server/online/tts/check_server/test_all.sh
tests/unit/server/online/tts/check_server/test_all.sh
+0
-0
tests/unit/server/online/tts/check_server/tts_online_application.yaml
...erver/online/tts/check_server/tts_online_application.yaml
+0
-0
tests/unit/server/online/tts/check_server/ws_client.py
tests/unit/server/online/tts/check_server/ws_client.py
+0
-0
tests/unit/server/online/tts/test_server/test_http_client.py
tests/unit/server/online/tts/test_server/test_http_client.py
+188
-0
未找到文件。
tests/unit/server/online/tts/change_yaml.py
→
tests/unit/server/online/tts/ch
eck_server/ch
ange_yaml.py
浏览文件 @
f86f1a6b
文件已移动
tests/unit/server/online/tts/conf/application.yaml
→
tests/unit/server/online/tts/c
heck_server/c
onf/application.yaml
浏览文件 @
f86f1a6b
文件已移动
tests/unit/server/online/tts/http_client.py
→
tests/unit/server/online/tts/
check_server/
http_client.py
浏览文件 @
f86f1a6b
文件已移动
tests/unit/server/online/tts/test.sh
→
tests/unit/server/online/tts/
check_server/
test.sh
浏览文件 @
f86f1a6b
文件已移动
tests/unit/server/online/tts/test_all.sh
→
tests/unit/server/online/tts/
check_server/
test_all.sh
浏览文件 @
f86f1a6b
文件已移动
tests/unit/server/online/tts/tts_online_application.yaml
→
tests/unit/server/online/tts/
check_server/
tts_online_application.yaml
浏览文件 @
f86f1a6b
文件已移动
tests/unit/server/online/tts/ws_client.py
→
tests/unit/server/online/tts/
check_server/
ws_client.py
浏览文件 @
f86f1a6b
文件已移动
tests/unit/server/online/tts/test_server/test_http_client.py
0 → 100644
浏览文件 @
f86f1a6b
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
argparse
import
base64
import
json
import
os
import
time
import
requests
from
paddlespeech.server.utils.audio_process
import
pcm2wav
from
paddlespeech.t2s.exps.syn_utils
import
get_sentences
def
save_audio
(
buffer
,
audio_path
)
->
bool
:
if
audio_path
.
endswith
(
"pcm"
):
with
open
(
audio_path
,
"wb"
)
as
f
:
f
.
write
(
buffer
)
elif
audio_path
.
endswith
(
"wav"
):
with
open
(
"./tmp.pcm"
,
"wb"
)
as
f
:
f
.
write
(
buffer
)
pcm2wav
(
"./tmp.pcm"
,
audio_path
,
channels
=
1
,
bits
=
16
,
sample_rate
=
24000
)
os
.
system
(
"rm ./tmp.pcm"
)
else
:
print
(
"Only supports saved audio format is pcm or wav"
)
return
False
return
True
def
test
(
args
,
text
,
utt_id
):
params
=
{
"text"
:
text
,
"spk_id"
:
args
.
spk_id
,
"speed"
:
args
.
speed
,
"volume"
:
args
.
volume
,
"sample_rate"
:
args
.
sample_rate
,
"save_path"
:
''
}
buffer
=
b
''
flag
=
1
url
=
"http://"
+
str
(
args
.
server
)
+
":"
+
str
(
args
.
port
)
+
"/paddlespeech/streaming/tts"
st
=
time
.
time
()
html
=
requests
.
post
(
url
,
json
.
dumps
(
params
),
stream
=
True
)
for
chunk
in
html
.
iter_content
(
chunk_size
=
1024
):
chunk
=
base64
.
b64decode
(
chunk
)
# bytes
if
flag
:
first_response
=
time
.
time
()
-
st
print
(
f
"首包响应:
{
first_response
}
s"
)
flag
=
0
buffer
+=
chunk
final_response
=
time
.
time
()
-
st
duration
=
len
(
buffer
)
/
2.0
/
24000
print
(
f
"sentence:
{
text
}
"
)
print
(
f
"尾包响应:
{
final_response
}
s"
)
print
(
f
"音频时长:
{
duration
}
s"
)
print
(
f
"RTF:
{
final_response
/
duration
}
"
)
save_path
=
str
(
args
.
output_dir
+
"/"
+
utt_id
+
".wav"
)
save_audio
(
buffer
,
save_path
)
print
(
"音频保存至:"
,
save_path
)
return
first_response
,
final_response
,
duration
def
count_engine
(
logfile
:
str
=
"./nohup.out"
):
"""For inference on the statistical engine side
Args:
logfile (str, optional): server log. Defaults to "./nohup.out".
"""
first_response_list
=
[]
final_response_list
=
[]
duration_list
=
[]
with
open
(
logfile
,
"r"
)
as
f
:
for
line
in
f
.
readlines
():
if
"- first response time:"
in
line
:
first_response
=
float
(
line
.
splie
(
" "
)[
-
2
])
first_response_list
.
append
(
first_response
)
elif
"- final response time:"
in
line
:
final_response
=
float
(
line
.
splie
(
" "
)[
-
2
])
final_response_list
.
append
(
final_response
)
elif
"- The durations of audio is:"
in
line
:
duration
=
float
(
line
.
splie
(
" "
)[
-
2
])
duration_list
.
append
(
duration
)
assert
(
len
(
first_response_list
)
==
len
(
final_response_list
)
and
len
(
final_response_list
)
==
len
(
duration_list
))
avg_first_response
=
sum
(
first_response_list
)
/
len
(
first_response_list
)
avg_final_response
=
sum
(
final_response_list
)
/
len
(
final_response_list
)
avg_duration
=
sum
(
duration_list
)
/
len
(
duration_list
)
RTF
=
sum
(
final_response_list
)
/
sum
(
duration_list
)
print
(
"************************* engine result ***************************************"
)
print
(
f
"test num:
{
len
(
duration_list
)
}
, avg first response:
{
avg_first_response
}
s, avg final response:
{
avg_final_response
}
s, avg duration:
{
avg_duration
}
, RTF:
{
RTF
}
"
)
print
(
f
"min duration:
{
min
(
duration_list
)
}
s, max duration:
{
max
(
duration_list
)
}
s"
)
print
(
f
"max first response:
{
max
(
first_response_list
)
}
s, min first response:
{
min
(
first_response_list
)
}
s"
)
print
(
f
"max final response:
{
max
(
final_response_list
)
}
s, min final response:
{
min
(
final_response_list
)
}
s"
)
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"--text"
,
type
=
str
,
default
=
"../../../../../../paddlespeech/t2s/exps/csmsc_test.txt"
,
help
=
"text to synthesize, a 'utt_id sentence' pair per line"
)
parser
.
add_argument
(
'--spk_id'
,
type
=
int
,
default
=
0
,
help
=
'Speaker id'
)
parser
.
add_argument
(
'--speed'
,
type
=
float
,
default
=
1.0
,
help
=
'Audio speed'
)
parser
.
add_argument
(
'--volume'
,
type
=
float
,
default
=
1.0
,
help
=
'Audio volume'
)
parser
.
add_argument
(
'--sample_rate'
,
type
=
int
,
default
=
0
,
help
=
'Sampling rate, the default is the same as the model'
)
parser
.
add_argument
(
"--server"
,
type
=
str
,
help
=
"server ip"
,
default
=
"127.0.0.1"
)
parser
.
add_argument
(
"--port"
,
type
=
int
,
help
=
"server port"
,
default
=
8092
)
parser
.
add_argument
(
"--output_dir"
,
type
=
str
,
default
=
"./output"
,
help
=
"output dir"
)
args
=
parser
.
parse_args
()
os
.
system
(
"rm -rf %s"
%
(
args
.
output_dir
))
os
.
mkdir
(
args
.
output_dir
)
first_response_list
=
[]
final_response_list
=
[]
duration_list
=
[]
sentences
=
get_sentences
(
text_file
=
args
.
text
,
lang
=
"zh"
)
for
utt_id
,
sentence
in
sentences
:
first_response
,
final_response
,
duration
=
test
(
args
,
sentence
,
utt_id
)
first_response_list
.
append
(
first_response
)
final_response_list
.
append
(
final_response
)
duration_list
.
append
(
duration
)
assert
(
len
(
first_response_list
)
==
len
(
final_response_list
)
and
len
(
final_response_list
)
==
len
(
duration_list
))
avg_first_response
=
sum
(
first_response_list
)
/
len
(
first_response_list
)
avg_final_response
=
sum
(
final_response_list
)
/
len
(
final_response_list
)
avg_duration
=
sum
(
duration_list
)
/
len
(
duration_list
)
RTF
=
sum
(
final_response_list
)
/
sum
(
duration_list
)
print
(
"************************* server/client result ***************************************"
)
print
(
f
"test num:
{
len
(
duration_list
)
}
, avg first response:
{
avg_first_response
}
s, avg final response:
{
avg_final_response
}
s, avg duration:
{
avg_duration
}
, RTF:
{
RTF
}
"
)
print
(
f
"min duration:
{
min
(
duration_list
)
}
s, max duration:
{
max
(
duration_list
)
}
s"
)
print
(
f
"max first response:
{
max
(
first_response_list
)
}
s, min first response:
{
min
(
first_response_list
)
}
s"
)
print
(
f
"max final response:
{
max
(
final_response_list
)
}
s, min final response:
{
min
(
final_response_list
)
}
s"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录