Merge branch 'staging' into core-updates
[jackhill/guix/guix.git] / gnu / packages / speech.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2016, 2019 Marius Bakke <mbakke@fastmail.com>
4 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
5 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; Copyright © 2016 Kei Kebreau <kkebreau@posteo.net>
7 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages speech)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix utils)
30 #:use-module (guix build-system gnu)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages audio)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages emacs)
36 #:use-module (gnu packages gcc)
37 #:use-module (gnu packages glib)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages ncurses)
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages pulseaudio)
42 #:use-module (gnu packages python)
43 #:use-module (gnu packages texinfo)
44 #:use-module (gnu packages textutils))
45
46 (define-public espeak
47 (package
48 (name "espeak")
49 (version "1.48.04")
50 (source (origin
51 (method url-fetch)
52 (uri (string-append "mirror://sourceforge/espeak/espeak/"
53 "espeak-" (version-major+minor version)
54 "/espeak-" version "-source.zip"))
55 (sha256
56 (base32
57 "0n86gwh9pw0jqqpdz7mxggllfr8k0r7pc67ayy7w5z6z79kig6mz"))
58 (modules '((guix build utils)))
59 (snippet
60 ;; remove prebuilt binaries
61 '(begin
62 (delete-file-recursively "linux_32bit")
63 #t))))
64 (build-system gnu-build-system)
65 (arguments
66 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
67 (string-append "DATADIR="
68 (assoc-ref %outputs "out")
69 "/share/espeak-data")
70 (string-append "LDFLAGS=-Wl,-rpath="
71 (assoc-ref %outputs "out")
72 "/lib")
73 ;; The package fails to build with newer C++ standards.
74 "CXXFLAGS=-std=c++98"
75 "AUDIO=pulseaudio")
76 #:tests? #f ; no check target
77 #:phases
78 (modify-phases %standard-phases
79 (replace 'configure
80 (lambda _
81 (chdir "src")
82 ;; We use version 19 of the PortAudio library, so we must copy the
83 ;; corresponding file to be sure that espeak compiles correctly.
84 (copy-file "portaudio19.h" "portaudio.h")
85 (substitute* "Makefile"
86 (("/bin/ln") "ln"))
87 #t)))))
88 (inputs
89 `(("portaudio" ,portaudio)
90 ("pulseaudio" ,pulseaudio)))
91 (native-inputs `(("unzip" ,unzip)))
92 (home-page "http://espeak.sourceforge.net/")
93 (synopsis "Software speech synthesizer")
94 (description "eSpeak is a software speech synthesizer for English and
95 other languages. eSpeak uses a \"formant synthesis\" method. This allows many
96 languages to be provided in a small size. The speech is clear, and can be used
97 at high speeds, but is not as natural or smooth as larger synthesizers which are
98 based on human speech recordings.")
99 (license license:gpl3+)))
100
101 (define-public espeak-ng
102 (package
103 (name "espeak-ng")
104 (version "1.49.2")
105 (home-page "https://github.com/espeak-ng/espeak-ng")
106 (source (origin
107 (method url-fetch)
108 (uri (string-append home-page "/releases/download/" version
109 "/espeak-ng-" version ".tar.gz"))
110 (sha256
111 (base32 "1d10x9rbvqi2zwcz65fxh04k0x0scnk7732l37laz6xra1ldhzng"))))
112 (build-system gnu-build-system)
113 (arguments
114 `(#:configure-flags '("--disable-static")
115 ;; Building in parallel triggers a race condition in 1.49.2.
116 #:parallel-build? #f
117 ;; XXX: Some tests require an audio device.
118 #:tests? #f))
119 (inputs
120 `(("libcap" ,libcap)
121 ("pcaudiolib" ,pcaudiolib)))
122 (synopsis "Software speech synthesizer")
123 (description
124 "eSpeak NG is a software speech synthesizer for more than 100 languages.
125 It is based on the eSpeak engine and supports spectral and Klatt formant
126 synthesis, and the ability to use MBROLA voices.")
127 (license license:gpl3+)))
128
129 (define-public mitlm
130 (package
131 (name "mitlm")
132 (version "0.4.2")
133 (source (origin
134 (method url-fetch)
135 (uri (string-append "https://github.com/mitlm/mitlm/releases/"
136 "download/v" version "/"
137 name "-" version ".tar.xz"))
138 (sha256
139 (base32
140 "09fv4fcpmw9g1j0zml0k5kk1lgjw2spr8gn51llbkaaph6v8d62a"))))
141 (build-system gnu-build-system)
142 (native-inputs
143 `(("gfortran" ,gfortran)))
144 (synopsis "The MIT Language Modeling toolkit")
145 (description "The MIT Language Modeling (MITLM) toolkit is a set of
146 tools designed for the efficient estimation of statistical n-gram language
147 models involving iterative parameter estimation. It achieves much of its
148 efficiency through the use of a compact vector representation of n-grams.")
149 (home-page "https://github.com/mitlm/mitlm")
150 (license license:expat)))
151
152 (define-public speech-dispatcher
153 (package
154 (name "speech-dispatcher")
155 (version "0.9.1")
156 (source (origin
157 (method url-fetch)
158 (uri (string-append "https://github.com/brailcom/speechd/releases"
159 "/download/" version "/speech-dispatcher-"
160 version ".tar.gz"))
161 (sha256
162 (base32
163 "16bg52hnkrsrs7kgbzanb34b9zb6fqxwj0a9bmsxmj1skkil1h1p"))))
164 (build-system gnu-build-system)
165 (arguments
166 `(#:configure-flags '("--disable-static"
167
168 ;; Disable support for proprietary TTS engines.
169 "--with-ibmtts=no"
170 "--with-kali=no" "--with-baratinoo=no")))
171 (native-inputs
172 `(("intltool" ,intltool)
173 ("pkg-config" ,pkg-config)))
174 (inputs
175 `(("dotconf" ,dotconf)
176 ("espeak" ,espeak-ng)
177 ("glib" ,glib)
178 ("libltdl" ,libltdl)
179 ("libsndfile" ,libsndfile)
180 ("pulseaudio" ,pulseaudio)
181 ("python" ,python)))
182 (synopsis "Common interface to speech synthesizers")
183 (description "The Speech Dispatcher project provides a high-level
184 device independent layer for access to speech synthesis through a simple,
185 stable and well documented interface.")
186 (home-page "https://devel.freebsoft.org/speechd")
187 ;; The software is distributed under GPL2+, but includes a number
188 ;; of files covered by other licenses. Note: in practice, this
189 ;; is linked against dotconf, which is LGPL 2.1 only.
190 (license (list license:gpl2+
191 license:fdl1.2+ ; Most files in doc/ are dual gpl2+/fdl1.2+.
192 license:lgpl2.1+
193 (license:non-copyleft
194 ;; festival_client.{c,h} carries an expat-style license.
195 "See src/modules/festival_client.c in the distribution.")
196 license:gpl3+)))) ; doc/texinfo.tex -- with TeX exception.
197
198 (define-public sonic
199 (package
200 (name "sonic")
201 (version "0.2.0")
202 (source (origin
203 (method git-fetch)
204 (uri (git-reference
205 (url "https://github.com/waywardgeek/sonic")
206 (commit (string-append "release-" version))))
207 (file-name (git-file-name name version))
208 (sha256
209 (base32
210 "08xwnpw9cnaix1n1i7gvpq5hrfrqc2z1snjhjapfam506hrc77g4"))))
211 (build-system gnu-build-system)
212 (arguments
213 `(#:tests? #f ; No test suite.
214 #:make-flags
215 (list (string-append "DESTDIR=" (assoc-ref %outputs "out")))
216 #:phases
217 (modify-phases %standard-phases
218 (delete 'configure)))) ; No ./configure script.
219 (synopsis "Speed up or slow down speech")
220 (description "Sonic implements a simple algorithm for speeding up or slowing
221 down speech. However, it's optimized for speed ups of over 2X, unlike previous
222 algorithms for changing speech rate. Sonic is a C library designed to be easily
223 integrated into streaming voice applications such as text-to-speech (TTS) back
224 ends.
225
226 The primary motivation behind Sonic is to enable the blind and visually impaired
227 to improve their productivity with speech engines, like eSpeak. Sonic can also
228 be used by the sighted.")
229 (home-page "https://github.com/waywardgeek/sonic")
230 (license license:asl2.0)))
231
232 (define-public festival
233 (package
234 (name "festival")
235 (version "2.5.0")
236 (source (origin
237 (method url-fetch)
238 (uri (string-append "http://festvox.org/packed/festival/"
239 (version-major+minor version)
240 "/festival-" version "-release.tar.gz"))
241 (sha256
242 (base32
243 "1d5415nckiv19adxisxfm1l1xxfyw88g87ckkmcr0lhjdd10g42c"))))
244 (build-system gnu-build-system)
245 (arguments
246 `(#:tests? #f ; there is no test target
247 #:make-flags
248 (list (string-append "RM="
249 (assoc-ref %build-inputs "coreutils")
250 "/bin/rm")
251 (string-append "ECHO_N="
252 (assoc-ref %build-inputs "coreutils")
253 "/bin/printf \"%s\""))
254 #:parallel-build? #f ; not supported
255 #:modules ((guix build gnu-build-system)
256 (guix build utils)
257 (guix build emacs-utils))
258 #:imported-modules (,@%gnu-build-system-modules
259 (guix build emacs-utils))
260 #:phases
261 (modify-phases %standard-phases
262 (add-after 'unpack 'unpack-and-patch-speech-tools
263 (lambda* (#:key inputs #:allow-other-keys)
264 (invoke "tar" "-C" ".."
265 "-xf" (assoc-ref inputs "speech-tools"))
266 (with-directory-excursion "../speech_tools"
267 (substitute* '("config/rules/modules.mak"
268 "config/rules/test_make_rules.mak"
269 "config/make_system.mak")
270 (("/bin/sh") (which "sh"))))
271 #t))
272 (add-after 'unpack 'patch-/bin/sh
273 (lambda _
274 (substitute* '("config/test_make_rules"
275 "config/make_system.mak")
276 (("/bin/sh") (which "sh")))
277 #t))
278 (add-before 'build 'build-speech-tools
279 (lambda* (#:key configure-flags make-flags #:allow-other-keys)
280 (with-directory-excursion "../speech_tools"
281 (apply invoke "sh" "configure"
282 (string-append "CONFIG_SHELL=" (which "sh"))
283 (string-append "SHELL=" (which "sh"))
284 configure-flags)
285 (apply invoke "make" make-flags))))
286 (add-after 'build 'build-documentation
287 (lambda _
288 (with-directory-excursion "doc"
289 (invoke "make" "festival.info"))))
290 (add-after 'unpack 'set-installation-directories
291 (lambda* (#:key outputs #:allow-other-keys)
292 (let ((out (assoc-ref outputs "out")))
293 (substitute* "config/project.mak"
294 (("^FTLIBDIR.*")
295 (string-append "FTLIBDIR=" out "/share/festival/lib")))
296 (substitute* "config/systems/default.mak"
297 (("^INSTALL_PREFIX.*")
298 (string-append "INSTALL_PREFIX=" out)))
299 #t)))
300 (add-after 'install 'actually-install
301 (lambda* (#:key inputs outputs #:allow-other-keys)
302 (let ((out (assoc-ref outputs "out")))
303 ;; Install Speech Tools first
304 (with-directory-excursion "../speech_tools"
305 ;; Target directories
306 (for-each (lambda (dir)
307 (mkdir-p (string-append out dir)))
308 '("/bin"
309 "/lib"
310 "/include/speech_tools/"
311 "/include/speech_tools/instantiate"
312 "/include/speech_tools/ling_class"
313 "/include/speech_tools/rxp"
314 "/include/speech_tools/sigpr"
315 "/include/speech_tools/unix"))
316 ;; Install binaries
317 (for-each (lambda (file)
318 (install-file file (string-append out "/bin")))
319 (find-files "bin" ".*"))
320 (for-each (lambda (file)
321 (delete-file (string-append out "/bin/" file)))
322 '("est_gdb" "est_examples" "est_program"))
323 ;; Install libraries
324 (for-each (lambda (file)
325 (install-file file (string-append out "/lib")))
326 (find-files "lib" "lib.*\\.so.*"))
327
328 ;; Install headers
329 (for-each
330 (lambda (dir)
331 (for-each
332 (lambda (header)
333 (install-file header
334 (string-append out "/include/speech_tools/" dir)))
335 (find-files (string-append "include/" dir)
336 "\\.h$")))
337 '("." "instantiate" "ling_class" "rxp" "sigpr" "unix")))
338
339 ;; Unpack files that will be installed together with the
340 ;; Festival libraries.
341 (invoke "tar" "--strip-components=1"
342 "-xvf" (assoc-ref inputs "festvox-cmu"))
343 (invoke "tar" "--strip-components=1"
344 "-xvf" (assoc-ref inputs "festvox-poslex"))
345 (invoke "tar" "--strip-components=1"
346 "-xvf" (assoc-ref inputs "default-voice"))
347
348 ;; Install Festival
349 (let ((bin (string-append out "/bin"))
350 (incdir (string-append out "/include/festival"))
351 (share (string-append out "/share/festival"))
352 (info (string-append out "/share/info")))
353 (for-each (lambda (executable)
354 (install-file executable bin))
355 '("src/main/festival"
356 "src/main/festival_client"
357 "examples/benchmark"))
358 (let ((scripts '("examples/dumpfeats"
359 "examples/durmeanstd"
360 "examples/latest"
361 "examples/make_utts"
362 "examples/powmeanstd"
363 "examples/run-festival-script"
364 "examples/saytime"
365 "examples/scfg_parse_text"
366 "examples/text2pos"
367 "examples/text2wave")))
368 (substitute* scripts
369 (("exec /tmp/guix-build.*/bin/festival")
370 (string-append "exec " bin "/festival")))
371 (for-each (lambda (script)
372 (install-file script bin))
373 scripts))
374
375 ;; Documentation
376 (for-each (lambda (file)
377 (install-file file info))
378 (find-files "doc/info/" "festival.info.*"))
379
380 ;; Headers
381 (mkdir-p incdir)
382 (for-each (lambda (header)
383 (install-file header
384 (string-append incdir "/"
385 (dirname header))))
386 (find-files "src/include" "\\.h$"))
387
388 ;; Data
389 (mkdir-p share)
390 (for-each (lambda (file)
391 (install-file file
392 (string-append share "/"
393 (dirname file))))
394 (find-files "lib" ".*"))
395 (for-each delete-file
396 (append (find-files share "Makefile")
397 (find-files bin "Makefile")))))
398 #t))
399 (add-after 'actually-install 'install-emacs-mode
400 (lambda* (#:key outputs #:allow-other-keys)
401 (let ((emacs-dir (string-append (assoc-ref outputs "out")
402 "/share/emacs/site-lisp")))
403 (install-file "lib/festival.el" emacs-dir)
404 (emacs-generate-autoloads ,name emacs-dir)
405 #t)))
406 ;; Rebuild the very old configure script that is confused by extra
407 ;; arguments.
408 (add-before 'configure 'bootstrap
409 (lambda _ (invoke "autoreconf" "-vif"))))))
410 (inputs
411 `(("ncurses" ,ncurses)))
412 (native-inputs
413 `(("autoconf" ,autoconf)
414 ("automake" ,automake)
415 ("texinfo" ,texinfo)
416 ("emacs" ,emacs-minimal)
417 ("festvox-cmu"
418 ,(origin
419 (method url-fetch)
420 (uri (string-append "http://festvox.org/packed/festival/"
421 (version-major+minor version)
422 "/festlex_CMU.tar.gz"))
423 (sha256
424 (base32
425 "01vwidqhhg2zifvk1gby91mckg1z2pv2mj6lihvdaifakf8k1561"))))
426 ("festvox-poslex"
427 ,(origin
428 (method url-fetch)
429 (uri (string-append "http://festvox.org/packed/festival/"
430 (version-major+minor version)
431 "/festlex_POSLEX.tar.gz"))
432 (sha256
433 (base32
434 "18wywilxaqwy63lc47p5g5529mpxhslibh1bjij0snxx5mjf7ip7"))))
435 ("default-voice"
436 ,(origin
437 (method url-fetch)
438 (uri (string-append "http://festvox.org/packed/festival/"
439 (version-major+minor version)
440 "/voices/festvox_kallpc16k.tar.gz"))
441 (sha256
442 (base32
443 "136hmsyiwnlg2qwa508dy0imf19mzrb5r3dmb2kg8kcyxnslm740"))))
444 ("speech-tools"
445 ,(origin
446 (method url-fetch)
447 (uri (string-append "http://festvox.org/packed/festival/"
448 (version-major+minor version)
449 "/speech_tools-" version "-release.tar.gz"))
450 (sha256
451 (base32
452 "1k2xh13miyv48gh06rgsq2vj25xwj7z6vwq9ilsn8i7ig3nrgzg4"))))))
453 (home-page "http://www.cstr.ed.ac.uk/projects/festival/")
454 (synopsis "Speech synthesis system")
455 (description "Festival offers a general framework for building speech
456 synthesis systems as well as including examples of various modules. As a
457 whole it offers full text to speech through a number APIs: from shell level,
458 though a Scheme command interpreter, as a C++ library, from Java, and an Emacs
459 interface. Festival is multi-lingual though English is the most advanced.
460 The system is written in C++ and uses the Edinburgh Speech Tools Library for
461 low level architecture and has a Scheme (SIOD) based command interpreter for
462 control.")
463 (license (license:non-copyleft "file://COPYING"))))