From 149063ced4d2d5269f0472677228eadfcb4a4d8a Mon Sep 17 00:00:00 2001
From: 维石 <shixian.shi@alibaba-inc.com>
Date: 星期三, 17 四月 2024 14:33:24 +0800
Subject: [PATCH] update seaco finetune
---
funasr/models/paraformer_streaming/model.py | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/funasr/models/paraformer_streaming/model.py b/funasr/models/paraformer_streaming/model.py
index 45875a2..499b487 100644
--- a/funasr/models/paraformer_streaming/model.py
+++ b/funasr/models/paraformer_streaming/model.py
@@ -235,8 +235,7 @@
decoder_out_1st = None
pre_loss_att = None
if self.sampling_ratio > 0.0:
- if self.step_cur < 2:
- logging.info("enable sampler in paraformer, sampling_ratio: {}".format(self.sampling_ratio))
+
if self.use_1st_decoder_loss:
sematic_embeds, decoder_out_1st, pre_loss_att = \
self.sampler_with_grad(encoder_out, encoder_out_lens, ys_pad,
@@ -246,8 +245,6 @@
self.sampler(encoder_out, encoder_out_lens, ys_pad,
ys_pad_lens, pre_acoustic_embeds, scama_mask)
else:
- if self.step_cur < 2:
- logging.info("disable sampler in paraformer, sampling_ratio: {}".format(self.sampling_ratio))
sematic_embeds = pre_acoustic_embeds
# 1. Forward decoder
@@ -534,10 +531,14 @@
for i in range(n):
kwargs["is_final"] = _is_final and i == n -1
audio_sample_i = audio_sample[i*chunk_stride_samples:(i+1)*chunk_stride_samples]
-
- # extract fbank feats
- speech, speech_lengths = extract_fbank([audio_sample_i], data_type=kwargs.get("data_type", "sound"),
- frontend=frontend, cache=cache["frontend"], is_final=kwargs["is_final"])
+ if kwargs["is_final"] and len(audio_sample_i) < 960:
+ cache["encoder"]["tail_chunk"] = True
+ speech = cache["encoder"]["feats"]
+ speech_lengths = torch.tensor([speech.shape[1]], dtype=torch.int64).to(speech.device)
+ else:
+ # extract fbank feats
+ speech, speech_lengths = extract_fbank([audio_sample_i], data_type=kwargs.get("data_type", "sound"),
+ frontend=frontend, cache=cache["frontend"], is_final=kwargs["is_final"])
time3 = time.perf_counter()
meta_data["extract_feat"] = f"{time3 - time2:0.3f}"
meta_data["batch_data_time"] = speech_lengths.sum().item() * frontend.frame_shift * frontend.lfr_n / 1000
@@ -563,5 +564,8 @@
ibest_writer["text"][key[0]] = text_postprocessed
return result, meta_data
-
-
+
+ def export(self, **kwargs):
+ from .export_meta import export_rebuild_model
+ models = export_rebuild_model(model=self, **kwargs)
+ return models
\ No newline at end of file
--
Gitblit v1.9.1