Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
d99e99ce
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 1 年 前同步成功
通知
207
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,发现更多精彩内容 >>
未验证
提交
d99e99ce
编写于
5月 05, 2022
作者:
H
Hui Zhang
提交者:
GitHub
5月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1836 from Honei/punc
[asr][server]join streaming asr and punc server
上级
435e86b3
0e2372ed
变更
9
展开全部
显示空白变更内容
内联
并排
Showing
9 changed file
with
715 addition
and
13 deletion
+715
-13
demos/streaming_asr_server/README.md
demos/streaming_asr_server/README.md
+277
-2
demos/streaming_asr_server/README_cn.md
demos/streaming_asr_server/README_cn.md
+277
-1
demos/streaming_asr_server/conf/punc_application.yaml
demos/streaming_asr_server/conf/punc_application.yaml
+35
-0
demos/streaming_asr_server/conf/ws_conformer_application.yaml
...s/streaming_asr_server/conf/ws_conformer_application.yaml
+3
-3
demos/streaming_asr_server/punc_server.py
demos/streaming_asr_server/punc_server.py
+38
-0
demos/streaming_asr_server/server.sh
demos/streaming_asr_server/server.sh
+5
-0
demos/streaming_asr_server/streaming_asr_server.py
demos/streaming_asr_server/streaming_asr_server.py
+38
-0
demos/streaming_asr_server/test.sh
demos/streaming_asr_server/test.sh
+5
-2
paddlespeech/server/bin/paddlespeech_client.py
paddlespeech/server/bin/paddlespeech_client.py
+37
-5
未找到文件。
demos/streaming_asr_server/README.md
浏览文件 @
d99e99ce
此差异已折叠。
点击以展开。
demos/streaming_asr_server/README_cn.md
浏览文件 @
d99e99ce
此差异已折叠。
点击以展开。
demos/streaming_asr_server/conf/punc_application.yaml
0 → 100644
浏览文件 @
d99e99ce
# This is the parameter configuration file for PaddleSpeech Serving.
#################################################################################
# SERVER SETTING #
#################################################################################
host
:
0.0.0.0
port
:
8190
# The task format in the engin_list is: <speech task>_<engine type>
# task choices = ['asr_python']
# protocol = ['http'] (only one can be selected).
# http only support offline engine type.
protocol
:
'
http'
engine_list
:
[
'
text_python'
]
#################################################################################
# ENGINE CONFIG #
#################################################################################
################################### Text #########################################
################### text task: punc; engine_type: python #######################
text_python
:
task
:
punc
model_type
:
'
ernie_linear_p3_wudao'
lang
:
'
zh'
sample_rate
:
16000
cfg_path
:
# [optional]
ckpt_path
:
# [optional]
vocab_file
:
# [optional]
device
:
'
cpu'
# set 'gpu:id' or 'cpu'
demos/streaming_asr_server/conf/ws_conformer_application.yaml
浏览文件 @
d99e99ce
...
...
@@ -4,7 +4,7 @@
# SERVER SETTING #
#################################################################################
host
:
0.0.0.0
port
:
8
0
90
port
:
8
2
90
# The task format in the engin_list is: <speech task>_<engine type>
# task choices = ['asr_online']
...
...
@@ -29,7 +29,7 @@ asr_online:
cfg_path
:
decode_method
:
force_yes
:
True
device
:
# cpu or gpu:id
device
:
'
cpu'
# cpu or gpu:id
am_predictor_conf
:
device
:
# set 'gpu:id' or 'cpu'
switch_ir_optim
:
True
...
...
demos/streaming_asr_server/punc_server.py
0 → 100644
浏览文件 @
d99e99ce
# Copyright (c) 2022 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
from
paddlespeech.cli.log
import
logger
from
paddlespeech.server.bin.paddlespeech_server
import
ServerExecutor
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
(
prog
=
'paddlespeech_server.start'
,
add_help
=
True
)
parser
.
add_argument
(
"--config_file"
,
action
=
"store"
,
help
=
"yaml file of the app"
,
default
=
None
,
required
=
True
)
parser
.
add_argument
(
"--log_file"
,
action
=
"store"
,
help
=
"log file"
,
default
=
"./log/paddlespeech.log"
)
logger
.
info
(
"start to parse the args"
)
args
=
parser
.
parse_args
()
logger
.
info
(
"start to launch the punctuation server"
)
punc_server
=
ServerExecutor
()
punc_server
(
config_file
=
args
.
config_file
,
log_file
=
args
.
log_file
)
demos/streaming_asr_server/server.sh
0 → 100755
浏览文件 @
d99e99ce
export
CUDA_VISIBLE_DEVICE
=
0,1,2,3
nohup
python3 punc_server.py
--config_file
conf/punc_application.yaml
>
punc.log 2>&1 &
nohup
python3 streaming_asr_server.py
--config_file
conf/ws_conformer_application.yaml
>
streaming_asr.log 2>&1 &
demos/streaming_asr_server/streaming_asr_server.py
0 → 100644
浏览文件 @
d99e99ce
# Copyright (c) 2022 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
from
paddlespeech.cli.log
import
logger
from
paddlespeech.server.bin.paddlespeech_server
import
ServerExecutor
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
(
prog
=
'paddlespeech_server.start'
,
add_help
=
True
)
parser
.
add_argument
(
"--config_file"
,
action
=
"store"
,
help
=
"yaml file of the app"
,
default
=
None
,
required
=
True
)
parser
.
add_argument
(
"--log_file"
,
action
=
"store"
,
help
=
"log file"
,
default
=
"./log/paddlespeech.log"
)
logger
.
info
(
"start to parse the args"
)
args
=
parser
.
parse_args
()
logger
.
info
(
"start to launch the streaming asr server"
)
streaming_asr_server
=
ServerExecutor
()
streaming_asr_server
(
config_file
=
args
.
config_file
,
log_file
=
args
.
log_file
)
demos/streaming_asr_server/test.sh
100644 → 100755
浏览文件 @
d99e99ce
# download the test wav
wget
-c
https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav
# read the wav and pass it to service
python3 websocket_client.py
--wavfile
./zh.wav
# read the wav and pass it to only streaming asr service
python3 websocket_client.py
--server_ip
127.0.0.1
--port
8290
--wavfile
./zh.wav
# read the wav and call streaming and punc service
python3 websocket_client.py
--server_ip
127.0.0.1
--port
8290
--punc
.server_ip 127.0.0.1
--punc
.port 8190
--wavfile
./zh.wav
paddlespeech/server/bin/paddlespeech_client.py
浏览文件 @
d99e99ce
...
...
@@ -411,6 +411,18 @@ class ASROnlineClientExecutor(BaseExecutor):
'--lang'
,
type
=
str
,
default
=
"zh_cn"
,
help
=
'language'
)
self
.
parser
.
add_argument
(
'--audio_format'
,
type
=
str
,
default
=
"wav"
,
help
=
'audio format'
)
self
.
parser
.
add_argument
(
'--punc.server_ip'
,
type
=
str
,
default
=
None
,
dest
=
"punc_server_ip"
,
help
=
'Punctuation server ip'
)
self
.
parser
.
add_argument
(
'--punc.port'
,
type
=
int
,
default
=
8190
,
dest
=
"punc_server_port"
,
help
=
'Punctuation server port'
)
def
execute
(
self
,
argv
:
List
[
str
])
->
bool
:
args
=
self
.
parser
.
parse_args
(
argv
)
...
...
@@ -428,7 +440,9 @@ class ASROnlineClientExecutor(BaseExecutor):
port
=
port
,
sample_rate
=
sample_rate
,
lang
=
lang
,
audio_format
=
audio_format
)
audio_format
=
audio_format
,
punc_server_ip
=
args
.
punc_server_ip
,
punc_server_port
=
args
.
punc_server_port
)
time_end
=
time
.
time
()
logger
.
info
(
res
)
logger
.
info
(
"Response time %f s."
%
(
time_end
-
time_start
))
...
...
@@ -445,12 +459,30 @@ class ASROnlineClientExecutor(BaseExecutor):
port
:
int
=
8091
,
sample_rate
:
int
=
16000
,
lang
:
str
=
"zh_cn"
,
audio_format
:
str
=
"wav"
):
"""
Python API to call an executor.
audio_format
:
str
=
"wav"
,
punc_server_ip
:
str
=
None
,
punc_server_port
:
str
=
None
):
"""Python API to call asr online executor.
Args:
input (str): the audio file to be send to streaming asr service.
server_ip (str, optional): streaming asr server ip. Defaults to "127.0.0.1".
port (int, optional): streaming asr server port. Defaults to 8091.
sample_rate (int, optional): audio sample rate. Defaults to 16000.
lang (str, optional): audio language type. Defaults to "zh_cn".
audio_format (str, optional): audio format. Defaults to "wav".
punc_server_ip (str, optional): punctuation server ip. Defaults to None.
punc_server_port (str, optional): punctuation server port. Defaults to None.
Returns:
str: the audio text
"""
logger
.
info
(
"asr websocket client start"
)
handler
=
ASRWsAudioHandler
(
server_ip
,
port
)
handler
=
ASRWsAudioHandler
(
server_ip
,
port
,
punc_server_ip
=
punc_server_ip
,
punc_server_port
=
punc_server_port
)
loop
=
asyncio
.
get_event_loop
()
res
=
loop
.
run_until_complete
(
handler
.
run
(
input
))
logger
.
info
(
"asr websocket client finished"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录