Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
commit
语帆920331972a13
diff --cc examples/industrial_data_pretraining/contextual_paraformer/demo.shindex 8fc66f34f,1bd4f7f5b..1bd4f7f5bmode 100644,100755..100755--- a/examples/industrial_data_pretraining/contextual_paraformer/demo.sh+++ b/examples/industrial_data_pretraining/contextual_paraformer/demo.shdiff --cc funasr/auto/auto_model.pyindex 921ede809,9bb9ce07d..ec3c3f370--- a/funasr/auto/auto_model.py+++ b/funasr/auto/auto_model.py@@@ -162,16 -158,13 +163,15 @@@ class AutoModeltokenizer_class = tables.tokenizer_classes.get(tokenizer)tokenizer = tokenizer_class(**kwargs["tokenizer_conf"])kwargs["tokenizer"] = tokenizer- kwargs["token_list"] = tokenizer.token_list- vocab_size = len(tokenizer.token_list)++ kwargs["token_list"] = tokenizer.token_list if hasattr(tokenizer, "token_list") else None+ kwargs["token_list"] = tokenizer.get_vocab() if hasattr(tokenizer, "get_vocab") else kwargs["token_list"]+ vocab_size = len(kwargs["token_list"]) if kwargs["token_list"] is not None else -1else:vocab_size = -1-# build frontendfrontend = kwargs.get("frontend", None)-+ kwargs["input_size"] = Noneif frontend is not None:frontend_class = tables.frontend_classes.get(frontend)frontend = frontend_class(**kwargs["frontend_conf"])diff --cc funasr/models/contextual_paraformer/model.pyindex 49868a8f4,1c0805ab0..7d6f729a8--- a/funasr/models/contextual_paraformer/model.py+++ b/funasr/models/contextual_paraformer/model.py@@@ -194,8 -194,10 +193,8 @@@ class ContextualParaformer(Paraformer)sematic_embeds, decoder_out_1st = self.sampler(encoder_out, encoder_out_lens, ys_pad, ys_pad_lens,pre_acoustic_embeds, contextual_info)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 decoderdecoder_outs = self.decoder(encoder_out, encoder_out_lens, sematic_embeds, ys_pad_lens, contextual_info=contextual_infodiff --cc funasr/models/seaco_paraformer/model.pyindex 20b0cc838,e0467b3c4..a8b1f1fb1--- a/funasr/models/seaco_paraformer/model.py+++ b/funasr/models/seaco_paraformer/model.py@@@ -128,8 -130,9 +128,8 @@@ class SeacoParaformer(BiCifParaformer,hotword_pad = kwargs.get("hotword_pad")hotword_lengths = kwargs.get("hotword_lengths")dha_pad = kwargs.get("dha_pad")-+batch_size = speech.shape[0]- self.step_cur += 1# for data-paralleltext = text[:, : text_lengths.max()]speech = speech[:, :speech_lengths.max()]@@@ -219,11 -225,17 +222,11 @@@contextual_info = selected.squeeze(0).repeat(encoder_out.shape[0], 1, 1).to(encoder_out.device)num_hot_word = contextual_info.shape[1]_contextual_length = torch.Tensor([num_hot_word]).int().repeat(encoder_out.shape[0]).to(encoder_out.device)-+# ASF Coreif nfilter > 0 and nfilter < num_hot_word:- for dec in self.seaco_decoder.decoders:- dec.reserve_attn = True-- # cif_attended, _ = self.decoder2(contextual_info, _contextual_length, sematic_embeds, ys_pad_lens)- dec_attended, _ = self.seaco_decoder(contextual_info, _contextual_length, decoder_hidden, ys_pad_lens)- # cif_filter = torch.topk(self.decoder2.decoders[-1].attn_mat[0][0].sum(0).sum(0)[:-1], min(nfilter, num_hot_word-1))[1].tolist()-- hotword_scores = self.seaco_decoder.decoders[-1].attn_mat[0][0].sum(0).sum(0)[:-1]+ hotword_scores = self.seaco_decoder.forward_asf6(contextual_info, _contextual_length, decoder_hidden, ys_pad_lens)+ hotword_scores = hotword_scores[0].sum(0).sum(0)# hotword_scores /= torch.sqrt(torch.tensor(hw_lengths)[:-1].float()).to(hotword_scores.device)dec_filter = torch.topk(hotword_scores, min(nfilter, num_hot_word-1))[1].tolist()add_filter = dec_filterdiff --cc funasr/train_utils/load_pretrained_model.pyindex ea2372537,9127e2fe1..0c46449e4--- a/funasr/train_utils/load_pretrained_model.py+++ b/funasr/train_utils/load_pretrained_model.py@@@ -61,8 -96,8 +61,9 @@@ def load_pretrained_modelobj = modeldst_state = obj.state_dict()+print(f"ckpt: {path}")+if oss_bucket is None:src_state = torch.load(path, map_location=map_location)else: