From 9f8fbdbc09807a6b80416e846c3f7e394180df33 Mon Sep 17 00:00:00 2001 From: Zhao Yuting <91456992+THUzyt21@users.noreply.github.com> Date: Tue, 27 Sep 2022 16:09:36 +0800 Subject: [PATCH 1/8] Update punc_application.yaml change model --- demos/streaming_asr_server/conf/punc_application.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/streaming_asr_server/conf/punc_application.yaml b/demos/streaming_asr_server/conf/punc_application.yaml index f947525e1..8456e2329 100644 --- a/demos/streaming_asr_server/conf/punc_application.yaml +++ b/demos/streaming_asr_server/conf/punc_application.yaml @@ -22,7 +22,7 @@ engine_list: ['text_python'] ################### text task: punc; engine_type: python ####################### text_python: task: punc - model_type: 'ernie_linear_p3_wudao' + model_type: 'ernie_linear_p3_wudao_fast' lang: 'zh' sample_rate: 16000 cfg_path: # [optional] From 82f731c1530c6e46470d4497073438ec6ab25d5b Mon Sep 17 00:00:00 2001 From: Zhao Yuting <91456992+THUzyt21@users.noreply.github.com> Date: Tue, 27 Sep 2022 16:13:11 +0800 Subject: [PATCH 2/8] Update application.yaml change model --- paddlespeech/server/conf/application.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddlespeech/server/conf/application.yaml b/paddlespeech/server/conf/application.yaml index 55f241ec7..47b8b178f 100644 --- a/paddlespeech/server/conf/application.yaml +++ b/paddlespeech/server/conf/application.yaml @@ -142,7 +142,7 @@ cls_inference: ################### text task: punc; engine_type: python ####################### text_python: task: punc - model_type: 'ernie_linear_p3_wudao' + model_type: 'ernie_linear_p3_wudao_fast' lang: 'zh' sample_rate: 16000 cfg_path: # [optional] From d2da7f50d2982704dfb59184906cca96bff0c95b Mon Sep 17 00:00:00 2001 From: Zhao Yuting <91456992+THUzyt21@users.noreply.github.com> Date: Tue, 27 Sep 2022 16:27:49 +0800 Subject: [PATCH 3/8] Update text_engine.py precommihted already --- paddlespeech/server/engine/text/python/text_engine.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paddlespeech/server/engine/text/python/text_engine.py b/paddlespeech/server/engine/text/python/text_engine.py index 6167e7784..9f2a48d51 100644 --- a/paddlespeech/server/engine/text/python/text_engine.py +++ b/paddlespeech/server/engine/text/python/text_engine.py @@ -107,10 +107,11 @@ class PaddleTextConnectionHandler: assert len(tokens) == len(labels) text = '' + print(self._punc_list) for t, l in zip(tokens, labels): text += t if l != 0: # Non punc. - text += self._punc_list[l] + text += self._punc_list[l - 1] return text else: @@ -160,7 +161,7 @@ class TextEngine(BaseEngine): return False self.executor = TextServerExecutor() - self.executor._init_from_path( + self.executor._init_from_path_new( task=config.task, model_type=config.model_type, lang=config.lang, From 8ecf6796f3673d2565ab2949c2e4d4f303c7c9ab Mon Sep 17 00:00:00 2001 From: Zhao Yuting <91456992+THUzyt21@users.noreply.github.com> Date: Wed, 28 Sep 2022 15:23:49 +0800 Subject: [PATCH 4/8] Update text_engine.py --- paddlespeech/server/engine/text/python/text_engine.py | 1 - 1 file changed, 1 deletion(-) diff --git a/paddlespeech/server/engine/text/python/text_engine.py b/paddlespeech/server/engine/text/python/text_engine.py index 9f2a48d51..b4ad95c64 100644 --- a/paddlespeech/server/engine/text/python/text_engine.py +++ b/paddlespeech/server/engine/text/python/text_engine.py @@ -107,7 +107,6 @@ class PaddleTextConnectionHandler: assert len(tokens) == len(labels) text = '' - print(self._punc_list) for t, l in zip(tokens, labels): text += t if l != 0: # Non punc. From b9693a0e8e41636cdc1c141467a4fbee621119b7 Mon Sep 17 00:00:00 2001 From: Zhao Yuting <91456992+THUzyt21@users.noreply.github.com> Date: Thu, 29 Sep 2022 13:08:20 +0800 Subject: [PATCH 5/8] Update text_engine.py --- paddlespeech/server/engine/text/python/text_engine.py | 1 - 1 file changed, 1 deletion(-) diff --git a/paddlespeech/server/engine/text/python/text_engine.py b/paddlespeech/server/engine/text/python/text_engine.py index b4ad95c64..a871de35c 100644 --- a/paddlespeech/server/engine/text/python/text_engine.py +++ b/paddlespeech/server/engine/text/python/text_engine.py @@ -131,7 +131,6 @@ class TextEngine(BaseEngine): """ super(TextEngine, self).__init__() logger.debug("Create the TextEngine Instance") - def init(self, config: dict): """Init the Text Engine From 8c945c073d6764b20b0ccad7b4cf5f00c1180bd6 Mon Sep 17 00:00:00 2001 From: Zhao Yuting <91456992+THUzyt21@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:05:49 +0800 Subject: [PATCH 6/8] Update application.yaml --- paddlespeech/server/conf/application.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddlespeech/server/conf/application.yaml b/paddlespeech/server/conf/application.yaml index 47b8b178f..55f241ec7 100644 --- a/paddlespeech/server/conf/application.yaml +++ b/paddlespeech/server/conf/application.yaml @@ -142,7 +142,7 @@ cls_inference: ################### text task: punc; engine_type: python ####################### text_python: task: punc - model_type: 'ernie_linear_p3_wudao_fast' + model_type: 'ernie_linear_p3_wudao' lang: 'zh' sample_rate: 16000 cfg_path: # [optional] From 80837fd65812ddb64ce17c813ac1b05f27571458 Mon Sep 17 00:00:00 2001 From: Zhao Yuting <91456992+THUzyt21@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:06:57 +0800 Subject: [PATCH 7/8] Update punc_application.yaml --- demos/streaming_asr_server/conf/punc_application.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/streaming_asr_server/conf/punc_application.yaml b/demos/streaming_asr_server/conf/punc_application.yaml index 8456e2329..f947525e1 100644 --- a/demos/streaming_asr_server/conf/punc_application.yaml +++ b/demos/streaming_asr_server/conf/punc_application.yaml @@ -22,7 +22,7 @@ engine_list: ['text_python'] ################### text task: punc; engine_type: python ####################### text_python: task: punc - model_type: 'ernie_linear_p3_wudao_fast' + model_type: 'ernie_linear_p3_wudao' lang: 'zh' sample_rate: 16000 cfg_path: # [optional] From 304dc2603c583cda7d1bffb6f7d14eb7c40f96d0 Mon Sep 17 00:00:00 2001 From: Zhao Yuting <91456992+THUzyt21@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:08:37 +0800 Subject: [PATCH 8/8] Update text_engine.py --- .../server/engine/text/python/text_engine.py | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/paddlespeech/server/engine/text/python/text_engine.py b/paddlespeech/server/engine/text/python/text_engine.py index a871de35c..cc72c0543 100644 --- a/paddlespeech/server/engine/text/python/text_engine.py +++ b/paddlespeech/server/engine/text/python/text_engine.py @@ -107,11 +107,14 @@ class PaddleTextConnectionHandler: assert len(tokens) == len(labels) text = '' + is_fast_model = 'fast' in self.text_engine.config.model_type for t, l in zip(tokens, labels): text += t if l != 0: # Non punc. - text += self._punc_list[l - 1] - + if is_fast_model: + text += self._punc_list[l - 1] + else: + text += self._punc_list[l] return text else: raise NotImplementedError @@ -131,6 +134,7 @@ class TextEngine(BaseEngine): """ super(TextEngine, self).__init__() logger.debug("Create the TextEngine Instance") + def init(self, config: dict): """Init the Text Engine @@ -159,14 +163,23 @@ class TextEngine(BaseEngine): return False self.executor = TextServerExecutor() - self.executor._init_from_path_new( - task=config.task, - model_type=config.model_type, - lang=config.lang, - cfg_path=config.cfg_path, - ckpt_path=config.ckpt_path, - vocab_file=config.vocab_file) - + if 'fast' in config.model_type: + self.executor._init_from_path_new( + task=config.task, + model_type=config.model_type, + lang=config.lang, + cfg_path=config.cfg_path, + ckpt_path=config.ckpt_path, + vocab_file=config.vocab_file) + else: + self.executor._init_from_path( + task=config.task, + model_type=config.model_type, + lang=config.lang, + cfg_path=config.cfg_path, + ckpt_path=config.ckpt_path, + vocab_file=config.vocab_file) + logger.info("Using model: %s." % (config.model_type)) logger.info("Initialize Text server engine successfully on device: %s." % (self.device)) return True