Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
60c0877e
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
12 个月 前同步成功
通知
205
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,发现更多精彩内容 >>
未验证
提交
60c0877e
编写于
2月 22, 2022
作者:
H
Hui Zhang
提交者:
GitHub
2月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1472 from KPatr1ck/cli_batch
[CLI][Logger]Add cli logger control.
上级
49f80afe
d36a4ccf
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
76 addition
and
28 deletion
+76
-28
paddlespeech/cli/asr/infer.py
paddlespeech/cli/asr/infer.py
+11
-5
paddlespeech/cli/cls/infer.py
paddlespeech/cli/cls/infer.py
+11
-5
paddlespeech/cli/executor.py
paddlespeech/cli/executor.py
+20
-3
paddlespeech/cli/st/infer.py
paddlespeech/cli/st/infer.py
+11
-5
paddlespeech/cli/text/infer.py
paddlespeech/cli/text/infer.py
+11
-5
paddlespeech/cli/tts/infer.py
paddlespeech/cli/tts/infer.py
+12
-5
未找到文件。
paddlespeech/cli/asr/infer.py
浏览文件 @
60c0877e
...
...
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
argparse
import
ast
import
os
import
sys
from
collections
import
OrderedDict
...
...
@@ -183,10 +182,15 @@ class ASRExecutor(BaseExecutor):
default
=
paddle
.
get_device
(),
help
=
'Choose device to execute model inference.'
)
self
.
parser
.
add_argument
(
'-d'
,
'--job_dump_result'
,
type
=
ast
.
literal_eval
,
default
=
False
,
action
=
'store_true'
,
help
=
'Save job result into file.'
)
self
.
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
'store_true'
,
help
=
'Increase logger verbosity of current task.'
)
def
_get_pretrained_path
(
self
,
tag
:
str
)
->
os
.
PathLike
:
"""
...
...
@@ -479,7 +483,9 @@ class ASRExecutor(BaseExecutor):
decode_method
=
parser_args
.
decode_method
force_yes
=
parser_args
.
yes
device
=
parser_args
.
device
job_dump_result
=
parser_args
.
job_dump_result
if
not
parser_args
.
verbose
:
self
.
disable_task_loggers
()
task_source
=
self
.
get_task_source
(
parser_args
.
input
)
task_results
=
OrderedDict
()
...
...
@@ -495,7 +501,7 @@ class ASRExecutor(BaseExecutor):
task_results
[
id_
]
=
f
'
{
e
.
__class__
.
__name__
}
:
{
e
}
'
self
.
process_task_results
(
parser_args
.
input
,
task_results
,
job_dump_result
)
parser_args
.
job_dump_result
)
if
has_exceptions
:
return
False
...
...
paddlespeech/cli/cls/infer.py
浏览文件 @
60c0877e
...
...
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
argparse
import
ast
import
os
from
collections
import
OrderedDict
from
typing
import
List
...
...
@@ -112,10 +111,15 @@ class CLSExecutor(BaseExecutor):
default
=
paddle
.
get_device
(),
help
=
'Choose device to execute model inference.'
)
self
.
parser
.
add_argument
(
'-d'
,
'--job_dump_result'
,
type
=
ast
.
literal_eval
,
default
=
False
,
action
=
'store_true'
,
help
=
'Save job result into file.'
)
self
.
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
'store_true'
,
help
=
'Increase logger verbosity of current task.'
)
def
_get_pretrained_path
(
self
,
tag
:
str
)
->
os
.
PathLike
:
"""
...
...
@@ -243,7 +247,9 @@ class CLSExecutor(BaseExecutor):
ckpt_path
=
parser_args
.
ckpt_path
topk
=
parser_args
.
topk
device
=
parser_args
.
device
job_dump_result
=
parser_args
.
job_dump_result
if
not
parser_args
.
verbose
:
self
.
disable_task_loggers
()
task_source
=
self
.
get_task_source
(
parser_args
.
input
)
task_results
=
OrderedDict
()
...
...
@@ -259,7 +265,7 @@ class CLSExecutor(BaseExecutor):
task_results
[
id_
]
=
f
'
{
e
.
__class__
.
__name__
}
:
{
e
}
'
self
.
process_task_results
(
parser_args
.
input
,
task_results
,
job_dump_result
)
parser_args
.
job_dump_result
)
if
has_exceptions
:
return
False
...
...
paddlespeech/cli/executor.py
浏览文件 @
60c0877e
...
...
@@ -11,6 +11,7 @@
# 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
logging
import
os
import
sys
from
abc
import
ABC
...
...
@@ -149,10 +150,16 @@ class BaseExecutor(ABC):
job_dump_result (bool, optional): if True, dumps job results into file. Defaults to False.
"""
raw_text
=
self
.
_format_task_results
(
results
)
print
(
raw_text
,
end
=
''
)
if
not
self
.
_is_job_input
(
input_
)
and
len
(
results
)
==
1
:
# Only one input sample
raw_text
=
list
(
results
.
values
())[
0
]
else
:
raw_text
=
self
.
_format_task_results
(
results
)
print
(
raw_text
,
end
=
''
)
# Stdout
if
self
.
_is_job_input
(
input_
)
and
job_dump_result
:
if
self
.
_is_job_input
(
input_
)
and
job_dump_result
:
# Dump to *.job.done
try
:
job_output_file
=
os
.
path
.
abspath
(
input_
)
+
'.done'
sys
.
stdout
=
open
(
job_output_file
,
'w'
)
...
...
@@ -209,3 +216,13 @@ class BaseExecutor(ABC):
for
k
,
v
in
results
.
items
():
ret
+=
f
'
{
k
}
{
v
}
\n
'
return
ret
def
disable_task_loggers
(
self
):
"""
Disable all loggers in current task.
"""
loggers
=
[
logging
.
getLogger
(
name
)
for
name
in
logging
.
root
.
manager
.
loggerDict
]
for
l
in
loggers
:
l
.
disabled
=
True
paddlespeech/cli/st/infer.py
浏览文件 @
60c0877e
...
...
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
argparse
import
ast
import
os
import
subprocess
from
collections
import
OrderedDict
...
...
@@ -110,10 +109,15 @@ class STExecutor(BaseExecutor):
default
=
paddle
.
get_device
(),
help
=
"Choose device to execute model inference."
)
self
.
parser
.
add_argument
(
'-d'
,
'--job_dump_result'
,
type
=
ast
.
literal_eval
,
default
=
False
,
action
=
'store_true'
,
help
=
'Save job result into file.'
)
self
.
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
'store_true'
,
help
=
'Increase logger verbosity of current task.'
)
def
_get_pretrained_path
(
self
,
tag
:
str
)
->
os
.
PathLike
:
"""
...
...
@@ -327,7 +331,9 @@ class STExecutor(BaseExecutor):
config
=
parser_args
.
config
ckpt_path
=
parser_args
.
ckpt_path
device
=
parser_args
.
device
job_dump_result
=
parser_args
.
job_dump_result
if
not
parser_args
.
verbose
:
self
.
disable_task_loggers
()
task_source
=
self
.
get_task_source
(
parser_args
.
input
)
task_results
=
OrderedDict
()
...
...
@@ -343,7 +349,7 @@ class STExecutor(BaseExecutor):
task_results
[
id_
]
=
f
'
{
e
.
__class__
.
__name__
}
:
{
e
}
'
self
.
process_task_results
(
parser_args
.
input
,
task_results
,
job_dump_result
)
parser_args
.
job_dump_result
)
if
has_exceptions
:
return
False
...
...
paddlespeech/cli/text/infer.py
浏览文件 @
60c0877e
...
...
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
argparse
import
ast
import
os
import
re
from
collections
import
OrderedDict
...
...
@@ -122,10 +121,15 @@ class TextExecutor(BaseExecutor):
default
=
paddle
.
get_device
(),
help
=
'Choose device to execute model inference.'
)
self
.
parser
.
add_argument
(
'-d'
,
'--job_dump_result'
,
type
=
ast
.
literal_eval
,
default
=
False
,
action
=
'store_true'
,
help
=
'Save job result into file.'
)
self
.
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
'store_true'
,
help
=
'Increase logger verbosity of current task.'
)
def
_get_pretrained_path
(
self
,
tag
:
str
)
->
os
.
PathLike
:
"""
...
...
@@ -270,7 +274,9 @@ class TextExecutor(BaseExecutor):
ckpt_path
=
parser_args
.
ckpt_path
punc_vocab
=
parser_args
.
punc_vocab
device
=
parser_args
.
device
job_dump_result
=
parser_args
.
job_dump_result
if
not
parser_args
.
verbose
:
self
.
disable_task_loggers
()
task_source
=
self
.
get_task_source
(
parser_args
.
input
)
task_results
=
OrderedDict
()
...
...
@@ -286,7 +292,7 @@ class TextExecutor(BaseExecutor):
task_results
[
id_
]
=
f
'
{
e
.
__class__
.
__name__
}
:
{
e
}
'
self
.
process_task_results
(
parser_args
.
input
,
task_results
,
job_dump_result
)
parser_args
.
job_dump_result
)
if
has_exceptions
:
return
False
...
...
paddlespeech/cli/tts/infer.py
浏览文件 @
60c0877e
...
...
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
argparse
import
ast
import
os
from
collections
import
OrderedDict
from
typing
import
Any
...
...
@@ -400,10 +399,15 @@ class TTSExecutor(BaseExecutor):
self
.
parser
.
add_argument
(
'--output'
,
type
=
str
,
default
=
'output.wav'
,
help
=
'output file name'
)
self
.
parser
.
add_argument
(
'-d'
,
'--job_dump_result'
,
type
=
ast
.
literal_eval
,
default
=
False
,
action
=
'store_true'
,
help
=
'Save job result into file.'
)
self
.
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
'store_true'
,
help
=
'Increase logger verbosity of current task.'
)
def
_get_pretrained_path
(
self
,
tag
:
str
)
->
os
.
PathLike
:
"""
...
...
@@ -693,7 +697,9 @@ class TTSExecutor(BaseExecutor):
lang
=
args
.
lang
device
=
args
.
device
spk_id
=
args
.
spk_id
job_dump_result
=
args
.
job_dump_result
if
not
args
.
verbose
:
self
.
disable_task_loggers
()
task_source
=
self
.
get_task_source
(
args
.
input
)
task_results
=
OrderedDict
()
...
...
@@ -733,7 +739,8 @@ class TTSExecutor(BaseExecutor):
has_exceptions
=
True
task_results
[
id_
]
=
f
'
{
e
.
__class__
.
__name__
}
:
{
e
}
'
self
.
process_task_results
(
args
.
input
,
task_results
,
job_dump_result
)
self
.
process_task_results
(
args
.
input
,
task_results
,
args
.
job_dump_result
)
if
has_exceptions
:
return
False
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录