Merge pull request #193707 from mweinelt/whisper-2022-09-30
This commit is contained in:
commit
9f2bd66ff8
2 changed files with 26 additions and 8 deletions
|
@ -1,6 +1,10 @@
|
||||||
{ lib
|
{ lib
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, buildPythonPackage
|
, buildPythonPackage
|
||||||
|
, substituteAll
|
||||||
|
|
||||||
|
# runtime
|
||||||
|
, ffmpeg
|
||||||
|
|
||||||
# propagates
|
# propagates
|
||||||
, numpy
|
, numpy
|
||||||
|
@ -16,21 +20,22 @@
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
pname = "whisper";
|
pname = "whisper";
|
||||||
version = "unstable-2022-09-23";
|
version = "unstable-2022-09-30";
|
||||||
format = "setuptools";
|
format = "setuptools";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "openai";
|
owner = "openai";
|
||||||
repo = pname;
|
repo = pname;
|
||||||
rev = "8cf36f3508c9acd341a45eb2364239a3d81458b9";
|
rev = "60132ade70e00b843d93542fcb37b58c0d8bf9e7";
|
||||||
hash = "sha256-2RH8eM/SezqFJltelv5AjQEGpqXm980u57vrlkTEUvQ=";
|
hash = "sha256-4mhlCvewA0bVo5bq2sbSEKHq99TQ6jUauiCUkdRSdas=";
|
||||||
};
|
};
|
||||||
|
|
||||||
postPatch = ''
|
patches = [
|
||||||
# Rely on the ffmpeg path already patched into the ffmpeg-python library
|
(substituteAll {
|
||||||
substituteInPlace whisper/audio.py \
|
src = ./ffmpeg-path.patch;
|
||||||
--replace 'run(cmd="ffmpeg",' 'run('
|
inherit ffmpeg;
|
||||||
'';
|
})
|
||||||
|
];
|
||||||
|
|
||||||
propagatedBuildInputs = [
|
propagatedBuildInputs = [
|
||||||
numpy
|
numpy
|
||||||
|
|
|
@ -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
|
Loading…
Reference in a new issue