diff --git a/pkgs/development/python-modules/openai-whisper/default.nix b/pkgs/development/python-modules/openai-whisper/default.nix index 06978b96483d..73327d314af1 100644 --- a/pkgs/development/python-modules/openai-whisper/default.nix +++ b/pkgs/development/python-modules/openai-whisper/default.nix @@ -1,6 +1,10 @@ { lib , fetchFromGitHub , buildPythonPackage +, substituteAll + +# runtime +, ffmpeg # propagates , numpy @@ -16,21 +20,22 @@ buildPythonPackage rec { pname = "whisper"; - version = "unstable-2022-09-23"; + version = "unstable-2022-09-30"; format = "setuptools"; src = fetchFromGitHub { owner = "openai"; repo = pname; - rev = "8cf36f3508c9acd341a45eb2364239a3d81458b9"; - hash = "sha256-2RH8eM/SezqFJltelv5AjQEGpqXm980u57vrlkTEUvQ="; + rev = "60132ade70e00b843d93542fcb37b58c0d8bf9e7"; + hash = "sha256-4mhlCvewA0bVo5bq2sbSEKHq99TQ6jUauiCUkdRSdas="; }; - postPatch = '' - # Rely on the ffmpeg path already patched into the ffmpeg-python library - substituteInPlace whisper/audio.py \ - --replace 'run(cmd="ffmpeg",' 'run(' - ''; + patches = [ + (substituteAll { + src = ./ffmpeg-path.patch; + inherit ffmpeg; + }) + ]; propagatedBuildInputs = [ numpy diff --git a/pkgs/development/python-modules/openai-whisper/ffmpeg-path.patch b/pkgs/development/python-modules/openai-whisper/ffmpeg-path.patch new file mode 100644 index 000000000000..6ccde1dcabb8 --- /dev/null +++ b/pkgs/development/python-modules/openai-whisper/ffmpeg-path.patch @@ -0,0 +1,13 @@ +diff --git a/whisper/audio.py b/whisper/audio.py +index a6074e8..da18350 100644 +--- a/whisper/audio.py ++++ b/whisper/audio.py +@@ -41,7 +41,7 @@ def load_audio(file: str, sr: int = SAMPLE_RATE): + out, _ = ( + ffmpeg.input(file, threads=0) + .output("-", format="s16le", acodec="pcm_s16le", ac=1, ar=sr) +- .run(cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True) ++ .run(cmd=["@ffmpeg@/bin/ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True) + ) + except ffmpeg.Error as e: + raise RuntimeError(f"Failed to load audio: {e.stderr.decode()}") from e