about summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorMartin Weinelt <mweinelt@users.noreply.github.com>2023-08-03 13:10:32 +0200
committerGitHub <noreply@github.com>2023-08-03 13:10:32 +0200
commitfcf476cb789d61f70f83e4cf639724d0cb5d232b (patch)
treece980e2b4f585d49f00c8a3a5f2b2f4b1dd34a93 /pkgs/development
parentfd3ce3bb2d9c07cdba4a86ad81f9b39c94ea5e06 (diff)
parent24c0ba0ffcce19a168a61bac47c96d7d7e9e930e (diff)
Merge pull request #246856 from mweinelt/piper-tts-1.2.0
piper-tts: 0.0.2 -> 1.2.0
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/libraries/piper-phonemize/default.nix60
-rw-r--r--pkgs/development/libraries/piper-phonemize/espeak-mbrola.patch26
-rw-r--r--pkgs/development/python-modules/piper-phonemize/default.nix34
-rw-r--r--pkgs/development/python-modules/piper-train/default.nix60
4 files changed, 120 insertions, 60 deletions
diff --git a/pkgs/development/libraries/piper-phonemize/default.nix b/pkgs/development/libraries/piper-phonemize/default.nix
new file mode 100644
index 0000000000000..fd1c1ae34b4c5
--- /dev/null
+++ b/pkgs/development/libraries/piper-phonemize/default.nix
@@ -0,0 +1,60 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+
+# build
+, cmake
+, pkg-config
+
+# runtime
+, espeak-ng
+, onnxruntime
+}:
+
+let
+  espeak-ng' = espeak-ng.overrideAttrs (oldAttrs: {
+    version = "1.52-dev";
+    src = fetchFromGitHub {
+      owner = "rhasspy";
+      repo = "espeak-ng";
+      rev = "61504f6b76bf9ebbb39b07d21cff2a02b87c99ff";
+      hash = "sha256-RBHL11L5uazAFsPFwul2QIyJREXk9Uz8HTZx9JqmyIQ=";
+    };
+
+    patches = [
+      ./espeak-mbrola.patch
+    ];
+  });
+in
+stdenv.mkDerivation rec {
+  pname = "piper-phonemize";
+  version = "1.1.0";
+
+  src = fetchFromGitHub {
+    owner = "rhasspy";
+    repo = "piper-phonemize";
+    rev = "refs/tags/v${version}";
+    hash = "sha256-cMer7CSLOXv3jc9huVA3Oy5cjXjOX9XuEXpIWau1BNQ=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    pkg-config
+  ];
+
+  buildInputs = [
+    espeak-ng'
+    onnxruntime
+  ];
+
+  passthru = {
+    espeak-ng = espeak-ng';
+  };
+
+  meta = with lib; {
+    description = "C++ library for converting text to phonemes for Piper";
+    homepage = "https://github.com/rhasspy/piper-phonemize";
+    license = licenses.mit;
+    maintainers = with maintainers; [ hexa ];
+  };
+}
diff --git a/pkgs/development/libraries/piper-phonemize/espeak-mbrola.patch b/pkgs/development/libraries/piper-phonemize/espeak-mbrola.patch
new file mode 100644
index 0000000000000..9d3f0aeb4abe6
--- /dev/null
+++ b/pkgs/development/libraries/piper-phonemize/espeak-mbrola.patch
@@ -0,0 +1,26 @@
+diff --git a/src/libespeak-ng/mbrowrap.c b/src/libespeak-ng/mbrowrap.c
+index ae137873..9015cc01 100644
+--- a/src/libespeak-ng/mbrowrap.c
++++ b/src/libespeak-ng/mbrowrap.c
+@@ -206,7 +206,7 @@ static int start_mbrola(const char *voice_path)
+ 		signal(SIGTERM, SIG_IGN);
+ 
+ 		snprintf(charbuf, sizeof(charbuf), "%g", mbr_volume);
+-		execlp("mbrola", "mbrola", "-e", "-v", charbuf,
++		execlp("@mbrola/bin/mbrola", "mbrola", "-e", "-v", charbuf,
+ 		       voice_path, "-", "-.wav", (char *)NULL);
+ 		/* if execution reaches this point then the exec() failed */
+ 		snprintf(mbr_errorbuf, sizeof(mbr_errorbuf),
+diff --git a/src/libespeak-ng/synth_mbrola.c b/src/libespeak-ng/synth_mbrola.c
+index 734631b7..46d1f13e 100644
+--- a/src/libespeak-ng/synth_mbrola.c
++++ b/src/libespeak-ng/synth_mbrola.c
+@@ -85,7 +85,7 @@ espeak_ng_STATUS LoadMbrolaTable(const char *mbrola_voice, const char *phtrans,
+ 	if (!load_MBR())
+ 		return ENS_MBROLA_NOT_FOUND;
+ 
+-	sprintf(path, "%s/mbrola/%s", path_home, mbrola_voice);
++	sprintf(path, "@mbrola@/share/mbrola/voices/%s/%s", mbrola_voice, mbrola_voice);
+ #if PLATFORM_POSIX
+ 	// if not found, then also look in
+ 	//   usr/share/mbrola/xx, /usr/share/mbrola/xx/xx, /usr/share/mbrola/voices/xx
diff --git a/pkgs/development/python-modules/piper-phonemize/default.nix b/pkgs/development/python-modules/piper-phonemize/default.nix
new file mode 100644
index 0000000000000..cd09567a61e36
--- /dev/null
+++ b/pkgs/development/python-modules/piper-phonemize/default.nix
@@ -0,0 +1,34 @@
+{ buildPythonPackage
+, onnxruntime-native
+, piper-phonemize-native
+, pybind11
+, setuptools
+}:
+
+buildPythonPackage {
+  inherit (piper-phonemize-native) pname version src;
+  format = "pyproject";
+
+  nativeBuildInputs = [
+    pybind11
+    setuptools
+  ];
+
+  buildInputs = [
+    onnxruntime-native
+    piper-phonemize-native
+    piper-phonemize-native.espeak-ng
+  ];
+
+  pythonImportsCheck = [
+    "piper_phonemize"
+  ];
+
+  # no tests
+  doCheck = false;
+
+  meta = {
+    description = "Phonemization libary used by Piper text to speech system";
+    inherit (piper-phonemize-native.meta) homepage license maintainers;
+  };
+}
diff --git a/pkgs/development/python-modules/piper-train/default.nix b/pkgs/development/python-modules/piper-train/default.nix
deleted file mode 100644
index 5cf8cdea10df6..0000000000000
--- a/pkgs/development/python-modules/piper-train/default.nix
+++ /dev/null
@@ -1,60 +0,0 @@
-{ buildPythonPackage
-, piper-tts
-
-# build
-, cython
-, python
-
-# propagates
-, espeak-phonemizer
-, librosa
-, numpy
-, onnxruntime
-, pytorch-lightning
-, torch
-}:
-
-buildPythonPackage {
-  inherit (piper-tts) version src meta;
-
-  pname = "piper-train";
-  format = "setuptools";
-
-  sourceRoot = "source/src/python";
-
-  nativeBuildInputs = [
-    cython
-  ];
-
-  postPatch = ''
-    substituteInPlace requirements.txt \
-      --replace "onnxruntime~=1.11.0" "onnxruntime" \
-      --replace "pytorch-lightning~=1.7.0" "pytorch-lightning" \
-      --replace "torch~=1.11.0" "torch"
-  '';
-
-  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 = [
-    espeak-phonemizer
-    librosa
-    numpy
-    onnxruntime
-    pytorch-lightning
-    torch
-  ];
-
-  pythonImportsCheck = [
-    "piper_train"
-  ];
-
-  doCheck = false; # no tests
-}