From b18e27be3ffdb7bf70242ed6d71f721ebfcdfe0c Mon Sep 17 00:00:00 2001
From: 仁迷 <haoneng.lhn@alibaba-inc.com>
Date: 星期日, 29 一月 2023 11:48:08 +0800
Subject: [PATCH] add 8k paraformer recipe
---
funasr/bin/asr_inference_paraformer_vad_punc.py | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/funasr/bin/asr_inference_paraformer_vad_punc.py b/funasr/bin/asr_inference_paraformer_vad_punc.py
index 85838aa..a8af835 100644
--- a/funasr/bin/asr_inference_paraformer_vad_punc.py
+++ b/funasr/bin/asr_inference_paraformer_vad_punc.py
@@ -174,7 +174,7 @@
self.converter = converter
self.tokenizer = tokenizer
is_use_lm = lm_weight != 0.0 and lm_file is not None
- if ctc_weight == 0.0 and not is_use_lm:
+ if (ctc_weight == 0.0 or asr_model.ctc == None) and not is_use_lm:
beam_search = None
self.beam_search = beam_search
logging.info(f"Beam_search: {self.beam_search}")
@@ -635,9 +635,15 @@
text_postprocessed, time_stamp_postprocessed, word_lists = postprocessed_result[0], \
postprocessed_result[1], \
postprocessed_result[2]
- text_postprocessed_punc, punc_id_list = text2punc(word_lists, 20)
- text_postprocessed_punc_time_stamp = "predictions: {} time_stamp: {}".format(
- text_postprocessed_punc, time_stamp_postprocessed)
+ if len(word_lists) > 0:
+ text_postprocessed_punc, punc_id_list = text2punc(word_lists, 20)
+ text_postprocessed_punc_time_stamp = "predictions: {} time_stamp: {}".format(
+ text_postprocessed_punc, time_stamp_postprocessed)
+ else:
+ text_postprocessed_punc = ""
+ punc_id_list = []
+ text_postprocessed_punc_time_stamp = ""
+
else:
text_postprocessed = ""
time_stamp_postprocessed = ""
@@ -666,7 +672,7 @@
time_stamp_postprocessed))
logging.info("decoding, feature length total: {}, forward_time total: {:.4f}, rtf avg: {:.4f}".
- format(length_total, forward_time_total, 100 * forward_time_total / (length_total * lfr_factor)))
+ format(length_total, forward_time_total, 100 * forward_time_total / (length_total * lfr_factor+1e-6)))
return asr_result_list
return _forward
--
Gitblit v1.9.1