summary refs log tree commit diff
path: root/pkgs/tools/audio
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-08-03 12:01:13 +0000
committerGitHub <noreply@github.com>2023-08-03 12:01:13 +0000
commitdc63372d70ebd4a951518d595712d92484ba3dac (patch)
tree6dc4ac244f7ab6fa098dee50a8ec8ca05b3c06f9 /pkgs/tools/audio
parentc5d3708f89dc5f658e4a76e7f6154f2e04e3fc14 (diff)
parent9eaec2881f216fcd532901cc00341b68c350969d (diff)
downloadnixpkgs-dc63372d70ebd4a951518d595712d92484ba3dac.tar
nixpkgs-dc63372d70ebd4a951518d595712d92484ba3dac.tar.gz
nixpkgs-dc63372d70ebd4a951518d595712d92484ba3dac.tar.bz2
nixpkgs-dc63372d70ebd4a951518d595712d92484ba3dac.tar.lz
nixpkgs-dc63372d70ebd4a951518d595712d92484ba3dac.tar.xz
nixpkgs-dc63372d70ebd4a951518d595712d92484ba3dac.tar.zst
nixpkgs-dc63372d70ebd4a951518d595712d92484ba3dac.zip
Merge master into staging-next
Diffstat (limited to 'pkgs/tools/audio')
-rw-r--r--pkgs/tools/audio/piper/default.nix32
-rw-r--r--pkgs/tools/audio/piper/train.nix54
-rw-r--r--pkgs/tools/audio/wyoming/faster-whisper-entrypoint.patch17
-rw-r--r--pkgs/tools/audio/wyoming/faster-whisper.nix4
-rw-r--r--pkgs/tools/audio/wyoming/piper-entrypoint.patch20
-rw-r--r--pkgs/tools/audio/wyoming/piper.nix4
6 files changed, 97 insertions, 34 deletions
diff --git a/pkgs/tools/audio/piper/default.nix b/pkgs/tools/audio/piper/default.nix
index c3d8a763830..29fdb0705fe 100644
--- a/pkgs/tools/audio/piper/default.nix
+++ b/pkgs/tools/audio/piper/default.nix
@@ -1,17 +1,24 @@
 { lib
 , stdenv
 , fetchFromGitHub
+
+# build time
 , cmake
 , pkg-config
-, espeak-ng
+
+# runtime
 , onnxruntime
 , pcaudiolib
+, piper-phonemize
+, spdlog
+
+# tests
 , piper-train
 }:
 
 let
   pname = "piper";
-  version = "0.0.2";
+  version = "1.2.0";
 in
 stdenv.mkDerivation {
   inherit pname version;
@@ -19,30 +26,27 @@ stdenv.mkDerivation {
   src = fetchFromGitHub {
     owner = "rhasspy";
     repo = "piper";
-    rev = "70afec58bc131010c8993c154ff02a78d1e7b8b0";
-    hash = "sha256-zTW7RGcV8Hh7G6Braf27F/8s7nNjAqagp7tmrKO10BY=";
+    rev = "refs/tags/v${version}";
+    hash = "sha256-6WNWqJt0PO86vnf+3iHaRRg2KwBOEj4aicmB+P2phlk=";
   };
 
   sourceRoot = "source/src/cpp";
 
-  patches = [
-    ./fix-compilation-with-newer-onnxruntime.patch
-  ];
-
-  postPatch = ''
-    substituteInPlace CMakeLists.txt \
-      --replace "/usr/local/include/onnxruntime" "${onnxruntime}"
-  '';
-
   nativeBuildInputs = [
     cmake
     pkg-config
   ];
 
   buildInputs = [
-    espeak-ng
     onnxruntime
     pcaudiolib
+    piper-phonemize
+    piper-phonemize.espeak-ng
+    spdlog
+  ];
+
+  env.NIX_CFLAGS_COMPILE = builtins.toString [
+    "-isystem ${lib.getDev piper-phonemize}/include/piper-phonemize"
   ];
 
   installPhase = ''
diff --git a/pkgs/tools/audio/piper/train.nix b/pkgs/tools/audio/piper/train.nix
new file mode 100644
index 00000000000..a385ebb85ad
--- /dev/null
+++ b/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 = "source/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;
+  };
+}
diff --git a/pkgs/tools/audio/wyoming/faster-whisper-entrypoint.patch b/pkgs/tools/audio/wyoming/faster-whisper-entrypoint.patch
index 1af62cb1fe2..27a6bd08249 100644
--- a/pkgs/tools/audio/wyoming/faster-whisper-entrypoint.patch
+++ b/pkgs/tools/audio/wyoming/faster-whisper-entrypoint.patch
@@ -1,5 +1,5 @@
 diff --git a/setup.py b/setup.py
