2022-12-07 15:26:15 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, SDL2
|
|
|
|
, makeWrapper
|
|
|
|
, wget
|
|
|
|
, Accelerate
|
|
|
|
, CoreGraphics
|
|
|
|
, CoreVideo
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "whisper-cpp";
|
2023-03-08 17:23:56 +00:00
|
|
|
version = "1.2.1";
|
2022-12-07 15:26:15 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ggerganov";
|
|
|
|
repo = "whisper.cpp";
|
2023-02-05 13:44:27 +00:00
|
|
|
rev = "refs/tags/v${version}" ;
|
2023-03-08 17:23:56 +00:00
|
|
|
hash = "sha256-gcw+tcrwCt2CynNXQZxb+WxN/0chIQIJnwUAw9JGkYA=";
|
2022-12-07 15:26:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# The upstream download script tries to download the models to the
|
|
|
|
# directory of the script, which is not writable due to being
|
|
|
|
# inside the nix store. This patch changes the script to download
|
|
|
|
# the models to the current directory of where it is being run from.
|
|
|
|
patches = [ ./download-models.patch ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
buildInputs = [ SDL2 ] ++ lib.optionals stdenv.isDarwin [ Accelerate CoreGraphics CoreVideo ];
|
|
|
|
|
|
|
|
makeFlags = [ "main" "stream" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp ./main $out/bin/whisper-cpp
|
|
|
|
cp ./stream $out/bin/whisper-cpp-stream
|
|
|
|
|
|
|
|
cp models/download-ggml-model.sh $out/bin/whisper-cpp-download-ggml-model
|
|
|
|
|
|
|
|
wrapProgram $out/bin/whisper-cpp-download-ggml-model \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [wget]}
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Port of OpenAI's Whisper model in C/C++";
|
|
|
|
longDescription = ''
|
|
|
|
To download the models as described in the project's readme, you may
|
|
|
|
use the `whisper-cpp-download-ggml-model` binary from this package.
|
|
|
|
'';
|
|
|
|
homepage = "https://github.com/ggerganov/whisper.cpp";
|
|
|
|
license = licenses.mit;
|
2023-02-24 04:20:00 +00:00
|
|
|
platforms = platforms.all;
|
2022-12-07 15:26:15 +00:00
|
|
|
maintainers = with maintainers; [ dit7ya ];
|
|
|
|
};
|
|
|
|
}
|