Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
b1f9b801
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看板
提交
b1f9b801
编写于
5月 11, 2022
作者:
L
lym0302
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add start and end request on ws tts, test=doc
上级
d4f863dc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
7 addition
and
65 deletion
+7
-65
paddlespeech/server/bin/paddlespeech_client.py
paddlespeech/server/bin/paddlespeech_client.py
+0
-44
paddlespeech/server/utils/util.py
paddlespeech/server/utils/util.py
+0
-20
paddlespeech/server/ws/tts_api.py
paddlespeech/server/ws/tts_api.py
+7
-1
未找到文件。
paddlespeech/server/bin/paddlespeech_client.py
浏览文件 @
b1f9b801
...
...
@@ -33,7 +33,6 @@ from paddlespeech.cli.log import logger
from
paddlespeech.server.utils.audio_handler
import
ASRWsAudioHandler
from
paddlespeech.server.utils.audio_process
import
wav2pcm
from
paddlespeech.server.utils.util
import
compute_delay
from
paddlespeech.server.utils.util
import
network_reachable
from
paddlespeech.server.utils.util
import
wav2base64
__all__
=
[
...
...
@@ -157,12 +156,6 @@ class TTSClientExecutor(BaseExecutor):
"save_path"
:
output
}
# Check if the network is reachable
network
=
'http://'
+
server_ip
+
":"
+
str
(
port
)
if
network_reachable
(
network
)
is
not
True
:
logger
.
error
(
f
"
{
network
}
unreachable, please check the ip address."
)
sys
.
exit
(
-
1
)
res
=
requests
.
post
(
url
,
json
.
dumps
(
request
))
response_dict
=
res
.
json
()
if
output
is
not
None
:
...
...
@@ -264,12 +257,6 @@ class TTSOnlineClientExecutor(BaseExecutor):
Python API to call an executor.
"""
# Check if the network is reachable
network
=
'http://'
+
server_ip
+
":"
+
str
(
port
)
if
network_reachable
(
network
)
is
not
True
:
logger
.
error
(
f
"
{
network
}
unreachable, please check the ip address."
)
sys
.
exit
(
-
1
)
if
protocol
==
"http"
:
logger
.
info
(
"tts http client start"
)
from
paddlespeech.server.utils.audio_handler
import
TTSHttpHandler
...
...
@@ -415,13 +402,6 @@ class ASRClientExecutor(BaseExecutor):
# and paddlespeech_client asr only support http protocol
protocol
=
"http"
if
protocol
.
lower
()
==
"http"
:
# Check if the network is reachable
network
=
'http://'
+
server_ip
+
":"
+
str
(
port
)
if
network_reachable
(
network
)
is
not
True
:
logger
.
error
(
f
"
{
network
}
unreachable, please check the ip address."
)
sys
.
exit
(
-
1
)
from
paddlespeech.server.utils.audio_handler
import
ASRHttpHandler
logger
.
info
(
"asr http client start"
)
handler
=
ASRHttpHandler
(
server_ip
=
server_ip
,
port
=
port
)
...
...
@@ -527,12 +507,6 @@ class ASROnlineClientExecutor(BaseExecutor):
str: the audio text
"""
# Check if the network is reachable
network
=
'http://'
+
server_ip
+
":"
+
str
(
port
)
if
network_reachable
(
network
)
is
not
True
:
logger
.
error
(
f
"
{
network
}
unreachable, please check the ip address."
)
sys
.
exit
(
-
1
)
logger
.
info
(
"asr websocket client start"
)
handler
=
ASRWsAudioHandler
(
server_ip
,
...
...
@@ -598,12 +572,6 @@ class CLSClientExecutor(BaseExecutor):
Python API to call an executor.
"""
# Check if the network is reachable
network
=
'http://'
+
server_ip
+
":"
+
str
(
port
)
if
network_reachable
(
network
)
is
not
True
:
logger
.
error
(
f
"
{
network
}
unreachable, please check the ip address."
)
sys
.
exit
(
-
1
)
url
=
'http://'
+
server_ip
+
":"
+
str
(
port
)
+
'/paddlespeech/cls'
audio
=
wav2base64
(
input
)
data
=
{
"audio"
:
audio
,
"topk"
:
topk
}
...
...
@@ -669,12 +637,6 @@ class TextClientExecutor(BaseExecutor):
str: the punctuation text
"""
# Check if the network is reachable
network
=
'http://'
+
server_ip
+
":"
+
str
(
port
)
if
network_reachable
(
network
)
is
not
True
:
logger
.
error
(
f
"
{
network
}
unreachable, please check the ip address."
)
sys
.
exit
(
-
1
)
url
=
'http://'
+
server_ip
+
":"
+
str
(
port
)
+
'/paddlespeech/text'
request
=
{
"text"
:
input
,
...
...
@@ -772,12 +734,6 @@ class VectorClientExecutor(BaseExecutor):
str: the audio embedding or score between enroll and test audio
"""
# Check if the network is reachable
network
=
'http://'
+
server_ip
+
":"
+
str
(
port
)
if
network_reachable
(
network
)
is
not
True
:
logger
.
error
(
f
"
{
network
}
unreachable, please check the ip address."
)
sys
.
exit
(
-
1
)
if
task
==
"spk"
:
from
paddlespeech.server.utils.audio_handler
import
VectorHttpHandler
logger
.
info
(
"vector http client start"
)
...
...
paddlespeech/server/utils/util.py
浏览文件 @
b1f9b801
...
...
@@ -13,8 +13,6 @@
import
base64
import
math
import
requests
def
wav2base64
(
wav_file
:
str
):
"""
...
...
@@ -148,21 +146,3 @@ def count_engine(logfile: str="./nohup.out"):
print
(
f
"max final response:
{
max
(
final_response_list
)
}
s, min final response:
{
min
(
final_response_list
)
}
s"
)
def
network_reachable
(
url
:
str
,
timeout
:
int
=
5
)
->
bool
:
"""Check if the network is reachable
Args:
url (str): http://server_ip:port or ws://server_ip:port
timeout (int, optional): timeout. Defaults to 5.
Returns:
bool: Whether the network is reachable.
"""
try
:
request
=
requests
.
get
(
url
,
timeout
=
timeout
)
return
True
except
(
requests
.
ConnectionError
,
requests
.
Timeout
)
as
exception
:
print
(
exception
)
return
False
paddlespeech/server/ws/tts_api.py
浏览文件 @
b1f9b801
...
...
@@ -68,6 +68,10 @@ async def websocket_endpoint(websocket: WebSocket):
"session"
:
session
}
await
websocket
.
send_json
(
resp
)
break
else
:
resp
=
{
"status"
:
0
,
"signal"
:
"no valid json data"
}
await
websocket
.
send_json
(
resp
)
# speech synthesis request
elif
'text'
in
message
:
...
...
@@ -83,10 +87,12 @@ async def websocket_endpoint(websocket: WebSocket):
resp
=
{
"status"
:
1
,
"audio"
:
tts_results
}
await
websocket
.
send_json
(
resp
)
except
StopIteration
as
e
:
import
pdb
pdb
.
set_trace
()
resp
=
{
"status"
:
2
,
"audio"
:
''
}
await
websocket
.
send_json
(
resp
)
logger
.
info
(
"Complete the
transmission of
audio streams"
)
"Complete the
synthesis of the
audio streams"
)
break
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录