mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
local-ai: add whisper test
This commit is contained in:
parent
72450f071c
commit
683ab72943
|
@ -52,7 +52,12 @@
|
||||||
|
|
||||||
# tests
|
# tests
|
||||||
, fetchzip
|
, fetchzip
|
||||||
|
, fetchurl
|
||||||
, writeText
|
, writeText
|
||||||
|
, writeTextFile
|
||||||
|
, symlinkJoin
|
||||||
|
, linkFarmFromDrvs
|
||||||
|
, jq
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
BUILD_TYPE =
|
BUILD_TYPE =
|
||||||
|
@ -520,13 +525,32 @@ let
|
||||||
hash = "sha256-5wf+6H5HeQY0qgdqnAG1vSqtjIFM9lXH53OgouuPm0M=";
|
hash = "sha256-5wf+6H5HeQY0qgdqnAG1vSqtjIFM9lXH53OgouuPm0M=";
|
||||||
stripRoot = false;
|
stripRoot = false;
|
||||||
};
|
};
|
||||||
|
ggml-tiny-en = fetchurl {
|
||||||
|
url = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en-q5_1.bin";
|
||||||
|
hash = "sha256-x3xXZvHO8JtrfUfyG1Rsvd1BV4hrO11tT3CekeZsfCs=";
|
||||||
|
};
|
||||||
|
whisper-en = {
|
||||||
|
name = "whisper-en";
|
||||||
|
backend = "whisper";
|
||||||
|
parameters.model = ggml-tiny-en.name;
|
||||||
|
};
|
||||||
|
models = symlinkJoin {
|
||||||
|
name = "models";
|
||||||
|
paths = [
|
||||||
|
voice-en-us
|
||||||
|
(linkFarmFromDrvs "whisper-en" [
|
||||||
|
(writeText "whisper-en.yaml" (builtins.toJSON whisper-en))
|
||||||
|
ggml-tiny-en
|
||||||
|
])
|
||||||
|
];
|
||||||
|
};
|
||||||
in
|
in
|
||||||
testers.runNixOSTest {
|
testers.runNixOSTest {
|
||||||
name = pname + "-tts";
|
name = pname + "-tts";
|
||||||
nodes.machine = {
|
nodes.machine = {
|
||||||
systemd.services.local-ai = {
|
systemd.services.local-ai = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig.ExecStart = "${self}/bin/local-ai --debug --models-path ${voice-en-us} --localai-config-dir . --address :${port}";
|
serviceConfig.ExecStart = "${self}/bin/local-ai --debug --models-path ${models} --localai-config-dir . --address :${port}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
testScript =
|
testScript =
|
||||||
|
@ -534,13 +558,15 @@ let
|
||||||
request = {
|
request = {
|
||||||
model = "en-us-danny-low.onnx";
|
model = "en-us-danny-low.onnx";
|
||||||
backend = "piper";
|
backend = "piper";
|
||||||
input = "Hello";
|
input = "Hello, how are you?";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
machine.wait_for_open_port(${port})
|
machine.wait_for_open_port(${port})
|
||||||
machine.succeed("curl -f http://localhost:${port}/readyz")
|
machine.succeed("curl -f http://localhost:${port}/readyz")
|
||||||
machine.succeed("curl -f http://localhost:${port}/tts --json @${writeText "request.json" (builtins.toJSON request)} --output out.wav")
|
machine.succeed("curl -f http://localhost:${port}/tts --json @${writeText "request.json" (builtins.toJSON request)} --output out.wav")
|
||||||
|
machine.succeed("curl -f http://localhost:${port}/v1/audio/transcriptions --header 'Content-Type: multipart/form-data' --form file=@out.wav --form model=${whisper-en.name} --output transcription.json")
|
||||||
|
machine.succeed("${jq}/bin/jq --exit-status 'debug | .segments | first.text == \"${request.input}\"' transcription.json")
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue