at master 2.6 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # build-system 8 setuptools, 9 10 # dependencies 11 ctranslate2, 12 faster-whisper, 13 nltk, 14 pandas, 15 pyannote-audio, 16 torch, 17 torchaudio, 18 transformers, 19 20 # native packages 21 ffmpeg, 22 ctranslate2-cpp, # alias for `pkgs.ctranslate2`, required due to colliding with the `ctranslate2` Python module. 23 24 # enable GPU support 25 cudaSupport ? torch.cudaSupport, 26}: 27 28let 29 ctranslate = ctranslate2.override { 30 ctranslate2-cpp = ctranslate2-cpp.override { 31 withCUDA = cudaSupport; 32 withCuDNN = cudaSupport; 33 }; 34 }; 35in 36buildPythonPackage rec { 37 pname = "whisperx"; 38 version = "3.4.3"; 39 pyproject = true; 40 41 src = fetchFromGitHub { 42 owner = "m-bain"; 43 repo = "whisperX"; 44 tag = "v${version}"; 45 hash = "sha256-zx77Fx8KYTWCFcC6Uy6pbe8LJtXP3b6lkwuOSEEYJfU="; 46 }; 47 48 build-system = [ setuptools ]; 49 50 dependencies = [ 51 ctranslate 52 faster-whisper 53 nltk 54 pandas 55 pyannote-audio # Missing from pyproject.toml, but used in `whisperx/vad.py` 56 torch 57 torchaudio 58 transformers 59 ]; 60 61 # As `makeWrapperArgs` does not apply to the module, and whisperx depends on `ffmpeg`, 62 # we replace the `"ffmpeg"` string in `subprocess.run` with the full path to the binary. 63 # This works for both the program and the module. 64 # Every update, the codebase should be checked for further instances of `ffmpeg` calls. 65 postPatch = '' 66 substituteInPlace whisperx/audio.py --replace-fail \ 67 '"ffmpeg"' '"${lib.getExe ffmpeg}"' 68 ''; 69 70 pythonRelaxDeps = [ 71 # > Checking runtime dependencies for whisperx-3.3.2-py3-none-any.whl 72 # > - faster-whisper==1.1.0 not satisfied by version 1.1.1 73 # This has been updated on main, so we expect this clause to be removed upon the next update. 74 "faster-whisper" 75 76 "ctranslate2" 77 ]; 78 79 # Import check fails due on `aarch64-linux` ONLY in the sandbox due to onnxruntime 80 # not finding its default logger, which then promptly segfaults. 81 # Simply run the import check on every other platform instead. 82 pythonImportsCheck = lib.optionals ( 83 !(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) 84 ) [ "whisperx" ]; 85 86 # No tests in repository 87 doCheck = false; 88 89 meta = { 90 mainProgram = "whisperx"; 91 description = "Automatic Speech Recognition with Word-level Timestamps (& Diarization)"; 92 homepage = "https://github.com/m-bain/whisperX"; 93 changelog = "https://github.com/m-bain/whisperX/releases/tag/${src.tag}"; 94 license = lib.licenses.bsd2; 95 maintainers = [ lib.maintainers.bengsparks ]; 96 }; 97}