From e9d2cfc3a134b00f4e98271fbee3838d1ccecbcc Mon Sep 17 00:00:00 2001
From: VirtuosoQ <2416050435@qq.com>
Date: 星期五, 26 四月 2024 14:59:30 +0800
Subject: [PATCH] FunASR java http  client

---
 funasr/models/lcbnet/model.py |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/funasr/models/lcbnet/model.py b/funasr/models/lcbnet/model.py
index 82a1b78..3ac319c 100644
--- a/funasr/models/lcbnet/model.py
+++ b/funasr/models/lcbnet/model.py
@@ -181,8 +181,7 @@
                 text: (Batch, Length)
                 text_lengths: (Batch,)
         """
-        # import pdb;
-        # pdb.set_trace()
+
         if len(text_lengths.size()) > 1:
             text_lengths = text_lengths[:, 0]
         if len(speech_lengths.size()) > 1:
@@ -428,7 +427,10 @@
             time2 = time.perf_counter()
             meta_data["load_data"] = f"{time2 - time1:0.3f}"
             audio_sample_list = sample_list[0]
-            ocr_sample_list = sample_list[1]
+            if len(sample_list) >1:
+                ocr_sample_list = sample_list[1]
+            else:
+                ocr_sample_list = [[294, 0]]
             speech, speech_lengths = extract_fbank(audio_sample_list, data_type=kwargs.get("data_type", "sound"),
                                                    frontend=frontend)
             time3 = time.perf_counter()
@@ -442,14 +444,13 @@
         encoder_out, encoder_out_lens = self.encode(speech, speech_lengths)
         if isinstance(encoder_out, tuple):
             encoder_out = encoder_out[0]
-        
+
         ocr_list_new = [[x + 1 if x != 0 else x for x in sublist] for sublist in ocr_sample_list]
-        ocr = torch.tensor(ocr_list_new)
-        ocr_lengths = ocr.new_full([1], dtype=torch.long, fill_value=ocr.size(1))
+        ocr = torch.tensor(ocr_list_new).to(device=kwargs["device"])
+        ocr_lengths = ocr.new_full([1], dtype=torch.long, fill_value=ocr.size(1)).to(device=kwargs["device"])
         ocr, ocr_lens, _ = self.text_encoder(ocr, ocr_lengths)
         fusion_out, _, _, _ = self.fusion_encoder(encoder_out,None, ocr, None)
         encoder_out = encoder_out + fusion_out
-        pdb.set_trace()
         # c. Passed the encoder result and the beam search
         nbest_hyps = self.beam_search(
             x=encoder_out[0], maxlenratio=kwargs.get("maxlenratio", 0.0), minlenratio=kwargs.get("minlenratio", 0.0)
@@ -457,7 +458,6 @@
         
         nbest_hyps = nbest_hyps[: self.nbest]
 
-        pdb.set_trace()
         results = []
         b, n, d = encoder_out.size()
         for i in range(b):
@@ -479,12 +479,9 @@
                 # remove blank symbol id, which is assumed to be 0
                 token_int = list(filter(lambda x: x != self.eos and x != self.sos and x != self.blank_id, token_int))
                 
-                pdb.set_trace()
                 # Change integer-ids to tokens
                 token = tokenizer.ids2tokens(token_int)
-                pdb.set_trace()
                 text = tokenizer.tokens2text(token)
-                pdb.set_trace()
 
                 text_postprocessed, _ = postprocess_utils.sentence_postprocess(token)
                 result_i = {"key": key[i], "token": token, "text": text_postprocessed}

--
Gitblit v1.9.1