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