Unverified Commit c90d266b authored by Martin Weinelt's avatar Martin Weinelt Committed by GitHub
Browse files

espeak-ng: 1.51.1 -> 1.52.0; piper-tts: 2023.11.14-2 -> 1.3.0; piper-train: drop (#439761)

parents 766c3640 bb733d67
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ let
  cfg = config.services.wyoming.piper;

  inherit (lib)
    literalExpression
    mkOption
    mkEnableOption
    mkPackageOption
@@ -100,6 +101,15 @@ in
                default = true;
              };

              useCUDA = mkOption {
                type = bool;
                default = config.cudaSupport;
                defaultText = literalExpression "config.cudaSupport";
                description = ''
                  Whether to accelerate the underlying onnxruntime library with CUDA.
                '';
              };

              extraArgs = mkOption {
                type = listOf str;
                default = [ ];
@@ -165,6 +175,9 @@ in
              ++ lib.optionals options.streaming [
                "--streaming"
              ]
              ++ lib.optionals options.cuda [
                "--use-cuda"
              ]
              ++ options.extraArgs
            );
            CapabilityBoundingSet = "";
+74 −43
Original line number Diff line number Diff line
@@ -3,40 +3,78 @@
  lib,
  fetchFromGitHub,
  fetchpatch,
  replaceVars,

  # build system
  autoconf,
  automake,
  which,
  cmake,
  libtool,
  makeWrapper,
  ninja,
  pkg-config,
  ronn,
  replaceVars,
  buildPackages,
  mbrolaSupport ? true,
  which,

  # dependencies
  alsa-plugins,
  asyncSupport ? true,
  klattSupport ? true,
  mbrola,
  pcaudiolibSupport ? true,
  mbrolaSupport ? true,
  pcaudiolib,
  sonicSupport ? true,
  pcaudiolibSupport ? true,
  sonic,
  alsa-plugins,
  makeWrapper,
  sonicSupport ? true,
  speechPlayerSupport ? true,
  ucdSupport ? false,
}:

let
  version = "1.52.0";

  src = fetchFromGitHub {
    owner = "espeak-ng";
    repo = "espeak-ng";
    tag = version;
    hash = "sha256-mmh5QPSVD5YQ0j16R+bEL5vcyWLtTNOJ/irBNzWY3ro=";
  };

  ucd-tools = stdenv.mkDerivation {
    pname = "ucd-tools";
    inherit version src;

    sourceRoot = "${src.name}/src/ucd-tools";

    nativeBuildInputs = [ cmake ];

    installPhase = ''
      runHook preInstall
      mkdir $out
      cp -v libucd.a $out/
      runHook postInstall
    '';
  };
in

stdenv.mkDerivation rec {
  pname = "espeak-ng";
  version = "1.51.1";
  version = "1.52.0";

  src = fetchFromGitHub {
    owner = "espeak-ng";
    repo = "espeak-ng";
    rev = version;
    hash = "sha256-aAJ+k+kkOS6k835mEW7BvgAIYGhUHxf7Q4P5cKO8XTk=";
    tag = version;
    hash = "sha256-mmh5QPSVD5YQ0j16R+bEL5vcyWLtTNOJ/irBNzWY3ro=";
  };

  patches = [
    # Fix build with Clang 16.
    # https://github.com/espeak-ng/espeak-ng/pull/2274
    ./libsonic.patch
    (fetchpatch {
      url = "https://github.com/espeak-ng/espeak-ng/commit/497c6217d696c1190c3e8b992ff7b9110eb3bedd.patch";
      hash = "sha256-KfzqnRyQfz6nuMKnsHoUzb9rn9h/Pg54mupW1Cr+Zx0=";
      name = "espeak-ng-text-to-phonemes-with-terminator.patch";
      url = "https://github.com/espeak-ng/espeak-ng/commit/2108b1e8ae02f49cc909894a1024efdfde6682fd.patch";
      hash = "sha256-XjEc1r7F88xZOfeUey0R6Xv6vu4Wy8GtWxXFG2NTf9g=";
    })
  ]
  ++ lib.optionals mbrolaSupport [
@@ -46,14 +84,20 @@ stdenv.mkDerivation rec {
    })
  ];

  postPatch = lib.optionalString ucdSupport ''
    ln -s ${ucd-tools}/libucd.a src/ucd-tools/libucd.a
  '';

  nativeBuildInputs = [
    autoconf
    automake
    which
    cmake
    libtool
    ninja
    pkg-config
    ronn
    makeWrapper
    which
  ];

  buildInputs =
