refactor(wyoming): move to tflite dep instead of tensorflow
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-12-15 17:14:49 -05:00
parent ff6b5c753e
commit c75cb0759d
5 changed files with 114 additions and 54 deletions

View file

@ -10,7 +10,7 @@
cfg = config.services.wyoming; cfg = config.services.wyoming;
in { in {
config = let config = let
forkedPkg = import ./pkgs/wyoming-openwakeword.nix pkgs; forkedPkg = (import ./pkgs {inherit pkgs;}).wyoming-openwakeword;
in { in {
systemd.services = mkIf (cfg.openwakeword.enable) { systemd.services = mkIf (cfg.openwakeword.enable) {
wyoming-openwakeword.serviceConfig = { wyoming-openwakeword.serviceConfig = {

View file

@ -0,0 +1,19 @@
{pkgs, ...}: let
python3Packages = pkgs.python311Packages;
in rec {
speexdsp-ns = pkgs.callPackage ./speexdsp-ns.nix {
inherit python3Packages;
};
tflite-runtime = pkgs.callPackage ./tflite-runtime.nix {
inherit python3Packages;
};
openwakeword = pkgs.callPackage ./openwakeword.nix {
inherit python3Packages speexdsp-ns tflite-runtime;
};
wyoming-openwakeword = pkgs.callPackage ./wyoming-openwakeword.nix {
inherit openwakeword python3Packages;
};
}

View file

@ -1,11 +1,13 @@
{ {
fetchFromGitHub, fetchFromGitHub,
fetchpatch,
python3Packages, python3Packages,
speexdsp-ns, speexdsp-ns,
tflite-runtime,
... ...
}: }: let
python3Packages.buildPythonApplication rec { inherit (builtins) attrValues;
in
python3Packages.buildPythonApplication rec {
pname = "openwakeword"; pname = "openwakeword";
version = "0.6.0"; version = "0.6.0";
pyproject = true; pyproject = true;
@ -17,27 +19,23 @@ python3Packages.buildPythonApplication rec {
hash = "sha256-QsXV9REAHdP0Y0fVZuU+Gt9+gcPMB60bc3DOMDYuaDM="; hash = "sha256-QsXV9REAHdP0Y0fVZuU+Gt9+gcPMB60bc3DOMDYuaDM=";
}; };
# Patch upstream to enable use of full tensorflow dep
pythonRemoveDeps = ["tflite-runtime"];
patches = [
(fetchpatch {
url = "https://github.com/dscripka/openWakeWord/pull/178/commits/99cd87e8898348255e864540e43bab17ce0576d6.patch";
hash = "sha256-xveMBZTcYfT8LKiiStqYjjOdUOM/v4taQzSewo97Bfc=";
})
];
nativeBuildInputs = with python3Packages; [ nativeBuildInputs = with python3Packages; [
setuptools setuptools
]; ];
propagatedBuildInputs = propagatedBuildInputs = attrValues {
(with python3Packages; [ inherit
(python3Packages)
onnxruntime onnxruntime
tensorflow-bin
tqdm tqdm
scipy scipy
scikit-learn scikit-learn
requests requests
]) ;
++ [speexdsp-ns];
} inherit
speexdsp-ns
tflite-runtime
;
};
}

View file

@ -0,0 +1,15 @@
{
fetchurl,
python3Packages,
...
}:
python3Packages.buildPythonApplication {
pname = "tflite-runtime";
format = "wheel";
version = "2.14.0";
src = fetchurl {
url = "https://files.pythonhosted.org/packages/8f/a6/02d68cb62cd221589a0ff055073251d883936237c9c990e34a1d7cecd06f/tflite_runtime-2.14.0-cp311-cp311-manylinux2014_x86_64.whl";
hash = "sha256-GVq3UuflcymmjlTdPdVDn62Ii5v/G+Dw3AQqMjepDk0=";
};
}

View file

@ -2,28 +2,56 @@
This package uses a `wyoming-openwakeword` fork that makes use of This package uses a `wyoming-openwakeword` fork that makes use of
the upstream `openwakeword` instead of a fork: https://github.com/rhasspy/wyoming-openwakeword/pull/27 the upstream `openwakeword` instead of a fork: https://github.com/rhasspy/wyoming-openwakeword/pull/27
*/ */
pkgs: let {
pyPkgs = pkgs.python312Packages; fetchFromGitHub,
lib,
speexdsp-ns = pkgs.callPackage ./speexdsp-ns.nix { openwakeword,
python3Packages = pyPkgs; python3Packages,
}; ...
}: let
openwakeword = pkgs.callPackage ./openwakeword.nix { inherit (lib) attrValues;
inherit speexdsp-ns;
python3Packages = pyPkgs;
};
in in
(pkgs.wyoming-openwakeword.override { python3Packages.buildPythonApplication {
python3Packages = pyPkgs; pname = "wyoming-openwakeword";
}) version = "1.10.0-unstable";
.overrideAttrs (o: { pyproject = true;
src = pkgs.fetchFromGitHub {
src = fetchFromGitHub {
owner = "rhasspy"; owner = "rhasspy";
repo = "wyoming-openwakeword"; repo = "wyoming-openwakeword";
rev = "synesthesiam-20240627-openwakeword"; # rev = "synesthesiam-20240627-openwakeword";
rev = "324d669645a778439c5392d9e287a763ead3cf4c";
hash = "sha256-69oR2LHiUfx8j39nWp7XhG5xTvmOoPCLjSlH1CFvavo="; hash = "sha256-69oR2LHiUfx8j39nWp7XhG5xTvmOoPCLjSlH1CFvavo=";
}; };
propagatedBuildInputs = [openwakeword pyPkgs.wyoming]; nativeBuildInputs = attrValues {
}) inherit
(python3Packages)
setuptools
;
};
pythonRelaxDeps = [
"wyoming"
];
propagatedBuildInputs = attrValues {
inherit
(python3Packages)
wyoming
;
inherit openwakeword;
};
pythonImportsCheck = [
"wyoming_openwakeword"
];
meta = {
description = "Open source voice assistant toolkit for many human languages";
homepage = "https://github.com/rhasspy/wyoming-openwakeword";
license = lib.licenses.mit;
mainProgram = "wyoming-openwakeword";
};
}