Skip to content

Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.

update

R1ckShid097d0ca4547
diff --git a/examples/industrial_data_pretraining/paraformer/export.py b/examples/industrial_data_pretraining/paraformer/export.py
index fd5938aba..a84ecac0f 100644
--- a/examples/industrial_data_pretraining/paraformer/export.py
+++ b/examples/industrial_data_pretraining/paraformer/export.py
@@ -10,7 +10,7 @@
from funasr import AutoModel
model = AutoModel(
- model="iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch",
+ model="iic/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404",
)
res = model.export(type="torchscript", quantize=False)
diff --git a/funasr/models/contextual_paraformer/export_meta.py b/funasr/models/contextual_paraformer/export_meta.py
index 75437893e..5fce7acd5 100644
--- a/funasr/models/contextual_paraformer/export_meta.py
+++ b/funasr/models/contextual_paraformer/export_meta.py
@@ -16,6 +16,21 @@ class ContextualEmbedderExport2(ContextualEmbedderExport):
self.embedding = model.bias_embed
model.bias_encoder.batch_first = False
self.bias_encoder = model.bias_encoder
+
+ def export_dummy_inputs(self):
+ hotword = torch.tensor(
+ [
+ [10, 11, 12, 13, 14, 10, 11, 12, 13, 14],
+ [100, 101, 0, 0, 0, 0, 0, 0, 0, 0],
+ [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [10, 11, 12, 13, 14, 10, 11, 12, 13, 14],
+ [100, 101, 0, 0, 0, 0, 0, 0, 0, 0],
+ [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ ],
+ dtype=torch.int32,
+ )
+ # hotword_length = torch.tensor([10, 2, 1], dtype=torch.int32)
+ return (hotword)
def export_rebuild_model(model, **kwargs):
diff --git a/funasr/models/sanm/attention.py b/funasr/models/sanm/attention.py
index 08f7dc7f5..c7e8a8e06 100644
--- a/funasr/models/sanm/attention.py
+++ b/funasr/models/sanm/attention.py
@@ -780,7 +780,7 @@ class MultiHeadedAttentionCrossAttExport(nn.Module):
return q, k, v
def forward_attention(self, value, scores, mask, ret_attn):
- scores = scores + mask
+ scores = scores + mask.to(scores.device)
self.attn = torch.softmax(scores, dim=-1)
context_layer = torch.matmul(self.attn, value) # (batch, head, time1, d_k)
diff --git a/funasr/models/whisper/model.py b/funasr/models/whisper/model.py
index 8e9245af5..4710b9cb1 100644
--- a/funasr/models/whisper/model.py
+++ b/funasr/models/whisper/model.py
@@ -7,7 +7,10 @@ import torch
import torch.nn.functional as F
from torch import Tensor
from torch import nn
+
import whisper
+# import whisper_timestamped as whisper
+
from funasr.utils.load_utils import load_audio_text_image_video, extract_fbank
from funasr.register import tables
@@ -108,8 +111,12 @@ class WhisperWarp(nn.Module):
# decode the audio
options = whisper.DecodingOptions(**kwargs.get("DecodingOptions", {}))
- result = whisper.decode(self.model, speech, options)
+
+ result = whisper.decode(self.model, speech, language='english')
+ # result = whisper.transcribe(self.model, speech)
+ import pdb; pdb.set_trace()
+
results = []
result_i = {"key": key[0], "text": result.text}
diff --git a/funasr/utils/export_utils.py b/funasr/utils/export_utils.py
index 1deeaa758..ba200a6fd 100644
--- a/funasr/utils/export_utils.py
+++ b/funasr/utils/export_utils.py
@@ -83,7 +83,10 @@ def _torchscripts(model, path, device='cuda'):
if device == 'cuda':
model = model.cuda()
- dummy_input = tuple([i.cuda() for i in dummy_input])
+ if isinstance(dummy_input, torch.Tensor):
+ dummy_input = dummy_input.cuda()
+ else:
+ dummy_input = tuple([i.cuda() for i in dummy_input])
# model_script = torch.jit.script(model)
model_script = torch.jit.trace(model, dummy_input)