@@ -61,45 +105,32 @@ stdenv.mkDerivation rec {
    ++ lib.optional pcaudiolibSupport pcaudiolib
    ++ lib.optional sonicSupport sonic;

  # touch ChangeLog to avoid below error on darwin:
  # Makefile.am: error: required file './ChangeLog.md' not found
  preConfigure =
    lib.optionalString stdenv.hostPlatform.isDarwin ''
      touch ChangeLog
    ''
    + ''
      ./autogen.sh
    '';

  configureFlags = [
    "--with-mbrola=${if mbrolaSupport then "yes" else "no"}"
  cmakeFlags = [
    (lib.cmakeBool "BUILD_SHARED_LIBS" true)
    (lib.cmakeBool "USE_ASYNC" asyncSupport)
    (lib.cmakeBool "USE_KLATT" klattSupport)
    (lib.cmakeBool "USE_LIBPCAUDIO" pcaudiolibSupport)
    (lib.cmakeBool "USE_LIBSONIC" sonicSupport)
    (lib.cmakeBool "USE_MBROLA" mbrolaSupport)
    (lib.cmakeBool "USE_SPEECHPLAYER" speechPlayerSupport)
  ];

  # ref https://github.com/void-linux/void-packages/blob/3cf863f894b67b3c93e23ac7830ca46b697d308a/srcpkgs/espeak-ng/template#L29-L31
  postConfigure = lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
    substituteInPlace Makefile \
      --replace 'ESPEAK_DATA_PATH=$(CURDIR) src/espeak-ng' 'ESPEAK_DATA_PATH=$(CURDIR) ${lib.getExe buildPackages.espeak-ng}' \
      --replace 'espeak-ng-data/%_dict: src/espeak-ng' 'espeak-ng-data/%_dict: ${lib.getExe buildPackages.espeak-ng}' \
      --replace '../src/espeak-ng --compile' "${lib.getExe buildPackages.espeak-ng} --compile"
  '';

  postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
    patchelf --set-rpath "$(patchelf --print-rpath $out/bin/espeak-ng)" $out/bin/speak-ng
    wrapProgram $out/bin/espeak-ng \
      --set ALSA_PLUGIN_DIR ${alsa-plugins}/lib/alsa-lib
  '';

  passthru = {
    inherit mbrolaSupport;
    inherit mbrolaSupport ucd-tools;
  };

  meta = with lib; {
    description = "Open source speech synthesizer that supports over 70 languages, based on eSpeak";
  meta = {
    description = "Speech synthesizer that supports more than hundred languages and accents";
    homepage = "https://github.com/espeak-ng/espeak-ng";
    changelog = "https://github.com/espeak-ng/espeak-ng/blob/${version}/CHANGELOG.md";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ aske ];
    platforms = platforms.all;
    changelog = "https://github.com/espeak-ng/espeak-ng/blob/${src.tag}/ChangeLog.md";
    license = lib.licenses.gpl3Plus;
    maintainers = with lib.maintainers; [ aske ];
    platforms = lib.platforms.all;
    mainProgram = "espeak-ng";
  };
}
+41 −0
Original line number Diff line number Diff line
diff --git a/cmake/deps.cmake b/cmake/deps.cmake
index b63ced21..2cd1727b 100644
--- a/cmake/deps.cmake
+++ b/cmake/deps.cmake
@@ -13,20 +13,22 @@ endif(PTHREAD_LIB)
 if (MBROLA_BIN)
   set(HAVE_MBROLA ON)
 endif(MBROLA_BIN)
-if (SONIC_LIB AND SONIC_INC)
-  set(HAVE_LIBSONIC ON)
-else()
-  FetchContent_Declare(sonic-git
-    GIT_REPOSITORY https://github.com/waywardgeek/sonic.git
-    GIT_TAG fbf75c3d6d846bad3bb3d456cbc5d07d9fd8c104
-  )
-  FetchContent_MakeAvailable(sonic-git)
-  FetchContent_GetProperties(sonic-git)
-  add_library(sonic OBJECT ${sonic-git_SOURCE_DIR}/sonic.c)
-  target_include_directories(sonic PUBLIC ${sonic-git_SOURCE_DIR})
-  set(HAVE_LIBSONIC ON)
-  set(SONIC_LIB sonic)
-  set(SONIC_INC ${sonic-git_SOURCE_DIR})
+if (USE_LIBSONIC)
+  if (SONIC_LIB AND SONIC_INC)
+    set(HAVE_LIBSONIC ON)
+  else()
+    FetchContent_Declare(sonic-git
+      GIT_REPOSITORY https://github.com/waywardgeek/sonic.git
+      GIT_TAG fbf75c3d6d846bad3bb3d456cbc5d07d9fd8c104
+    )
+    FetchContent_MakeAvailable(sonic-git)
+    FetchContent_GetProperties(sonic-git)
+    add_library(sonic OBJECT ${sonic-git_SOURCE_DIR}/sonic.c)
+    target_include_directories(sonic PUBLIC ${sonic-git_SOURCE_DIR})
+    set(HAVE_LIBSONIC ON)
+    set(SONIC_LIB sonic)
+    set(SONIC_INC ${sonic-git_SOURCE_DIR})
+  endif()
 endif()
 if (PCAUDIO_LIB AND PCAUDIO_INC)
   set(HAVE_LIBPCAUDIO ON)
+10 −6
Original line number Diff line number Diff line
diff --git a/src/libespeak-ng/mbrowrap.c b/src/libespeak-ng/mbrowrap.c
index e3e4b702..de06dd21 100644
--- a/src/libespeak-ng/mbrowrap.c
+++ b/src/libespeak-ng/mbrowrap.c
@@ -205,7 +205,7 @@
@@ -209,7 +209,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,
+		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 5f9b0458..26a05635 100644
--- a/src/libespeak-ng/synth_mbrola.c
+++ b/src/libespeak-ng/synth_mbrola.c
@@ -85,7 +85,7 @@
@@ -95,7 +95,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);
 #ifdef PLATFORM_POSIX
+	sprintf(path, "%s/@mbrola@/%s", path_home, 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
 	//   $data_dir/mbrola/xx, $data_dir/mbrola/xx/xx, $data_dir/mbrola/voices/xx
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ stdenv.mkDerivation (finalAttrs: {

  dontUseQmakeConfigure = true;
  dontUseCmakeConfigure = true;
  dontUseNinjaBuild = true;

  nativeBuildInputs = [
    cmake
Loading