-index 1c0b2d2..bbff1d1 100644
+index 04eedbc..ee0b495 100644
 --- a/setup.py
 +++ b/setup.py
 @@ -35,4 +35,9 @@ setup(
@@ -13,17 +13,20 @@ index 1c0b2d2..bbff1d1 100644
 +    }
  )
 diff --git a/wyoming_faster_whisper/__main__.py b/wyoming_faster_whisper/__main__.py
-index 5557cc5..bb9d69f 100755
+index 8a5039f..bd1e7b6 100755
 --- a/wyoming_faster_whisper/__main__.py
 +++ b/wyoming_faster_whisper/__main__.py
-@@ -131,5 +131,9 @@ async def main() -> None:
+@@ -131,8 +131,12 @@ async def main() -> None:
  
  # -----------------------------------------------------------------------------
  
--if __name__ == "__main__":
 +def run():
-     asyncio.run(main())
++    asyncio.run(main())
 +
 +
-+if __name__ == "__main__":
-+    run()
+ if __name__ == "__main__":
+     try:
+-        asyncio.run(main())
++        run()
+     except KeyboardInterrupt:
+         pass
diff --git a/pkgs/tools/audio/wyoming/faster-whisper.nix b/pkgs/tools/audio/wyoming/faster-whisper.nix
index 74794732234..50ec99f6dee 100644
--- a/pkgs/tools/audio/wyoming/faster-whisper.nix
+++ b/pkgs/tools/audio/wyoming/faster-whisper.nix
@@ -5,13 +5,13 @@
 
 python3.pkgs.buildPythonApplication rec {
   pname = "wyoming-faster-whisper";
-  version = "0.0.3";
+  version = "1.0.1";
   format = "setuptools";
 
   src = fetchPypi {
     pname = "wyoming_faster_whisper";
     inherit version;
-    hash = "sha256-uqepa70lprzV3DJK2wrNAAyZkMMJ5S86RKK716zxYU4=";
+    hash = "sha256-wo62m8gIP9hXihkd8j2haVvz3TlJv3m5WWthTPFwesk=";
   };
 
   patches = [
diff --git a/pkgs/tools/audio/wyoming/piper-entrypoint.patch b/pkgs/tools/audio/wyoming/piper-entrypoint.patch
index c2e4245e5b2..4f7d09fd40c 100644
--- a/pkgs/tools/audio/wyoming/piper-entrypoint.patch
+++ b/pkgs/tools/audio/wyoming/piper-entrypoint.patch
@@ -1,8 +1,8 @@
 diff --git a/setup.py b/setup.py
-index 1355313..3b144c1 100644
+index 05e42c1..8347acb 100644
 --- a/setup.py
 +++ b/setup.py
-@@ -35,4 +35,9 @@ setup(
+@@ -41,4 +41,9 @@ setup(
          "Programming Language :: Python :: 3.10",
      ],
      keywords="rhasspy wyoming piper",
@@ -13,18 +13,20 @@ index 1355313..3b144c1 100644
 +    }
  )
 diff --git a/wyoming_piper/__main__.py b/wyoming_piper/__main__.py
-index f60cf13..a0a15f7 100755
+index ab1580b..4c0a143 100755
 --- a/wyoming_piper/__main__.py
 +++ b/wyoming_piper/__main__.py
-@@ -143,5 +143,9 @@ async def main() -> None:
+@@ -143,8 +143,12 @@ def get_description(voice_info: Dict[str, Any]):
  
  # -----------------------------------------------------------------------------
  
--if __name__ == "__main__":
 +def run():
-     asyncio.run(main())
++    asyncio.run(main())
 +
 +
-+if __name__ == "__main__":
-+    run()
-\ No newline at end of file
+ if __name__ == "__main__":
+     try:
+-        asyncio.run(main())
++        run()
+     except KeyboardInterrupt:
+         pass
diff --git a/pkgs/tools/audio/wyoming/piper.nix b/pkgs/tools/audio/wyoming/piper.nix
index 830f7205965..c5ce6f99005 100644
--- a/pkgs/tools/audio/wyoming/piper.nix
+++ b/pkgs/tools/audio/wyoming/piper.nix
@@ -5,13 +5,13 @@
 
 python3.pkgs.buildPythonApplication rec {
   pname = "wyoming-piper";
-  version = "0.0.3";
+  version = "1.2.0";
   format = "setuptools";
 
   src = fetchPypi {
     pname = "wyoming_piper";
     inherit version;
-    hash = "sha256-vl7LjW/2HBx6o/+vpap+wSG3XXzDwFacNmcbeU/8bOs=";
+    hash = "sha256-cdCWpejHNCjyYtIxGms9yaEerRmFnGllUN7+3uQy4mQ=";
   };
 
   patches = [