1{ stdenv
2, lib
3, substituteAll
4, pkg-config
5, fetchurl
6, python3Packages
7, gettext
8, itstool
9, libtool
10, texinfo
11, util-linux
12, autoreconfHook
13, glib
14, dotconf
15, libsndfile
16, withLibao ? true, libao
17, withPulse ? false, libpulseaudio
18, withAlsa ? false, alsa-lib
19, withOss ? false
20, withFlite ? true, flite
21, withEspeak ? true, espeak, sonic, pcaudiolib
22, mbrola
23, withPico ? true, svox
24, libsOnly ? false
25}:
26
27let
28 inherit (python3Packages) python pyxdg wrapPython;
29in stdenv.mkDerivation rec {
30 pname = "speech-dispatcher";
31 version = "0.11.5";
32
33 src = fetchurl {
34 url = "https://github.com/brailcom/speechd/releases/download/${version}/${pname}-${version}.tar.gz";
35 sha256 = "sha256-HOR1n/q7rxrrQzpewHOb4Gdum9+66URKezvhsq8+wSs=";
36 };
37
38 patches = [
39 (substituteAll {
40 src = ./fix-paths.patch;
41 utillinux = util-linux;
42 })
43 ] ++ lib.optionals (withEspeak && espeak.mbrolaSupport) [
44 # Replace FHS paths.
45 (substituteAll {
46 src = ./fix-mbrola-paths.patch;
47 inherit espeak mbrola;
48 })
49 ];
50
51 nativeBuildInputs = [
52 pkg-config
53 autoreconfHook
54 gettext
55 libtool
56 itstool
57 texinfo
58 wrapPython
59 ];
60
61 buildInputs = [
62 glib
63 dotconf
64 libsndfile
65 libao
66 libpulseaudio
67 alsa-lib
68 python
69 ] ++ lib.optionals withEspeak [
70 espeak
71 sonic
72 pcaudiolib
73 ] ++ lib.optionals withFlite [
74 flite
75 ] ++ lib.optionals withPico [
76 svox
77 ];
78
79 pythonPath = [
80 pyxdg
81 ];
82
83 configureFlags = [
84 # Audio method falls back from left to right.
85 "--with-default-audio-method=\"libao,pulse,alsa,oss\""
86 "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
87 ] ++ lib.optionals withPulse [
88 "--with-pulse"
89 ] ++ lib.optionals withAlsa [
90 "--with-alsa"
91 ] ++ lib.optionals withLibao [
92 "--with-libao"
93 ] ++ lib.optionals withOss [
94 "--with-oss"
95 ] ++ lib.optionals withEspeak [
96 "--with-espeak-ng"
97 ] ++ lib.optionals withPico [
98 "--with-pico"
99 ];
100
101 postPatch = ''
102 substituteInPlace src/modules/pico.c --replace "/usr/share/pico/lang" "${svox}/share/pico/lang"
103 '';
104
105 postInstall = if libsOnly then ''
106 rm -rf $out/{bin,etc,lib/speech-dispatcher,lib/systemd,libexec,share}
107 '' else ''
108 wrapPythonPrograms
109 '';
110
111 enableParallelBuilding = true;
112
113 meta = with lib; {
114 description = "Common interface to speech synthesis" + lib.optionalString libsOnly " - client libraries only";
115 homepage = "https://devel.freebsoft.org/speechd";
116 license = licenses.gpl2Plus;
117 maintainers = with maintainers; [
118 berce
119 jtojnar
120 ];
121 platforms = platforms.linux;
122 mainProgram = "speech-dispatcher";
123 };
124}