From 579b998ded8756f1c0213c94fc7adb5ef8bb5647 Mon Sep 17 00:00:00 2001
From: hnluo <haoneng.lhn@alibaba-inc.com>
Date: 星期四, 09 二月 2023 15:26:57 +0800
Subject: [PATCH] Merge pull request #83 from alibaba-damo-academy/dev_lzr

---
 funasr/bin/asr_inference.py    |   10 ----------
 funasr/models/predictor/cif.py |    6 ++++--
 funasr/utils/asr_utils.py      |   16 ++++------------
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/funasr/bin/asr_inference.py b/funasr/bin/asr_inference.py
index d419018..16fa3e5 100644
--- a/funasr/bin/asr_inference.py
+++ b/funasr/bin/asr_inference.py
@@ -464,16 +464,6 @@
     
     return _forward
 
-def set_parameters(language: str = None,
-                   sample_rate: Union[int, Dict[Any, int]] = None):
-    if language is not None:
-        global global_asr_language
-        global_asr_language = language
-    if sample_rate is not None:
-        global global_sample_rate
-        global_sample_rate = sample_rate
-
-
 def get_parser():
     parser = config_argparse.ArgumentParser(
         description="ASR Decoding",
diff --git a/funasr/models/predictor/cif.py b/funasr/models/predictor/cif.py
index 00c5a3e..c34759d 100644
--- a/funasr/models/predictor/cif.py
+++ b/funasr/models/predictor/cif.py
@@ -68,7 +68,8 @@
             mask_2 = torch.cat([ones_t, mask], dim=1)
             mask = mask_2 - mask_1
             tail_threshold = mask * tail_threshold
-            alphas = torch.cat([alphas, tail_threshold], dim=1)
+            alphas = torch.cat([alphas, zeros_t], dim=1)
+            alphas = torch.add(alphas, tail_threshold)
         else:
             tail_threshold = torch.tensor([tail_threshold], dtype=alphas.dtype).to(alphas.device)
             tail_threshold = torch.reshape(tail_threshold, (1, 1))
@@ -597,7 +598,8 @@
             mask_2 = torch.cat([ones_t, mask], dim=1)
             mask = mask_2 - mask_1
             tail_threshold = mask * tail_threshold
-            alphas = torch.cat([alphas, tail_threshold], dim=1)
+            alphas = torch.cat([alphas, zeros_t], dim=1)
+            alphas = torch.add(alphas, tail_threshold)
         else:
             tail_threshold = torch.tensor([tail_threshold], dtype=alphas.dtype).to(alphas.device)
             tail_threshold = torch.reshape(tail_threshold, (1, 1))
diff --git a/funasr/utils/asr_utils.py b/funasr/utils/asr_utils.py
index 76b20a5..a3ff3e3 100644
--- a/funasr/utils/asr_utils.py
+++ b/funasr/utils/asr_utils.py
@@ -186,22 +186,11 @@
 
     return wav_list
 
-
-def set_parameters(language: str = None):
-    if language is not None:
-        global global_asr_language
-        global_asr_language = language
-
-
 def compute_wer(hyp_list: List[Any],
                 ref_list: List[Any],
                 lang: str = None) -> Dict[str, Any]:
     assert len(hyp_list) > 0, 'hyp list is empty'
     assert len(ref_list) > 0, 'ref list is empty'
-
-    if lang is not None:
-        global global_asr_language
-        global_asr_language = lang
 
     rst = {
         'Wrd': 0,
@@ -216,12 +205,15 @@
         'wrong_sentences': 0
     }
 
+    if lang is None:
+        lang = global_asr_language
+
     for h_item in hyp_list:
         for r_item in ref_list:
             if h_item['key'] == r_item['key']:
                 out_item = compute_wer_by_line(h_item['value'],
                                                r_item['value'],
-                                               global_asr_language)
+                                               lang)
                 rst['Wrd'] += out_item['nwords']
                 rst['Corr'] += out_item['cor']
                 rst['wrong_words'] += out_item['wrong']

--
Gitblit v1.9.1