mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-25 12:39:25 +01:00
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:
@@ -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],
|
||||
|
||||
@@ -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]:
|
||||
|
||||
Reference in New Issue
Block a user