From 8e45898772c3576ba26d90a54e5cc7391a4657c0 Mon Sep 17 00:00:00 2001 From: Benjamin Sparks Date: Tue, 18 Feb 2025 19:56:36 +0100 Subject: [PATCH] python3Packages.whisperx: init at 3.3.1 --- pkgs/by-name/wh/whisperx/package.nix | 1 + .../python-modules/whisperx/default.nix | 87 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 3 files changed, 90 insertions(+) create mode 100644 pkgs/by-name/wh/whisperx/package.nix create mode 100644 pkgs/development/python-modules/whisperx/default.nix diff --git a/pkgs/by-name/wh/whisperx/package.nix b/pkgs/by-name/wh/whisperx/package.nix new file mode 100644 index 0000000000000..c5b60fb97af61 --- /dev/null +++ b/pkgs/by-name/wh/whisperx/package.nix @@ -0,0 +1 @@ +{ python3Packages }: with python3Packages; toPythonApplication whisperx diff --git a/pkgs/development/python-modules/whisperx/default.nix b/pkgs/development/python-modules/whisperx/default.nix new file mode 100644 index 0000000000000..91298a1b86c94 --- /dev/null +++ b/pkgs/development/python-modules/whisperx/default.nix @@ -0,0 +1,87 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + setuptools, + + ctranslate2, + ctranslate2-cpp, + faster-whisper, + ffmpeg, + nltk, + pandas, + pyannote-audio, + torch, + torchaudio, + transformers, + + cudaSupport ? torch.cudaSupport, + cudaPackages, +}: + +let + # inherit (cudaPackages) cudaFlags cudnn nccl; + + ctranslate = ctranslate2.override { + ctranslate2-cpp = ctranslate2-cpp.override { + withCUDA = cudaSupport ? false; + withCuDNN = cudaSupport ? false; + }; + }; +in +buildPythonPackage rec { + pname = "whisperx"; + version = "3.3.1"; + pyproject = true; + + src = fetchFromGitHub { + owner = "m-bain"; + repo = "whisperX"; + tag = "v${version}"; + hash = "sha256-Wb9jKTs0rTdgjvcnKl1P8Uh6b5jzlkKgQBcJYA+7+W4="; + }; + + nativeBuildInputs = lib.optionals cudaSupport ( with cudaPackages; [ + + ]); + + build-system = [ setuptools ]; + + dependencies = [ + ctranslate + faster-whisper + nltk + pandas + pyannote-audio + torch + torchaudio + transformers + ]; + + pythonRelaxDeps = [ + "ctranslate2" + "faster-whisper" + ]; + + pythonImportsCheck = [ "whisperx" ]; + + # No tests in repository + doCheck = false; + + makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ ffmpeg ]}" ]; + + meta = { + mainProgram = "whisperx"; + description = "Automatic Speech Recognition with Word-level Timestamps (& Diarization)"; + homepage = "https://github.com/m-bain/whisperX"; + license = lib.licenses.bsd2; + maintainers = with lib.maintainers; [ bengsparks ]; + + platforms = + if cudaSupport then + lib.platforms.linux + else + lib.platforms.unix; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 2c30a1d273f97..2c0e9d0101785 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -18324,6 +18324,8 @@ self: super: with self; { whispers = callPackage ../development/python-modules/whispers { }; + whisperx = callPackage ../development/python-modules/whisperx { }; + whitenoise = callPackage ../development/python-modules/whitenoise { }; whodap = callPackage ../development/python-modules/whodap { };