Skip to content

Commit

Permalink
espeak-ng: Pick mbrola voices from XDG_DATA_DIRS
Browse files Browse the repository at this point in the history
This will require that user installs e.g. `mbrola-voices` in such a way its `share/` directory ends up in `XDG_DATA_DIRS` environment variable. The NixOS module change in the parent commit will handle that automatically for GNOME.
  • Loading branch information
jtojnar committed Jul 8, 2024
1 parent 38dd1a6 commit 5f1ff0f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
11 changes: 9 additions & 2 deletions pkgs/applications/audio/espeak-ng/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,17 @@ stdenv.mkDerivation rec {
hash = "sha256-KfzqnRyQfz6nuMKnsHoUzb9rn9h/Pg54mupW1Cr+Zx0=";
})
] ++ lib.optionals mbrolaSupport [
# Hardcode correct mbrola paths.
# Hardcode correct mbrola path.
(substituteAll {
src = ./mbrola.patch;
mbrola = mbrola.combined;
inherit mbrola;
})

# Pick up mbrola voices from XDG_DATA_DIRS to reduce closure size.
# https://github.com/espeak-ng/espeak-ng/pull/1948
(fetchpatch {
url = "https://github.com/espeak-ng/espeak-ng/commit/7d31736c04e1bdd86f59e158a15be5e0f4a5b0cd.patch";
hash = "sha256-phVQeEjhm8gCZta3TARPleDtTKPGqXGUMaTQsjc9zlw=";
})
];

Expand Down
11 changes: 0 additions & 11 deletions pkgs/applications/audio/espeak-ng/mbrola.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,3 @@
voice_path, "-", "-.wav", (char *)NULL);
/* if execution reaches this point then the exec() failed */
snprintf(mbr_errorbuf, sizeof(mbr_errorbuf),
--- a/src/libespeak-ng/synth_mbrola.c
+++ b/src/libespeak-ng/synth_mbrola.c
@@ -85,7 +85,7 @@
if (!load_MBR())
return ENS_MBROLA_NOT_FOUND;

- sprintf(path, "%s/mbrola/%s", path_home, mbrola_voice);
+ sprintf(path, "@mbrola@/share/mbrola/%s/%s", mbrola_voice, mbrola_voice);
#ifdef PLATFORM_POSIX
// if not found, then also look in
// usr/share/mbrola/xx, /usr/share/mbrola/xx/xx, /usr/share/mbrola/voices/xx
10 changes: 0 additions & 10 deletions pkgs/by-name/mb/mbrola/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
lib,
stdenv,
fetchFromGitHub,
mbrola-voices,
runCommandLocal,
}:

stdenv.mkDerivation (finalAttrs: {
Expand All @@ -28,14 +26,6 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';

passthru = {
combined = runCommandLocal "mbrola-combined-${finalAttrs.version}" { inherit (finalAttrs) meta; } ''
mkdir -p "$out/"
ln -s '${mbrola-voices}/share' "$out/"
ln -s '${finalAttrs.finalPackage}/bin' "$out/"
'';
};

meta = with lib; {
description = "Speech synthesizer based on the concatenation of diphones";
homepage = "https://github.com/numediart/MBROLA";
Expand Down

0 comments on commit 5f1ff0f

Please sign in to comment.