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
add intel xpu support (#2468)
AldarisXd43d0853dcf3
diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.pyindex 96c642e52..d274fb935 100644--- a/funasr/auto/auto_model.py+++ b/funasr/auto/auto_model.py@@ -182,7 +182,9 @@ class AutoModel:set_all_random_seed(kwargs.get("seed", 0))device = kwargs.get("device", "cuda")- if not torch.cuda.is_available() or kwargs.get("ngpu", 1) == 0:+ if ((device =="cuda" and not torch.cuda.is_available())+ or (device == "xpu" and not torch.xpu.is_available())+ or kwargs.get("ngpu", 1) == 0):device = "cpu"kwargs["batch_size"] = 1kwargs["device"] = devicediff --git a/funasr/frontends/fused.py b/funasr/frontends/fused.pyindex 0fa763900..0935910df 100644--- a/funasr/frontends/fused.py+++ b/funasr/frontends/fused.py@@ -78,6 +78,8 @@ class FusedFrontends(nn.Module):self.factors = [frontend.hop_length // self.gcd for frontend in self.frontends]if torch.cuda.is_available():dev = "cuda"+ elif torch.xpu.is_available():+ dev = "xpu"else:dev = "cpu"if self.align_method == "linear_projection":diff --git a/funasr/utils/export_utils.py b/funasr/utils/export_utils.pyindex ca04d75ce..c89dd77f4 100644--- a/funasr/utils/export_utils.py+++ b/funasr/utils/export_utils.py@@ -28,12 +28,12 @@ def export(**kwargs,)elif type == "torchscript":- device = "cuda" if torch.cuda.is_available() else "cpu"+ device = "cuda" if torch.cuda.is_available() else "xpu" if torch.xpu.is_available() else "cpu"print("Exporting torchscripts on device {}".format(device))_torchscripts(m, path=export_dir, device=device)elif type == "bladedisc":assert (- torch.cuda.is_available()+ torch.cuda.is_available() or torch.xpu.is_available()), "Currently bladedisc optimization for FunASR only supports GPU"# bladedisc only optimizes encoder/decoder modulesif hasattr(m, "encoder") and hasattr(m, "decoder"):@@ -44,7 +44,7 @@ def export(elif type == "onnx_fp16":assert (- torch.cuda.is_available()+ torch.cuda.is_available() or torch.xpu.is_available()), "Currently onnx_fp16 optimization for FunASR only supports GPU"if hasattr(m, "encoder") and hasattr(m, "decoder"):