diff options
Diffstat (limited to 'nixpkgs/pkgs/tools/audio/piper')
-rw-r--r-- | nixpkgs/pkgs/tools/audio/piper/default.nix | 69 | ||||
-rw-r--r-- | nixpkgs/pkgs/tools/audio/piper/fix-compilation-with-newer-onnxruntime.patch | 18 | ||||
-rw-r--r-- | nixpkgs/pkgs/tools/audio/piper/train.nix | 54 |
3 files changed, 141 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/audio/piper/default.nix b/nixpkgs/pkgs/tools/audio/piper/default.nix new file mode 100644 index 000000000000..d753d7bb3e1e --- /dev/null +++ b/nixpkgs/pkgs/tools/audio/piper/default.nix @@ -0,0 +1,69 @@ +{ lib +, stdenv +, fetchFromGitHub + +# build time +, cmake +, pkg-config + +# runtime +, onnxruntime +, pcaudiolib +, piper-phonemize +, spdlog + +# tests +, piper-train +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "piper"; + version = "1.2.0"; + + src = fetchFromGitHub { + owner = "rhasspy"; + repo = "piper"; + rev = "refs/tags/v${finalAttrs.version}"; + hash = "sha256-6WNWqJt0PO86vnf+3iHaRRg2KwBOEj4aicmB+P2phlk="; + }; + + sourceRoot = "${finalAttrs.src.name}/src/cpp"; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ + onnxruntime + pcaudiolib + piper-phonemize + piper-phonemize.espeak-ng + spdlog + ]; + + env.NIX_CFLAGS_COMPILE = builtins.toString [ + "-isystem ${lib.getDev piper-phonemize}/include/piper-phonemize" + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + install -m 0755 piper $out/bin + + runHook postInstall + ''; + + passthru.tests = { + inherit piper-train; + }; + + meta = with lib; { + changelog = "https://github.com/rhasspy/piper/releases/tag/v${finalAttrs.version}"; + description = "A fast, local neural text to speech system"; + homepage = "https://github.com/rhasspy/piper"; + license = licenses.mit; + maintainers = with maintainers; [ hexa ]; + }; +}) diff --git a/nixpkgs/pkgs/tools/audio/piper/fix-compilation-with-newer-onnxruntime.patch b/nixpkgs/pkgs/tools/audio/piper/fix-compilation-with-newer-onnxruntime.patch new file mode 100644 index 000000000000..9d2e46bb4e91 --- /dev/null +++ b/nixpkgs/pkgs/tools/audio/piper/fix-compilation-with-newer-onnxruntime.patch @@ -0,0 +1,18 @@ +diff --git a/src/cpp/synthesize.hpp b/src/cpp/synthesize.hpp +index ef61aef..4c7db7a 100644 +--- a/synthesize.hpp ++++ b/synthesize.hpp +@@ -119,11 +119,11 @@ void synthesize(SynthesisConfig &synthesisConfig, ModelSession &session, + + // Clean up + for (size_t i = 0; i < outputTensors.size(); i++) { +- Ort::OrtRelease(outputTensors[i].release()); ++ Ort::detail::OrtRelease(outputTensors[i].release()); + } + + for (size_t i = 0; i < inputTensors.size(); i++) { +- Ort::OrtRelease(inputTensors[i].release()); ++ Ort::detail::OrtRelease(inputTensors[i].release()); + } + } + } // namespace larynx diff --git a/nixpkgs/pkgs/tools/audio/piper/train.nix b/nixpkgs/pkgs/tools/audio/piper/train.nix new file mode 100644 index 000000000000..2cab1ba4ba04 --- /dev/null +++ b/nixpkgs/pkgs/tools/audio/piper/train.nix @@ -0,0 +1,54 @@ +{ piper-tts +, python3 +}: + +let + python = python3.override { + packageOverrides = self: super: { + }; + }; +in + +python.pkgs.buildPythonPackage { + inherit (piper-tts) version src; + + pname = "piper-train"; + format = "setuptools"; + + sourceRoot = "${piper-tts.src.name}/src/python"; + + nativeBuildInputs = with python.pkgs; [ + cython + ]; + + postBuild = '' + make -C piper_train/vits/monotonic_align + ''; + + postInstall = '' + export MONOTONIC_ALIGN=$out/${python.sitePackages}/piper_train/vits/monotonic_align/monotonic_align + mkdir -p $MONOTONIC_ALIGN + cp -v ./piper_train/vits/monotonic_align/piper_train/vits/monotonic_align/core.*.so $MONOTONIC_ALIGN/ + ''; + + propagatedBuildInputs = with python.pkgs; [ + espeak-phonemizer + librosa + numpy + onnxruntime + piper-phonemize + pytorch-lightning + torch + ]; + + pythonImportsCheck = [ + "piper_train" + ]; + + doCheck = false; # no tests + + meta = piper-tts.meta // { + # requires torch<2, pytorch-lightning~=1.7 + broken = true; + }; +} |