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
bug fix for empty text
shixian.shi9844be44e9e0
diff --git a/funasr/auto/auto_frontend.py b/funasr/auto/auto_frontend.pyindex 8f2f06920..35ea23f13 100644--- a/funasr/auto/auto_frontend.py+++ b/funasr/auto/auto_frontend.py@@ -1,3 +1,8 @@+#!/usr/bin/env python3+# -*- encoding: utf-8 -*-+# Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.+# MIT License (https://opensource.org/licenses/MIT)+import jsonimport timeimport torch@@ -12,15 +17,14 @@ from omegaconf import DictConfig, OmegaConf, ListConfigfrom funasr.register import tablesfrom funasr.utils.load_utils import load_bytesfrom funasr.download.file import download_from_url+from funasr.auto.auto_model import prepare_data_iterator+from funasr.utils.timestamp_tools import timestamp_sentencefrom funasr.download.download_from_hub import download_modelfrom funasr.utils.vad_utils import slice_padding_audio_samplesfrom funasr.train_utils.set_all_random_seed import set_all_random_seedfrom funasr.train_utils.load_pretrained_model import load_pretrained_modelfrom funasr.utils.load_utils import load_audio_text_image_video, extract_fbank-from funasr.utils.timestamp_tools import timestamp_sentencefrom funasr.models.campplus.utils import sv_chunk, postprocess, distribute_spk-from funasr.auto.auto_model import prepare_data_iterator-class AutoFrontend:diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.pyindex 66c07509b..2cb2e1d18 100644--- a/funasr/auto/auto_model.py+++ b/funasr/auto/auto_model.py@@ -1,3 +1,8 @@+#!/usr/bin/env python3+# -*- encoding: utf-8 -*-+# Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.+# MIT License (https://opensource.org/licenses/MIT)+import jsonimport timeimport copy@@ -12,12 +17,12 @@ from tqdm import tqdmfrom funasr.register import tablesfrom funasr.utils.load_utils import load_bytesfrom funasr.download.file import download_from_url+from funasr.utils.timestamp_tools import timestamp_sentencefrom funasr.download.download_from_hub import download_modelfrom funasr.utils.vad_utils import slice_padding_audio_samples+from funasr.utils.load_utils import load_audio_text_image_videofrom funasr.train_utils.set_all_random_seed import set_all_random_seedfrom funasr.train_utils.load_pretrained_model import load_pretrained_model-from funasr.utils.load_utils import load_audio_text_image_video-from funasr.utils.timestamp_tools import timestamp_sentencefrom funasr.models.campplus.utils import sv_chunk, postprocess, distribute_spktry:from funasr.models.campplus.cluster_backend import ClusterBackend@@ -381,11 +386,14 @@ class AutoModel:return_raw_text = kwargs.get('return_raw_text', False)# step.3 compute punc modelif self.punc_model is not None:- self.punc_kwargs.update(cfg)- punc_res = self.inference(result["text"], model=self.punc_model, kwargs=self.punc_kwargs, **cfg)- raw_text = copy.copy(result["text"])- if return_raw_text: result['raw_text'] = raw_text- result["text"] = punc_res[0]["text"]+ if not len(result["text"]):+ result['raw_text'] = ''+ else:+ self.punc_kwargs.update(cfg)+ punc_res = self.inference(result["text"], model=self.punc_model, kwargs=self.punc_kwargs, **cfg)+ raw_text = copy.copy(result["text"])+ if return_raw_text: result['raw_text'] = raw_text+ result["text"] = punc_res[0]["text"]else:raw_text = Nonediff --git a/funasr/models/seaco_paraformer/model.py b/funasr/models/seaco_paraformer/model.pyindex cfdd26a79..21ad87499 100644--- a/funasr/models/seaco_paraformer/model.py+++ b/funasr/models/seaco_paraformer/model.py@@ -25,8 +25,8 @@ from funasr.models.paraformer.search import Hypothesisfrom funasr.train_utils.device_funcs import force_gatherablefrom funasr.models.bicif_paraformer.model import BiCifParaformerfrom funasr.losses.label_smoothing_loss import LabelSmoothingLoss-from funasr.utils.timestamp_tools import ts_prediction_lfr6_standardfrom funasr.models.transformer.utils.add_sos_eos import add_sos_eos+from funasr.utils.timestamp_tools import ts_prediction_lfr6_standardfrom funasr.models.transformer.utils.nets_utils import make_pad_mask, pad_listfrom funasr.utils.load_utils import load_audio_text_image_video, extract_fbank