16 pcaudiolibSupport ? true,
27 stdenv.mkDerivation rec {
31 src = fetchFromGitHub {
35 hash = "sha256-aAJ+k+kkOS6k835mEW7BvgAIYGhUHxf7Q4P5cKO8XTk=";
40 # Fix build with Clang 16.
42 url = "https://github.com/espeak-ng/espeak-ng/commit/497c6217d696c1190c3e8b992ff7b9110eb3bedd.patch";
43 hash = "sha256-KfzqnRyQfz6nuMKnsHoUzb9rn9h/Pg54mupW1Cr+Zx0=";
46 ++ lib.optionals mbrolaSupport [
47 # Hardcode correct mbrola paths.
65 lib.optional mbrolaSupport mbrola
66 ++ lib.optional pcaudiolibSupport pcaudiolib
67 ++ lib.optional sonicSupport sonic
68 ++ lib.optionals stdenv.hostPlatform.isDarwin [
74 # touch ChangeLog to avoid below error on darwin:
75 # Makefile.am: error: required file './ChangeLog.md' not found
77 lib.optionalString stdenv.hostPlatform.isDarwin ''
85 "--with-mbrola=${if mbrolaSupport then "yes" else "no"}"
88 # ref https://github.com/void-linux/void-packages/blob/3cf863f894b67b3c93e23ac7830ca46b697d308a/srcpkgs/espeak-ng/template#L29-L31
89 postConfigure = lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
90 substituteInPlace Makefile \
91 --replace 'ESPEAK_DATA_PATH=$(CURDIR) src/espeak-ng' 'ESPEAK_DATA_PATH=$(CURDIR) ${lib.getExe buildPackages.espeak-ng}' \
92 --replace 'espeak-ng-data/%_dict: src/espeak-ng' 'espeak-ng-data/%_dict: ${lib.getExe buildPackages.espeak-ng}' \
93 --replace '../src/espeak-ng --compile' "${lib.getExe buildPackages.espeak-ng} --compile"
96 postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
97 patchelf --set-rpath "$(patchelf --print-rpath $out/bin/espeak-ng)" $out/bin/speak-ng
98 wrapProgram $out/bin/espeak-ng \
99 --set ALSA_PLUGIN_DIR ${alsa-plugins}/lib/alsa-lib
103 inherit mbrolaSupport;
107 description = "Open source speech synthesizer that supports over 70 languages, based on eSpeak";
108 homepage = "https://github.com/espeak-ng/espeak-ng";
109 changelog = "https://github.com/espeak-ng/espeak-ng/blob/${version}/CHANGELOG.md";
110 license = licenses.gpl3Plus;
111 maintainers = with maintainers; [ aske ];
112 platforms = platforms.all;
113 mainProgram = "espeak-ng";