modify itn pipeline for return dict

修改了itn 推理pipeline的返回值, 按照上一个commit, 定义了output key 再outputs.py
        Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11421065

    * modify inverse_text_processing_pipeline.py

* modify itn pipeline

* define output key in outputs.py
This commit is contained in:
ni.chongjia
2023-01-12 14:34:22 +00:00
parent f7930c23a0
commit 9baa236d85
2 changed files with 8 additions and 2 deletions

View File

@@ -723,6 +723,10 @@ TASK_OUTPUTS = {
# { "text": "每一天都要快乐喔"}
Tasks.auto_speech_recognition: [OutputKeys.TEXT],
# itn result for single sample
# {"text": "123"}
Tasks.inverse_text_processing: [OutputKeys.TEXT],
# speaker verification for single compare task
# {'score': 84.2332}
Tasks.speaker_verification: [OutputKeys.SCORES],

View File

@@ -44,14 +44,16 @@ class InverseTextProcessingPipeline(Pipeline):
super().__init__(model=model, **kwargs)
self.model_cfg = self.model.forward()
def __call__(self, text_in: str = None) -> str:
def __call__(self, text_in: str = None) -> Dict[str, Any]:
if len(text_in) == 0:
raise ValueError('The input of ITN should not be null.')
else:
self.text_in = text_in
output = {}
itn_result = self.forward(self.text_in)
output['text'] = itn_result
output = self.forward(self.text_in)
return output
def postprocess(self, inputs: Dict[str, Any]) -> Dict[str, Any]: