Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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.3.2"; 39 pyproject = true; 40 41 src = fetchFromGitHub { 42 owner = "m-bain"; 43 repo = "whisperX"; 44 tag = "v${version}"; 45 hash = "sha256-JJa8gUQjIcgJ5lug3ULGkHxkl66qnXkiUA3SwwUVpqk="; 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 # > Checking runtime dependencies for whisperx-3.3.2-py3-none-any.whl 71 # > - faster-whisper==1.1.0 not satisfied by version 1.1.1 72 # This has been updated on main, so we expect this clause to be removed upon the next update. 73 pythonRelaxDeps = [ "faster-whisper" ]; 74 75 # Import check fails due on `aarch64-linux` ONLY in the sandbox due to onnxruntime 76 # not finding its default logger, which then promptly segfaults. 77 # Simply run the import check on every other platform instead. 78 pythonImportsCheck = lib.optionals ( 79 !(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) 80 ) [ "whisperx" ]; 81 82 # No tests in repository 83 doCheck = false; 84 85 meta = { 86 mainProgram = "whisperx"; 87 description = "Automatic Speech Recognition with Word-level Timestamps (& Diarization)"; 88 homepage = "https://github.com/m-bain/whisperX"; 89 changelog = "https://github.com/m-bain/whisperX/releases/tag/${src.tag}"; 90 license = lib.licenses.bsd2; 91 maintainers = [ lib.maintainers.bengsparks ]; 92 }; 93}