From 39de3adfbc12bc491f6da9eb9ffdc5122a3f623d Mon Sep 17 00:00:00 2001
From: 语帆 <yf352572@alibaba-inc.com>
Date: 星期三, 28 二月 2024 16:39:15 +0800
Subject: [PATCH] test
---
funasr/models/lcbnet/model.py | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/funasr/models/lcbnet/model.py b/funasr/models/lcbnet/model.py
index 45b1ee5..6ee5342 100644
--- a/funasr/models/lcbnet/model.py
+++ b/funasr/models/lcbnet/model.py
@@ -274,15 +274,12 @@
ind: int
"""
with autocast(False):
- pdb.set_trace()
# Data augmentation
if self.specaug is not None and self.training:
speech, speech_lengths = self.specaug(speech, speech_lengths)
- pdb.set_trace()
# Normalization for feature: e.g. Global-CMVN, Utterance-CMVN
if self.normalize is not None:
speech, speech_lengths = self.normalize(speech, speech_lengths)
- pdb.set_trace()
# Forward encoder
# feats: (Batch, Length, Dim)
# -> encoder_out: (Batch, Length2, Dim2)
@@ -299,7 +296,6 @@
if intermediate_outs is not None:
return (encoder_out, intermediate_outs), encoder_out_lens
- pdb.set_trace()
return encoder_out, encoder_out_lens
def _calc_att_loss(
@@ -442,12 +438,18 @@
speech = speech.to(device=kwargs["device"])
speech_lengths = speech_lengths.to(device=kwargs["device"])
- pdb.set_trace()
# Encoder
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, 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)
@@ -455,7 +457,7 @@
nbest_hyps = nbest_hyps[: self.nbest]
-
+ pdb.set_trace()
results = []
b, n, d = encoder_out.size()
for i in range(b):
@@ -477,10 +479,13 @@
# 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}
results.append(result_i)
--
Gitblit v1.9.1