From 2cbebbb33435dc490b6a092f2e5903c7f0e3e33c Mon Sep 17 00:00:00 2001
From: zhifu gao <zhifu.gzf@alibaba-inc.com>
Date: 星期二, 31 一月 2023 17:54:02 +0800
Subject: [PATCH] Merge pull request #52 from alibaba-damo-academy/dev
---
funasr/bin/asr_inference_paraformer_vad_punc.py | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/funasr/bin/asr_inference_paraformer_vad_punc.py b/funasr/bin/asr_inference_paraformer_vad_punc.py
index a8af835..619e6fd 100644
--- a/funasr/bin/asr_inference_paraformer_vad_punc.py
+++ b/funasr/bin/asr_inference_paraformer_vad_punc.py
@@ -3,6 +3,7 @@
import logging
import sys
import time
+import json
from pathlib import Path
from typing import Optional
from typing import Sequence
@@ -234,6 +235,8 @@
predictor_outs = self.asr_model.calc_predictor(enc, enc_len)
pre_acoustic_embeds, pre_token_length, alphas, pre_peak_index = predictor_outs[0], predictor_outs[1], predictor_outs[2], predictor_outs[3]
+ if torch.max(pre_token_length) < 1:
+ return []
pre_token_length = pre_token_length.round().long()
decoder_outs = self.asr_model.cal_decoder_with_predictor(enc, enc_len, pre_acoustic_embeds, pre_token_length)
decoder_out, ys_pad_lens = decoder_outs[0], decoder_outs[1]
@@ -601,7 +604,7 @@
results = speech2text(**batch)
if len(results) < 1:
hyp = Hypothesis(score=0.0, scores={}, states={}, yseq=[])
- results = [[" ", ["<space>"], [2], 0, 1, 6]] * nbest
+ results = [[" ", ["sil"], [2], 0, 1, 6]] * nbest
time_end = time.time()
forward_time = time_end - time_beg
lfr_factor = results[0][-1]
@@ -637,8 +640,9 @@
postprocessed_result[2]
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)
+ text_postprocessed_punc_time_stamp = json.dumps({"predictions": text_postprocessed_punc,
+ "time_stamp": time_stamp_postprocessed},
+ ensure_ascii=False)
else:
text_postprocessed_punc = ""
punc_id_list = []
--
Gitblit v1.9.1