13 , mbrolaSupport ? true
15 , pcaudiolibSupport ? true
26 stdenv.mkDerivation rec {
30 src = fetchFromGitHub {
34 hash = "sha256-aAJ+k+kkOS6k835mEW7BvgAIYGhUHxf7Q4P5cKO8XTk=";
38 # Fix build with Clang 16.
40 url = "https://github.com/espeak-ng/espeak-ng/commit/497c6217d696c1190c3e8b992ff7b9110eb3bedd.patch";
41 hash = "sha256-KfzqnRyQfz6nuMKnsHoUzb9rn9h/Pg54mupW1Cr+Zx0=";
43 ] ++ lib.optionals mbrolaSupport [
44 # Hardcode correct mbrola paths.
51 nativeBuildInputs = [ autoconf automake which libtool pkg-config ronn makeWrapper ];
53 buildInputs = lib.optional mbrolaSupport mbrola
54 ++ lib.optional pcaudiolibSupport pcaudiolib
55 ++ lib.optional sonicSupport sonic
56 ++ lib.optionals stdenv.hostPlatform.isDarwin [
62 # touch ChangeLog to avoid below error on darwin:
63 # Makefile.am: error: required file './ChangeLog.md' not found
64 preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin ''
71 "--with-mbrola=${if mbrolaSupport then "yes" else "no"}"
74 # ref https://github.com/void-linux/void-packages/blob/3cf863f894b67b3c93e23ac7830ca46b697d308a/srcpkgs/espeak-ng/template#L29-L31
75 postConfigure = lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
76 substituteInPlace Makefile \
77 --replace 'ESPEAK_DATA_PATH=$(CURDIR) src/espeak-ng' 'ESPEAK_DATA_PATH=$(CURDIR) ${lib.getExe buildPackages.espeak-ng}' \
78 --replace 'espeak-ng-data/%_dict: src/espeak-ng' 'espeak-ng-data/%_dict: ${lib.getExe buildPackages.espeak-ng}' \
79 --replace '../src/espeak-ng --compile' "${lib.getExe buildPackages.espeak-ng} --compile"
82 postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
83 patchelf --set-rpath "$(patchelf --print-rpath $out/bin/espeak-ng)" $out/bin/speak-ng
84 wrapProgram $out/bin/espeak-ng \
85 --set ALSA_PLUGIN_DIR ${alsa-plugins}/lib/alsa-lib
89 inherit mbrolaSupport;
93 description = "Open source speech synthesizer that supports over 70 languages, based on eSpeak";
94 homepage = "https://github.com/espeak-ng/espeak-ng";
95 changelog = "https://github.com/espeak-ng/espeak-ng/blob/${version}/CHANGELOG.md";
96 license = licenses.gpl3Plus;
97 maintainers = with maintainers; [ aske ];
98 platforms = platforms.all;
99 mainProgram = "espeak-ng";