Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
cb39777a
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,发现更多精彩内容 >>
提交
cb39777a
编写于
3月 31, 2022
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format code
上级
760e5d44
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
23 addition
and
21 deletion
+23
-21
paddlespeech/s2t/frontend/speech.py
paddlespeech/s2t/frontend/speech.py
+6
-1
paddlespeech/server/bin/main.py
paddlespeech/server/bin/main.py
+1
-1
paddlespeech/server/engine/asr/online/asr_engine.py
paddlespeech/server/engine/asr/online/asr_engine.py
+12
-15
paddlespeech/server/utils/buffer.py
paddlespeech/server/utils/buffer.py
+4
-4
未找到文件。
paddlespeech/s2t/frontend/speech.py
浏览文件 @
cb39777a
...
...
@@ -108,7 +108,12 @@ class SpeechSegment(AudioSegment):
token_ids
)
@
classmethod
def
from_pcm
(
cls
,
samples
,
sample_rate
,
transcript
,
tokens
=
None
,
token_ids
=
None
):
def
from_pcm
(
cls
,
samples
,
sample_rate
,
transcript
,
tokens
=
None
,
token_ids
=
None
):
"""Create speech segment from pcm on online mode
Args:
samples (numpy.ndarray): Audio samples [num_samples x num_channels].
...
...
paddlespeech/server/bin/main.py
浏览文件 @
cb39777a
...
...
@@ -18,8 +18,8 @@ from fastapi import FastAPI
from
paddlespeech.server.engine.engine_pool
import
init_engine_pool
from
paddlespeech.server.restful.api
import
setup_router
as
setup_http_router
from
paddlespeech.server.ws.api
import
setup_router
as
setup_ws_router
from
paddlespeech.server.utils.config
import
get_config
from
paddlespeech.server.ws.api
import
setup_router
as
setup_ws_router
app
=
FastAPI
(
title
=
"PaddleSpeech Serving API"
,
description
=
"Api"
,
version
=
"0.0.1"
)
...
...
paddlespeech/server/engine/asr/online/asr_engine.py
浏览文件 @
cb39777a
...
...
@@ -11,29 +11,23 @@
# 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
io
import
os
import
time
from
typing
import
Optional
import
pickle
import
numpy
as
np
from
numpy
import
float32
import
soundfile
import
numpy
as
np
import
paddle
from
numpy
import
float32
from
yacs.config
import
CfgNode
from
paddlespeech.s2t.frontend.speech
import
SpeechSegment
from
paddlespeech.cli.asr.infer
import
ASRExecutor
from
paddlespeech.cli.log
import
logger
from
paddlespeech.cli.utils
import
MODEL_HOME
from
paddlespeech.s2t.frontend.featurizer.text_featurizer
import
TextFeaturizer
from
paddlespeech.s2t.frontend.speech
import
SpeechSegment
from
paddlespeech.s2t.modules.ctc
import
CTCDecoder
from
paddlespeech.s2t.utils.utility
import
UpdateConfig
from
paddlespeech.server.engine.base_engine
import
BaseEngine
from
paddlespeech.server.utils.config
import
get_config
from
paddlespeech.server.utils.paddle_predictor
import
init_predictor
from
paddlespeech.server.utils.paddle_predictor
import
run_model
__all__
=
[
'ASREngine'
]
...
...
@@ -182,10 +176,11 @@ class ASRServerExecutor(ASRExecutor):
Returns:
[type]: [description]
"""
if
"deepspeech2online"
in
model_type
:
if
"deepspeech2online"
in
model_type
:
input_names
=
self
.
am_predictor
.
get_input_names
()
audio_handle
=
self
.
am_predictor
.
get_input_handle
(
input_names
[
0
])
audio_len_handle
=
self
.
am_predictor
.
get_input_handle
(
input_names
[
1
])
audio_len_handle
=
self
.
am_predictor
.
get_input_handle
(
input_names
[
1
])
h_box_handle
=
self
.
am_predictor
.
get_input_handle
(
input_names
[
2
])
c_box_handle
=
self
.
am_predictor
.
get_input_handle
(
input_names
[
3
])
...
...
@@ -203,7 +198,8 @@ class ASRServerExecutor(ASRExecutor):
output_names
=
self
.
am_predictor
.
get_output_names
()
output_handle
=
self
.
am_predictor
.
get_output_handle
(
output_names
[
0
])
output_lens_handle
=
self
.
am_predictor
.
get_output_handle
(
output_names
[
1
])
output_lens_handle
=
self
.
am_predictor
.
get_output_handle
(
output_names
[
1
])
output_state_h_handle
=
self
.
am_predictor
.
get_output_handle
(
output_names
[
2
])
output_state_c_handle
=
self
.
am_predictor
.
get_output_handle
(
...
...
@@ -341,7 +337,8 @@ class ASREngine(BaseEngine):
x_chunk_lens (numpy.array): shape[B]
decoder_chunk_size(int)
"""
self
.
output
=
self
.
executor
.
decode_one_chunk
(
x_chunk
,
x_chunk_lens
,
self
.
config
.
model_type
)
self
.
output
=
self
.
executor
.
decode_one_chunk
(
x_chunk
,
x_chunk_lens
,
self
.
config
.
model_type
)
def
postprocess
(
self
):
"""postprocess
...
...
paddlespeech/server/utils/buffer.py
浏览文件 @
cb39777a
...
...
@@ -43,10 +43,10 @@ class ChunkBuffer(object):
audio
=
self
.
remained_audio
+
audio
self
.
remained_audio
=
b
''
n
=
int
(
self
.
sample_rate
*
(
self
.
frame_duration_ms
/
1000.0
)
*
self
.
sample_width
)
shift_n
=
int
(
self
.
sample_rate
*
(
self
.
shift_ms
/
1000.0
)
*
self
.
sample_width
)
n
=
int
(
self
.
sample_rate
*
(
self
.
frame_duration_ms
/
1000.0
)
*
self
.
sample_width
)
shift_n
=
int
(
self
.
sample_rate
*
(
self
.
shift_ms
/
1000.0
)
*
self
.
sample_width
)
offset
=
0
timestamp
=
0.0
duration
=
(
float
(
n
)
/
self
.
sample_rate
)
/
self
.
sample_width
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录