From bba4bd532c1c9210444058c13929fc49fd55cd7e Mon Sep 17 00:00:00 2001 From: Adrian G L Date: Tue, 24 Mar 2026 12:37:09 +0100 Subject: [PATCH] feat: llama-swap transcribe --- flake.nix | 1 + modules/llama-swap.nix | 26 ++++++++++++++++++++++ packages/whisper-models/default.nix | 34 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 packages/whisper-models/default.nix diff --git a/flake.nix b/flake.nix index ac0d356..84a8481 100644 --- a/flake.nix +++ b/flake.nix @@ -66,6 +66,7 @@ qwen-asr = nixpkgs.legacyPackages.${system}.callPackage ./packages/qwen-asr.nix { }; llama-swap = nixpkgs.legacyPackages.${system}.callPackage ./packages/llama-swap { }; z-image-models = nixpkgs.legacyPackages.${system}.callPackage ./packages/z-image-models { }; + whisper-models = nixpkgs.legacyPackages.${system}.callPackage ./packages/whisper-models { }; }; # legolas diff --git a/modules/llama-swap.nix b/modules/llama-swap.nix index ea979be..c7e8323 100644 --- a/modules/llama-swap.nix +++ b/modules/llama-swap.nix @@ -10,7 +10,9 @@ environment.systemPackages = [ pkgs.unstable.llama-cpp-vulkan pkgs.unstable.stable-diffusion-cpp-vulkan + pkgs.unstable.whisper-cpp-vulkan inputs.self.packages.${system}.z-image-models + inputs.self.packages.${system}.whisper-models ]; services.llama-swap = { @@ -23,7 +25,9 @@ let llama-server = lib.getExe' pkgs.unstable.llama-cpp-vulkan "llama-server"; sd-server = lib.getExe' pkgs.unstable.stable-diffusion-cpp-vulkan "sd-server"; + whisper-server = lib.getExe' pkgs.unstable.whisper-cpp-vulkan "whisper-server"; z-image-models = inputs.self.packages.${system}.z-image-models; + whisper-models = inputs.self.packages.${system}.whisper-models; in { healthCheckTimeout = 180; @@ -99,6 +103,28 @@ llm = "${z-image-models}/models/Qwen3-4B-Instruct-2507-Q4_K_M.gguf"; }; }; + "distil-whisper-v3.5" = { + cmd = "${whisper-server} --host 127.0.0.1 --port $\{PORT\} -m $\{model\} --request-path /v1/audio/transcriptions --inference-path \"\""; + checkEndpoint = "/v1/audio/transcriptions/"; + proxy = "http://127.0.0.1:$\{PORT\}"; + ttl = 0; + aliases = [ + "whisper" + "whisper-1" + ]; + macros.model = "${whisper-models}/models/distil-large-v3.5.bin"; + }; + "nb-whisper-small" = { + cmd = "${whisper-server} --host 127.0.0.1 --port $\{PORT\} -m $\{model\} --request-path /v1/audio/transcriptions --inference-path \"\" --language no"; + checkEndpoint = "/v1/audio/transcriptions/"; + proxy = "http://127.0.0.1:$\{PORT\}"; + ttl = 0; + aliases = [ + "whisper-no" + "whisper-nb" + ]; + macros.model = "${whisper-models}/models/nb-whisper-small-q5_0.bin"; + }; }; }; }; diff --git a/packages/whisper-models/default.nix b/packages/whisper-models/default.nix new file mode 100644 index 0000000..8f7ae21 --- /dev/null +++ b/packages/whisper-models/default.nix @@ -0,0 +1,34 @@ +{ + lib, + fetchurl, + runCommand, +}: + +let + distilLargeV35 = fetchurl { + url = "https://huggingface.co/distil-whisper/distil-large-v3.5-ggml/resolve/main/ggml-model.bin"; + hash = "sha256-7CSYkZtJjF9rAAQa20VlASSzzZ8m9UX/+o9dEcKNzyY="; + name = "distil-large-v3.5.bin"; + }; + + nbWhisperSmallQ5 = fetchurl { + url = "https://huggingface.co/NbAiLab/nb-whisper-small/resolve/main/ggml-model-q5_0.bin"; + hash = "sha256-KpAlr7boJfxK5qRmceDLL0PmLx3shycN7qb+YbUoWiA="; + name = "nb-whisper-small-q5_0.bin"; + }; +in +runCommand "whisper-models" + { + version = "1.0.0"; + meta = { + description = "Whisper GGML models for whisper.cpp"; + homepage = "https://huggingface.co/distil-whisper/distil-large-v3.5-ggml"; + license = lib.licenses.mit; + platforms = lib.platforms.all; + }; + } + '' + mkdir -p $out/models + ln -s ${distilLargeV35} $out/models/distil-large-v3.5.bin + ln -s ${nbWhisperSmallQ5} $out/models/nb-whisper-small-q5_0.bin + ''