提交 7394a187 编写于 作者: K KP

Add default arguments in cls python api.

上级 f9efbf30
......@@ -421,7 +421,7 @@ class ASRExecutor(BaseExecutor):
device = parser_args.device
try:
res = self(model, lang, sample_rate, config, ckpt_path, audio_file,
res = self(audio_file, model, lang, sample_rate, config, ckpt_path,
device)
logger.info('ASR Result: {}'.format(res))
return True
......@@ -429,8 +429,14 @@ class ASRExecutor(BaseExecutor):
logger.exception(e)
return False
def __call__(self, model, lang, sample_rate, config, ckpt_path, audio_file,
device):
def __call__(self,
audio_file: os.PathLike,
model: str='conformer_wenetspeech',
lang: str='zh',
sample_rate: int=16000,
config: os.PathLike=None,
ckpt_path: os.PathLike=None,
device=paddle.get_device()):
"""
Python API to call an executor.
"""
......
......@@ -237,7 +237,7 @@ class CLSExecutor(BaseExecutor):
device = parser_args.device
try:
res = self(model_type, cfg_path, label_file, ckpt_path, audio_file,
res = self(audio_file, model_type, cfg_path, ckpt_path, label_file,
topk, device)
logger.info('CLS Result:\n{}'.format(res))
return True
......@@ -245,8 +245,14 @@ class CLSExecutor(BaseExecutor):
logger.exception(e)
return False
def __call__(self, model, config, ckpt_path, label_file, audio_file, topk,
device):
def __call__(self,
audio_file: os.PathLike,
model: str='panns_cnn14',
config: Optional[os.PathLike]=None,
ckpt_path: Optional[os.PathLike]=None,
label_file: Optional[os.PathLike]=None,
topk: int=1,
device: str=paddle.get_device()):
"""
Python API to call an executor.
"""
......
......@@ -326,16 +326,23 @@ class STExecutor(BaseExecutor):
device = parser_args.device
try:
res = self(model, src_lang, tgt_lang, sample_rate, config,
ckpt_path, audio_file, device)
res = self(audio_file, model, src_lang, tgt_lang, sample_rate,
config, ckpt_path, device)
logger.info("ST Result: {}".format(res))
return True
except Exception as e:
logger.exception(e)
return False
def __call__(self, model, src_lang, tgt_lang, sample_rate, config,
ckpt_path, audio_file, device):
def __call__(self,
audio_file: os.PathLike,
model: str='fat_st_ted',
src_lang: str='en',
tgt_lang: str='zh',
sample_rate: int=16000,
config: Optional[os.PathLike]=None,
ckpt_path: Optional[os.PathLike]=None,
device: str=paddle.get_device()):
"""
Python API to call an executor.
"""
......
......@@ -265,9 +265,9 @@ class TextExecutor(BaseExecutor):
task: str='punc',
model: str='ernie_linear_wudao',
lang: str='zh',
config: os.PathLike=None,
ckpt_path: os.PathLike=None,
punc_vocab: os.PathLike=None,
config: Optional[os.PathLike]=None,
ckpt_path: Optional[os.PathLike]=None,
punc_vocab: Optional[os.PathLike]=None,
device: str=paddle.get_device(), ):
"""
Python API to call an executor.
......
......@@ -616,7 +616,7 @@ class TTSExecutor(BaseExecutor):
voc_ckpt: Optional[os.PathLike]=None,
voc_stat: Optional[os.PathLike]=None,
lang: str='zh',
device: str='gpu',
device: str=paddle.get_device(),
output: str='output.wav'):
"""
Python API to call an executor.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册