1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2016, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
4 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
5 ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; Copyright © 2016 Kei Kebreau <kkebreau@posteo.net>
7 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
8 ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
9 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages speech)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix packages)
29 #:use-module (guix download)
30 #:use-module (guix git-download)
31 #:use-module (guix utils)
32 #:use-module (guix build-system gnu)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages audio)
35 #:use-module (gnu packages autotools)
36 #:use-module (gnu packages base) ;for 'which'
37 #:use-module (gnu packages bison)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages documentation)
40 #:use-module (gnu packages emacs)
41 #:use-module (gnu packages gcc)
42 #:use-module (gnu packages glib)
43 #:use-module (gnu packages gstreamer)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages ncurses)
46 #:use-module (gnu packages perl)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages pulseaudio)
49 #:use-module (gnu packages python)
50 #:use-module (gnu packages swig)
51 #:use-module (gnu packages texinfo)
52 #:use-module (gnu packages textutils))
62 (string-append "http://www.festvox.org/" name "/packed/" name
63 "-" version "/" name "-" version "-release.tar.bz2"))
65 (base32 "119b7l7pjb1l5raqq24p8rmhdqni49vjh2mgdryrfr575rm3yg67"))))
66 (build-system gnu-build-system)
69 ;; There numerous issues with the testsuite.
70 ;; Enable all of them once they are fixed in upstream.
75 (string-append "LDFLAGS=-Wl,-rpath="
76 (assoc-ref %outputs "out")
79 (modify-phases %standard-phases
80 (add-after 'unpack 'patch-rpath
82 (substitute* "main/Makefile"
83 (("flite_LIBS_flags \\+= -Wl,-rpath [^ ]*")
84 "flite_LIBS_flags +="))
87 ;; Modifying testsuite/Makefile is not done in favor of
89 ;; The path not taken would be:
90 ;; test:\n\t$(foreach x,$(subst tris1,,$(subst dcoffset_wave,,$(subst flite_test,,$(subst by_word,,$(subst bin2ascii,,$(subst lpc_resynth,,$(subst rfc,,$(subst compare_wave,,$(subst record_in_noise,,$(subst combine_waves,,$(patsubst play_%,,$(subst record_wave,,$(subst lex_lookup,,$(patsubst lpc_test%,,$(patsubst asciiS2U%,,$(patsubst asciiU2S%,,$(ALL))))))))))))))))),echo TEST $x && ./$x data.one && ) true
91 (add-after 'install 'check
93 (invoke "make" "-C" "testsuite")
94 (with-directory-excursion "testsuite"
95 (invoke "./token_test")
97 (invoke "./regex_test")
98 (invoke "./nums_test")
100 (invoke "./utt_test")
101 (invoke "./multi_thread"))
103 (add-after 'install 'remove-static-libs
104 (lambda* (#:key outputs #:allow-other-keys)
105 (let* ((out (assoc-ref outputs "out")))
106 (for-each delete-file
107 (find-files out "\\.a$"))
112 `(("alsa" ,alsa-lib)))
113 (synopsis "Speech synthesis system")
114 (description "Flite (festival-lite) is a small, fast run-time text to speech
115 synthesis engine developed at CMU and primarily designed for small embedded
116 machines and/or large servers. It is designed as an alternative text to speech
117 synthesis engine to Festival for voices built using the FestVox suite of voice
119 (home-page "http://www.festvox.org/flite/index.html")
120 (license (license:non-copyleft "file:///COPYING"))))
122 (define-public espeak
128 (uri (string-append "mirror://sourceforge/espeak/espeak/"
129 "espeak-" (version-major+minor version)
130 "/espeak-" version "-source.zip"))
133 "0n86gwh9pw0jqqpdz7mxggllfr8k0r7pc67ayy7w5z6z79kig6mz"))
134 (modules '((guix build utils)))
136 ;; remove prebuilt binaries
138 (delete-file-recursively "linux_32bit")
140 (build-system gnu-build-system)
142 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
143 (string-append "DATADIR="
144 (assoc-ref %outputs "out")
145 "/share/espeak-data")
146 (string-append "LDFLAGS=-Wl,-rpath="
147 (assoc-ref %outputs "out")
149 ;; The package fails to build with newer C++ standards.
150 "CXXFLAGS=-std=c++98"
152 #:tests? #f ; no check target
154 (modify-phases %standard-phases
158 ;; We use version 19 of the PortAudio library, so we must copy the
159 ;; corresponding file to be sure that espeak compiles correctly.
160 (copy-file "portaudio19.h" "portaudio.h")
161 (substitute* "Makefile"
165 `(("portaudio" ,portaudio)
166 ("pulseaudio" ,pulseaudio)))
167 (native-inputs `(("unzip" ,unzip)))
168 (home-page "http://espeak.sourceforge.net/")
169 (synopsis "Software speech synthesizer")
170 (description "eSpeak is a software speech synthesizer for English and
171 other languages. eSpeak uses a \"formant synthesis\" method. This allows many
172 languages to be provided in a small size. The speech is clear, and can be used
173 at high speeds, but is not as natural or smooth as larger synthesizers which are
174 based on human speech recordings.")
175 (license license:gpl3+)))
177 (define-public espeak-ng
181 (home-page "https://github.com/espeak-ng/espeak-ng")
182 ;; Note: eSpeak NG publishes release tarballs, but the 1.50 tarball is
183 ;; broken: <https://github.com/espeak-ng/espeak-ng/issues/683>.
184 ;; Download the raw repository to work around it; remove 'native-inputs'
185 ;; below when switching back to the release tarball.
188 (uri (git-reference (url home-page) (commit version)))
189 (file-name (git-file-name name version))
191 (base32 "0jkqhf2h94vbqq7mg7mmm23bq372fa7mdk941my18c3vkldcir1b"))))
192 (build-system gnu-build-system)
194 `(#:configure-flags '("--disable-static")
195 ;; Building in parallel triggers a race condition in 1.49.2.
197 ;; XXX: Some tests require an audio device.
200 `(("autoconf" ,autoconf)
201 ("automake" ,automake)
206 ("pcaudiolib" ,pcaudiolib)))
207 (synopsis "Software speech synthesizer")
209 "eSpeak NG is a software speech synthesizer for more than 100 languages.
210 It is based on the eSpeak engine and supports spectral and Klatt formant
211 synthesis, and the ability to use MBROLA voices.")
212 (license license:gpl3+)))
220 (uri (string-append "https://github.com/mitlm/mitlm/releases/"
221 "download/v" version "/"
222 name "-" version ".tar.xz"))
225 "09fv4fcpmw9g1j0zml0k5kk1lgjw2spr8gn51llbkaaph6v8d62a"))))
226 (build-system gnu-build-system)
228 `(("gfortran" ,gfortran)))
229 (synopsis "The MIT Language Modeling toolkit")
230 (description "The MIT Language Modeling (MITLM) toolkit is a set of
231 tools designed for the efficient estimation of statistical n-gram language
232 models involving iterative parameter estimation. It achieves much of its
233 efficiency through the use of a compact vector representation of n-grams.")
234 (home-page "https://github.com/mitlm/mitlm")
235 (license license:expat)))
237 (define-public speech-dispatcher
239 (name "speech-dispatcher")
243 (uri (string-append "https://github.com/brailcom/speechd/releases"
244 "/download/" version "/speech-dispatcher-"
248 "16bg52hnkrsrs7kgbzanb34b9zb6fqxwj0a9bmsxmj1skkil1h1p"))))
249 (build-system gnu-build-system)
251 `(#:configure-flags '("--disable-static"
253 ;; Disable support for proprietary TTS engines.
255 "--with-kali=no" "--with-baratinoo=no")))
257 `(("intltool" ,intltool)
258 ("pkg-config" ,pkg-config)))
260 `(("dotconf" ,dotconf)
261 ("espeak" ,espeak-ng)
264 ("libsndfile" ,libsndfile)
265 ("pulseaudio" ,pulseaudio)
267 (synopsis "Common interface to speech synthesizers")
268 (description "The Speech Dispatcher project provides a high-level
269 device independent layer for access to speech synthesis through a simple,
270 stable and well documented interface.")
271 (home-page "https://devel.freebsoft.org/speechd")
272 ;; The software is distributed under GPL2+, but includes a number
273 ;; of files covered by other licenses. Note: in practice, this
274 ;; is linked against dotconf, which is LGPL 2.1 only.
275 (license (list license:gpl2+
276 license:fdl1.2+ ; Most files in doc/ are dual gpl2+/fdl1.2+.
278 (license:non-copyleft
279 ;; festival_client.{c,h} carries an expat-style license.
280 "See src/modules/festival_client.c in the distribution.")
281 license:gpl3+)))) ; doc/texinfo.tex -- with TeX exception.
290 (url "https://github.com/waywardgeek/sonic")
291 (commit (string-append "release-" version))))
292 (file-name (git-file-name name version))
295 "08xwnpw9cnaix1n1i7gvpq5hrfrqc2z1snjhjapfam506hrc77g4"))))
296 (build-system gnu-build-system)
298 `(#:tests? #f ; no test suite
300 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
301 (string-append "LDFLAGS=-Wl,-rpath="
302 (assoc-ref %outputs "out") "/lib"))
304 (modify-phases %standard-phases
305 (add-after 'unpack 'respect-LDFLAGS
307 (substitute* "Makefile"
308 ((" -o sonic " match)
309 (string-append " $(LDFLAGS)" match)))
311 (delete 'configure)))) ; no ./configure script
312 (synopsis "Speed up or slow down speech")
313 (description "Sonic implements a simple algorithm for speeding up or slowing
314 down speech. However, it's optimized for speed ups of over 2X, unlike previous
315 algorithms for changing speech rate. Sonic is a C library designed to be easily
316 integrated into streaming voice applications such as text-to-speech (TTS) back
319 The primary motivation behind Sonic is to enable the blind and visually impaired
320 to improve their productivity with speech engines, like eSpeak. Sonic can also
321 be used by the sighted.")
322 (home-page "https://github.com/waywardgeek/sonic")
323 (license license:asl2.0)))
325 (define-public festival
331 (uri (string-append "http://festvox.org/packed/festival/"
332 (version-major+minor version)
333 "/festival-" version "-release.tar.gz"))
336 "1d5415nckiv19adxisxfm1l1xxfyw88g87ckkmcr0lhjdd10g42c"))))
337 (build-system gnu-build-system)
339 `(#:tests? #f ; there is no test target
341 (list (string-append "RM="
342 (assoc-ref %build-inputs "coreutils")
344 (string-append "ECHO_N="
345 (assoc-ref %build-inputs "coreutils")
346 "/bin/printf \"%s\""))
347 #:parallel-build? #f ; not supported
348 #:modules ((guix build gnu-build-system)
350 (guix build emacs-utils))
351 #:imported-modules (,@%gnu-build-system-modules
352 (guix build emacs-utils))
354 (modify-phases %standard-phases
355 (add-after 'unpack 'unpack-and-patch-speech-tools
356 (lambda* (#:key inputs #:allow-other-keys)
357 (invoke "tar" "-C" ".."
358 "-xf" (assoc-ref inputs "speech-tools"))
359 (with-directory-excursion "../speech_tools"
360 (substitute* '("config/rules/modules.mak"
361 "config/rules/test_make_rules.mak"
362 "config/make_system.mak")
363 (("/bin/sh") (which "sh"))))
365 (add-after 'unpack 'patch-/bin/sh
367 (substitute* '("config/test_make_rules"
368 "config/make_system.mak")
369 (("/bin/sh") (which "sh")))
371 (add-before 'build 'build-speech-tools
372 (lambda* (#:key configure-flags make-flags #:allow-other-keys)
373 (with-directory-excursion "../speech_tools"
374 (apply invoke "sh" "configure"
375 (string-append "CONFIG_SHELL=" (which "sh"))
376 (string-append "SHELL=" (which "sh"))
378 (apply invoke "make" make-flags))))
379 (add-after 'build 'build-documentation
381 (with-directory-excursion "doc"
382 (invoke "make" "festival.info"))))
383 (add-after 'unpack 'set-installation-directories
384 (lambda* (#:key outputs #:allow-other-keys)
385 (let ((out (assoc-ref outputs "out")))
386 (substitute* "config/project.mak"
388 (string-append "FTLIBDIR=" out "/share/festival/lib")))
389 (substitute* "config/systems/default.mak"
390 (("^INSTALL_PREFIX.*")
391 (string-append "INSTALL_PREFIX=" out)))
393 (add-after 'install 'actually-install
394 (lambda* (#:key inputs outputs #:allow-other-keys)
395 (let ((out (assoc-ref outputs "out")))
396 ;; Install Speech Tools first
397 (with-directory-excursion "../speech_tools"
398 ;; Target directories
399 (for-each (lambda (dir)
400 (mkdir-p (string-append out dir)))
403 "/include/speech_tools/"
404 "/include/speech_tools/instantiate"
405 "/include/speech_tools/ling_class"
406 "/include/speech_tools/rxp"
407 "/include/speech_tools/sigpr"
408 "/include/speech_tools/unix"))
410 (for-each (lambda (file)
411 (install-file file (string-append out "/bin")))
412 (find-files "bin" ".*"))
413 (for-each (lambda (file)
414 (delete-file (string-append out "/bin/" file)))
415 '("est_gdb" "est_examples" "est_program"))
417 (for-each (lambda (file)
418 (install-file file (string-append out "/lib")))
419 (find-files "lib" "lib.*\\.so.*"))
427 (string-append out "/include/speech_tools/" dir)))
428 (find-files (string-append "include/" dir)
430 '("." "instantiate" "ling_class" "rxp" "sigpr" "unix")))
432 ;; Unpack files that will be installed together with the
433 ;; Festival libraries.
434 (invoke "tar" "--strip-components=1"
435 "-xvf" (assoc-ref inputs "festvox-cmu"))
436 (invoke "tar" "--strip-components=1"
437 "-xvf" (assoc-ref inputs "festvox-poslex"))
438 (invoke "tar" "--strip-components=1"
439 "-xvf" (assoc-ref inputs "default-voice"))
442 (let ((bin (string-append out "/bin"))
443 (incdir (string-append out "/include/festival"))
444 (share (string-append out "/share/festival"))
445 (info (string-append out "/share/info")))
446 (for-each (lambda (executable)
447 (install-file executable bin))
448 '("src/main/festival"
449 "src/main/festival_client"
450 "examples/benchmark"))
451 (let ((scripts '("examples/dumpfeats"
452 "examples/durmeanstd"
455 "examples/powmeanstd"
456 "examples/run-festival-script"
458 "examples/scfg_parse_text"
460 "examples/text2wave")))
462 (("exec /tmp/guix-build.*/bin/festival")
463 (string-append "exec " bin "/festival")))
464 (for-each (lambda (script)
465 (install-file script bin))
469 (for-each (lambda (file)
470 (install-file file info))
471 (find-files "doc/info/" "festival.info.*"))
475 (for-each (lambda (header)
477 (string-append incdir "/"
479 (find-files "src/include" "\\.h$"))
483 (for-each (lambda (file)
485 (string-append share "/"
487 (find-files "lib" ".*"))
488 (for-each delete-file
489 (append (find-files share "Makefile")
490 (find-files bin "Makefile")))))
492 (add-after 'actually-install 'install-emacs-mode
493 (lambda* (#:key outputs #:allow-other-keys)
494 (let ((emacs-dir (string-append (assoc-ref outputs "out")
495 "/share/emacs/site-lisp")))
496 (install-file "lib/festival.el" emacs-dir)
497 (emacs-generate-autoloads ,name emacs-dir)
499 ;; Rebuild the very old configure script that is confused by extra
501 (add-before 'configure 'bootstrap
502 (lambda _ (invoke "autoreconf" "-vif"))))))
504 `(("ncurses" ,ncurses)))
506 `(("autoconf" ,autoconf)
507 ("automake" ,automake)
509 ("emacs" ,emacs-minimal)
513 (uri (string-append "http://festvox.org/packed/festival/"
514 (version-major+minor version)
515 "/festlex_CMU.tar.gz"))
518 "01vwidqhhg2zifvk1gby91mckg1z2pv2mj6lihvdaifakf8k1561"))))
522 (uri (string-append "http://festvox.org/packed/festival/"
523 (version-major+minor version)
524 "/festlex_POSLEX.tar.gz"))
527 "18wywilxaqwy63lc47p5g5529mpxhslibh1bjij0snxx5mjf7ip7"))))
531 (uri (string-append "http://festvox.org/packed/festival/"
532 (version-major+minor version)
533 "/voices/festvox_kallpc16k.tar.gz"))
536 "136hmsyiwnlg2qwa508dy0imf19mzrb5r3dmb2kg8kcyxnslm740"))))
540 (uri (string-append "http://festvox.org/packed/festival/"
541 (version-major+minor version)
542 "/speech_tools-" version "-release.tar.gz"))
545 "1k2xh13miyv48gh06rgsq2vj25xwj7z6vwq9ilsn8i7ig3nrgzg4"))))))
546 (home-page "http://www.cstr.ed.ac.uk/projects/festival/")
547 (synopsis "Speech synthesis system")
548 (description "Festival offers a general framework for building speech
549 synthesis systems as well as including examples of various modules. As a
550 whole it offers full text to speech through a number APIs: from shell level,
551 though a Scheme command interpreter, as a C++ library, from Java, and an Emacs
552 interface. Festival is multi-lingual though English is the most advanced.
553 The system is written in C++ and uses the Edinburgh Speech Tools Library for
554 low level architecture and has a Scheme (SIOD) based command interpreter for
556 (license (license:non-copyleft "file://COPYING"))))
558 (define-public sphinxbase
561 (version "5prealpha")
565 (uri (string-append "mirror://sourceforge/cmusphinx/"
566 "sphinxbase/" version "/"
567 "sphinxbase-" version ".tar.gz"))
569 (base32 "0vr4k8pv5a8nvq9yja7kl13b5lh0f9vha8fc8znqnm8bwmcxnazp"))
570 (patches (search-patches "sphinxbase-fix-doxygen.patch"))))
571 (build-system gnu-build-system)
573 `(#:parallel-tests? #f)) ;tests fail otherwise
577 ("perl" ,perl) ;for tests
581 `(("pulseaudio" ,pulseaudio)))
582 (home-page "https://cmusphinx.github.io/")
583 (synopsis "Support library required by Pocketsphinx and Sphinxtrain")
584 (description "This package contains the basic libraries shared by
585 the CMU Sphinx trainer and all the Sphinx decoders (Sphinx-II,
586 Sphinx-III, and PocketSphinx), as well as some common utilities for
587 manipulating acoustic feature and audio files.")
588 (license license:bsd-4)))
590 (define-public pocketsphinx
592 (name "pocketsphinx")
593 (version "5prealpha")
597 (uri (string-append "mirror://sourceforge/cmusphinx/"
598 "pocketsphinx/" version "/"
599 "pocketsphinx-" version ".tar.gz"))
601 (base32 "1n9yazzdgvpqgnfzsbl96ch9cirayh74jmpjf7svs4i7grabanzg"))))
602 (build-system gnu-build-system)
604 `(("pkg-config" ,pkg-config)
605 ("perl" ,perl) ;for tests
609 `(("gstreamer" ,gstreamer)
611 ("pulseaudio" ,pulseaudio)
612 ("sphinxbase" ,sphinxbase)))
613 (home-page "https://cmusphinx.github.io/")
614 (synopsis "Recognizer library written in C")
615 (description "PocketSphinx is one of Carnegie Mellon University's
616 large vocabulary, speaker-independent continuous speech recognition
618 (license license:bsd-2)))