Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
c94ebdc5
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看板
提交
c94ebdc5
编写于
11月 30, 2021
作者:
K
KP
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add python api for executor.
上级
e9798498
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
4 deletion
+30
-4
paddlespeech/cli/executor.py
paddlespeech/cli/executor.py
+15
-0
paddlespeech/cli/s2t/infer.py
paddlespeech/cli/s2t/infer.py
+15
-4
未找到文件。
paddlespeech/cli/executor.py
浏览文件 @
c94ebdc5
...
...
@@ -14,6 +14,7 @@
import
os
from
abc
import
ABC
from
abc
import
abstractmethod
from
typing
import
List
from
typing
import
Union
import
paddle
...
...
@@ -64,3 +65,17 @@ class BaseExecutor(ABC):
Output postprocess and return human-readable results such as texts and audio files.
"""
pass
@
abstractmethod
def
execute
(
self
,
argv
:
List
[
str
])
->
bool
:
"""
Command line entry.
"""
pass
@
abstractmethod
def
__call__
(
self
,
*
arg
,
**
kwargs
):
"""
Python API to call an executor.
"""
pass
paddlespeech/cli/s2t/infer.py
浏览文件 @
c94ebdc5
...
...
@@ -126,6 +126,9 @@ class S2TExecutor(BaseExecutor):
pass
def
execute
(
self
,
argv
:
List
[
str
])
->
bool
:
"""
Command line entry.
"""
parser_args
=
self
.
parser
.
parse_args
(
argv
)
print
(
parser_args
)
...
...
@@ -137,12 +140,20 @@ class S2TExecutor(BaseExecutor):
device
=
parser_args
.
device
try
:
self
.
_init_from_path
(
model
,
lang
,
config
,
ckpt_path
)
self
.
preprocess
(
audio_file
)
self
.
infer
()
res
=
self
.
postprocess
()
# Retrieve result of s2t.
res
=
self
(
model
,
lang
,
config
,
ckpt_path
,
audio_file
,
device
)
print
(
res
)
return
True
except
Exception
as
e
:
print
(
e
)
return
False
def
__call__
(
self
,
model
,
lang
,
config
,
ckpt_path
,
audio_file
,
device
):
"""
Python API to call an executor.
"""
self
.
_init_from_path
(
model
,
lang
,
config
,
ckpt_path
)
self
.
preprocess
(
audio_file
)
self
.
infer
()
res
=
self
.
postprocess
()
# Retrieve result of s2t.
return
res
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录