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
oom fix
游雁604ae30fdbe9
diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.pyindex 60bfeff10..96c642e52 100644--- a/funasr/auto/auto_model.py+++ b/funasr/auto/auto_model.py@@ -147,7 +147,9 @@ class AutoModel:# if spk_model is not None, build spk model else Nonespk_model = kwargs.get("spk_model", None)spk_kwargs = {} if kwargs.get("spk_kwargs", {}) is None else kwargs.get("spk_kwargs", {})- cb_kwargs = {} if spk_kwargs.get("cb_kwargs", {}) is None else spk_kwargs.get("cb_kwargs", {})+ cb_kwargs = (+ {} if spk_kwargs.get("cb_kwargs", {}) is None else spk_kwargs.get("cb_kwargs", {})+ )if spk_model is not None:logging.info("Building SPK model.")spk_kwargs["model"] = spk_model@@ -368,8 +370,8 @@ class AutoModel:pbar.set_description(f"rtf_avg: {time_escape_total/time_speech_total:0.3f}")device = next(model.parameters()).device- if device.type == 'cuda':- with torch.cuda.device():+ if device.type == "cuda":+ with torch.cuda.device(device):torch.cuda.empty_cache()return asr_result_listdiff --git a/funasr/bin/train.py b/funasr/bin/train.pyindex 45e23a8c6..c56d04752 100644--- a/funasr/bin/train.py+++ b/funasr/bin/train.py@@ -221,10 +221,10 @@ def main(**kwargs):)trainer.start_step = 0- # device = next(model.parameters()).device- # if device.type == 'cuda':- # with torch.cuda.device():- # torch.cuda.empty_cache()+ device = next(model.parameters()).device+ if device.type == "cuda":+ with torch.cuda.device(device):+ torch.cuda.empty_cache()time_escaped = (time.perf_counter() - time_slice_i) / 3600.0logging.info(diff --git a/funasr/bin/train_ds.py b/funasr/bin/train_ds.pyindex b28752ba8..10a5d087f 100644--- a/funasr/bin/train_ds.py+++ b/funasr/bin/train_ds.py@@ -184,10 +184,10 @@ def main(**kwargs):)trainer.start_step = 0- # device = next(model.parameters()).device- # if device.type == 'cuda':- # with torch.cuda.device():- # torch.cuda.empty_cache()+ device = next(model.parameters()).device+ if device.type == "cuda":+ with torch.cuda.device(device):+ torch.cuda.empty_cache()time_escaped = (time.perf_counter() - time_slice_i) / 3600.0logging.info(