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, 2021 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>
10 ;;; Copyright © 2021 qblade <qblade@protonmail.com>
12 ;;; This file is part of GNU Guix.
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27 (define-module (gnu packages speech)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix utils)
33 #:use-module (guix build-system gnu)
34 #:use-module (gnu packages)
35 #:use-module (gnu packages audio)
36 #:use-module (gnu packages autotools)
37 #:use-module (gnu packages base) ;for 'which'
38 #:use-module (gnu packages bison)
39 #:use-module (gnu packages compression)
40 #:use-module (gnu packages documentation)
41 #:use-module (gnu packages emacs)
42 #:use-module (gnu packages gcc)
43 #:use-module (gnu packages glib)
44 #:use-module (gnu packages gstreamer)
45 #:use-module (gnu packages linux)
46 #:use-module (gnu packages ncurses)
47 #:use-module (gnu packages perl)
48 #:use-module (gnu packages pkg-config)
49 #:use-module (gnu packages pulseaudio)
50 #:use-module (gnu packages python)
51 #:use-module (gnu packages swig)
52 #:use-module (gnu packages texinfo)
53 #:use-module (gnu packages textutils))
63 (url "https://github.com/festvox/flite")
64 (commit (string-append "v" version))))
65 (file-name (git-file-name name version))
67 (base32 "1n0p81jzndzc1rzgm66kw9ls189ricy5v1ps11y0p2fk1p56kbjf"))))
68 (build-system gnu-build-system)
71 ;; There numerous issues with the testsuite.
72 ;; Enable all of them once they are fixed in upstream.
77 (string-append "LDFLAGS=-Wl,-rpath="
78 (assoc-ref %outputs "out")
81 (modify-phases %standard-phases
82 (add-after 'unpack 'patch-rpath
84 (substitute* "main/Makefile"
85 (("flite_LIBS_flags \\+= -Wl,-rpath [^ ]*")
86 "flite_LIBS_flags +="))
89 ;; Modifying testsuite/Makefile is not done in favor of
91 ;; The path not taken would be:
92 ;; 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
93 (add-after 'install 'check
95 (invoke "make" "-C" "testsuite")
96 (with-directory-excursion "testsuite"
97 (invoke "./token_test")
99 (invoke "./regex_test")
100 (invoke "./nums_test")
101 (invoke "./lex_test")
102 (invoke "./utt_test")
103 (invoke "./multi_thread"))
105 (add-after 'install 'remove-static-libs
106 (lambda* (#:key outputs #:allow-other-keys)
107 (let* ((out (assoc-ref outputs "out")))
108 (for-each delete-file
109 (find-files out "\\.a$"))
114 `(("alsa" ,alsa-lib)))
115 (synopsis "Speech synthesis system")
116 (description "Flite (festival-lite) is a small, fast run-time text to speech
117 synthesis engine developed at CMU and primarily designed for small embedded
118 machines and/or large servers. It is designed as an alternative text to speech
119 synthesis engine to Festival for voices built using the FestVox suite of voice
121 (home-page "http://www.festvox.org/flite/index.html")
122 (license (license:non-copyleft "file:///COPYING"))))
124 (define-public espeak
130 (uri (string-append "mirror://sourceforge/espeak/espeak/"
131 "espeak-" (version-major+minor version)
132 "/espeak-" version "-source.zip"))
135 "0n86gwh9pw0jqqpdz7mxggllfr8k0r7pc67ayy7w5z6z79kig6mz"))
136 (modules '((guix build utils)))
138 ;; remove prebuilt binaries
140 (delete-file-recursively "linux_32bit")
142 (build-system gnu-build-system)
144 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
145 (string-append "DATADIR="
146 (assoc-ref %outputs "out")
147 "/share/espeak-data")
148 (string-append "LDFLAGS=-Wl,-rpath="
149 (assoc-ref %outputs "out")
151 ;; The package fails to build with newer C++ standards.
152 "CXXFLAGS=-std=c++98"
154 #:tests? #f ; no check target
156 (modify-phases %standard-phases
160 ;; We use version 19 of the PortAudio library, so we must copy the
161 ;; corresponding file to be sure that espeak compiles correctly.
162 (copy-file "portaudio19.h" "portaudio.h")
163 (substitute* "Makefile"
167 `(("portaudio" ,portaudio)
168 ("pulseaudio" ,pulseaudio)))
169 (native-inputs `(("unzip" ,unzip)))
170 (home-page "http://espeak.sourceforge.net/")
171 (synopsis "Software speech synthesizer")
172 (description "eSpeak is a software speech synthesizer for English and
173 other languages. eSpeak uses a \"formant synthesis\" method. This allows many
174 languages to be provided in a small size. The speech is clear, and can be used
175 at high speeds, but is not as natural or smooth as larger synthesizers which are
176 based on human speech recordings.")
177 (license license:gpl3+)))
179 (define-public espeak-ng
183 (home-page "https://github.com/espeak-ng/espeak-ng")
184 ;; Note: eSpeak NG publishes release tarballs, but the 1.50 tarball is
185 ;; broken: <https://github.com/espeak-ng/espeak-ng/issues/683>.
186 ;; Download the raw repository to work around it; remove 'native-inputs'
187 ;; below when switching back to the release tarball.
190 (uri (git-reference (url home-page) (commit version)))
191 (file-name (git-file-name name version))
193 (base32 "0jkqhf2h94vbqq7mg7mmm23bq372fa7mdk941my18c3vkldcir1b"))))
194 (build-system gnu-build-system)
196 `(#:configure-flags '("--disable-static")
197 ;; Building in parallel triggers a race condition in 1.49.2.
199 ;; XXX: Some tests require an audio device.
202 `(("autoconf" ,autoconf)
203 ("automake" ,automake)
208 ("pcaudiolib" ,pcaudiolib)))
209 (synopsis "Software speech synthesizer")
211 "eSpeak NG is a software speech synthesizer for more than 100 languages.
212 It is based on the eSpeak engine and supports spectral and Klatt formant
213 synthesis, and the ability to use MBROLA voices.")
214 (license license:gpl3+)))
222 (uri (string-append "https://github.com/mitlm/mitlm/releases/"
223 "download/v" version "/"
224 name "-" version ".tar.xz"))
227 "09fv4fcpmw9g1j0zml0k5kk1lgjw2spr8gn51llbkaaph6v8d62a"))))
228 (build-system gnu-build-system)
230 `(("gfortran" ,gfortran)))
231 (synopsis "The MIT Language Modeling toolkit")
232 (description "The MIT Language Modeling (MITLM) toolkit is a set of
233 tools designed for the efficient estimation of statistical n-gram language
234 models involving iterative parameter estimation. It achieves much of its
235 efficiency through the use of a compact vector representation of n-grams.")
236 (home-page "https://github.com/mitlm/mitlm")
237 (license license:expat)))
239 (define-public speech-dispatcher
241 (name "speech-dispatcher")
245 (uri (string-append "https://github.com/brailcom/speechd/releases"
246 "/download/" version "/speech-dispatcher-"
250 "16bg52hnkrsrs7kgbzanb34b9zb6fqxwj0a9bmsxmj1skkil1h1p"))))
251 (build-system gnu-build-system)
253 `(#:configure-flags '("--disable-static"
255 ;; Disable support for proprietary TTS engines.
257 "--with-kali=no" "--with-baratinoo=no")))
259 `(("intltool" ,intltool)
260 ("pkg-config" ,pkg-config)))
262 `(("dotconf" ,dotconf)
263 ("espeak" ,espeak-ng)
266 ("libsndfile" ,libsndfile)
267 ("pulseaudio" ,pulseaudio)
269 (synopsis "Common interface to speech synthesizers")
270 (description "The Speech Dispatcher project provides a high-level
271 device independent layer for access to speech synthesis through a simple,
272 stable and well documented interface.")
273 (home-page "https://devel.freebsoft.org/speechd")
274 ;; The software is distributed under GPL2+, but includes a number
275 ;; of files covered by other licenses. Note: in practice, this
276 ;; is linked against dotconf, which is LGPL 2.1 only.
277 (license (list license:gpl2+
278 license:fdl1.2+ ; Most files in doc/ are dual gpl2+/fdl1.2+.
280 (license:non-copyleft
281 ;; festival_client.{c,h} carries an expat-style license.
282 "See src/modules/festival_client.c in the distribution.")
283 license:gpl3+)))) ; doc/texinfo.tex -- with TeX exception.
292 (url "https://github.com/waywardgeek/sonic")
293 (commit (string-append "release-" version))))
294 (file-name (git-file-name name version))
297 "08xwnpw9cnaix1n1i7gvpq5hrfrqc2z1snjhjapfam506hrc77g4"))))
298 (build-system gnu-build-system)
300 `(#:tests? #f ; no test suite
302 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
303 (string-append "LDFLAGS=-Wl,-rpath="
304 (assoc-ref %outputs "out") "/lib"))
306 (modify-phases %standard-phases
307 (add-after 'unpack 'respect-LDFLAGS
309 (substitute* "Makefile"
310 ((" -o sonic " match)
311 (string-append " $(LDFLAGS)" match)))
313 (delete 'configure)))) ; no ./configure script
314 (synopsis "Speed up or slow down speech")
315 (description "Sonic implements a simple algorithm for speeding up or slowing
316 down speech. However, it's optimized for speed ups of over 2X, unlike previous
317 algorithms for changing speech rate. Sonic is a C library designed to be easily
318 integrated into streaming voice applications such as text-to-speech (TTS) back
321 The primary motivation behind Sonic is to enable the blind and visually impaired
322 to improve their productivity with speech engines, like eSpeak. Sonic can also
323 be used by the sighted.")
324 (home-page "https://github.com/waywardgeek/sonic")
325 (license license:asl2.0)))
327 (define-public festival
333 (uri (string-append "http://festvox.org/packed/festival/"
334 (version-major+minor version)
335 "/festival-" version "-release.tar.gz"))
338 "1d5415nckiv19adxisxfm1l1xxfyw88g87ckkmcr0lhjdd10g42c"))))
339 (build-system gnu-build-system)
341 `(#:tests? #f ; there is no test target
343 (list (string-append "RM="
344 (assoc-ref %build-inputs "coreutils")
346 (string-append "ECHO_N="
347 (assoc-ref %build-inputs "coreutils")
348 "/bin/printf \"%s\""))
349 #:parallel-build? #f ; not supported
350 #:modules ((guix build gnu-build-system)
352 (guix build emacs-utils))
353 #:imported-modules (,@%gnu-build-system-modules
354 (guix build emacs-utils))
356 (modify-phases %standard-phases
357 (add-after 'unpack 'unpack-and-patch-speech-tools
358 (lambda* (#:key inputs #:allow-other-keys)
359 (invoke "tar" "-C" ".."
360 "-xf" (assoc-ref inputs "speech-tools"))
361 (with-directory-excursion "../speech_tools"
362 (substitute* '("config/rules/modules.mak"
363 "config/rules/test_make_rules.mak"
364 "config/make_system.mak")
365 (("/bin/sh") (which "sh"))))
367 (add-after 'unpack 'patch-/bin/sh
369 (substitute* '("config/test_make_rules"
370 "config/make_system.mak")
371 (("/bin/sh") (which "sh")))
373 (add-before 'build 'build-speech-tools
374 (lambda* (#:key configure-flags make-flags #:allow-other-keys)
375 (with-directory-excursion "../speech_tools"
376 (apply invoke "sh" "configure"
377 (string-append "CONFIG_SHELL=" (which "sh"))
378 (string-append "SHELL=" (which "sh"))
380 (apply invoke "make" make-flags))))
381 (add-after 'build 'build-documentation
383 (with-directory-excursion "doc"
384 (invoke "make" "festival.info"))))
385 (add-after 'unpack 'set-installation-directories
386 (lambda* (#:key outputs #:allow-other-keys)
387 (let ((out (assoc-ref outputs "out")))
388 (substitute* "config/project.mak"
390 (string-append "FTLIBDIR=" out "/share/festival/lib")))
391 (substitute* "config/systems/default.mak"
392 (("^INSTALL_PREFIX.*")
393 (string-append "INSTALL_PREFIX=" out)))
395 (add-after 'install 'actually-install
396 (lambda* (#:key inputs outputs #:allow-other-keys)
397 (let ((out (assoc-ref outputs "out")))
398 ;; Install Speech Tools first
399 (with-directory-excursion "../speech_tools"
400 ;; Target directories
401 (for-each (lambda (dir)
402 (mkdir-p (string-append out dir)))
405 "/include/speech_tools/"
406 "/include/speech_tools/instantiate"
407 "/include/speech_tools/ling_class"
408 "/include/speech_tools/rxp"
409 "/include/speech_tools/sigpr"
410 "/include/speech_tools/unix"))
412 (for-each (lambda (file)
413 (install-file file (string-append out "/bin")))
414 (find-files "bin" ".*"))
415 (for-each (lambda (file)
416 (delete-file (string-append out "/bin/" file)))
417 '("est_gdb" "est_examples" "est_program"))
419 (for-each (lambda (file)
420 (install-file file (string-append out "/lib")))
421 (find-files "lib" "lib.*\\.so.*"))
429 (string-append out "/include/speech_tools/" dir)))
430 (find-files (string-append "include/" dir)
432 '("." "instantiate" "ling_class" "rxp" "sigpr" "unix")))
434 ;; Unpack files that will be installed together with the
435 ;; Festival libraries.
436 (invoke "tar" "--strip-components=1"
437 "-xvf" (assoc-ref inputs "festvox-cmu"))
438 (invoke "tar" "--strip-components=1"
439 "-xvf" (assoc-ref inputs "festvox-poslex"))
440 (invoke "tar" "--strip-components=1"
441 "-xvf" (assoc-ref inputs "default-voice"))
444 (let ((bin (string-append out "/bin"))
445 (incdir (string-append out "/include/festival"))
446 (share (string-append out "/share/festival"))
447 (info (string-append out "/share/info")))
448 (for-each (lambda (executable)
449 (install-file executable bin))
450 '("src/main/festival"
451 "src/main/festival_client"
452 "examples/benchmark"))
453 (let ((scripts '("examples/dumpfeats"
454 "examples/durmeanstd"
457 "examples/powmeanstd"
458 "examples/run-festival-script"
460 "examples/scfg_parse_text"
462 "examples/text2wave")))
464 (("exec /tmp/guix-build.*/bin/festival")
465 (string-append "exec " bin "/festival")))
466 (for-each (lambda (script)
467 (install-file script bin))
471 (for-each (lambda (file)
472 (install-file file info))
473 (find-files "doc/info/" "festival.info.*"))
477 (for-each (lambda (header)
479 (string-append incdir "/"
481 (find-files "src/include" "\\.h$"))
485 (for-each (lambda (file)
487 (string-append share "/"
489 (find-files "lib" ".*"))
490 (for-each delete-file
491 (append (find-files share "Makefile")
492 (find-files bin "Makefile")))))
494 (add-after 'actually-install 'install-emacs-mode
495 (lambda* (#:key outputs #:allow-other-keys)
496 (let ((emacs-dir (string-append (assoc-ref outputs "out")
497 "/share/emacs/site-lisp")))
498 (install-file "lib/festival.el" emacs-dir)
499 (emacs-generate-autoloads ,name emacs-dir)
501 ;; Rebuild the very old configure script that is confused by extra
503 (add-before 'configure 'bootstrap
504 (lambda _ (invoke "autoreconf" "-vif"))))))
506 `(("ncurses" ,ncurses)))
508 `(("autoconf" ,autoconf)
509 ("automake" ,automake)
511 ("emacs" ,emacs-minimal)
515 (uri (string-append "http://festvox.org/packed/festival/"
516 (version-major+minor version)
517 "/festlex_CMU.tar.gz"))
520 "01vwidqhhg2zifvk1gby91mckg1z2pv2mj6lihvdaifakf8k1561"))))
524 (uri (string-append "http://festvox.org/packed/festival/"
525 (version-major+minor version)
526 "/festlex_POSLEX.tar.gz"))
529 "18wywilxaqwy63lc47p5g5529mpxhslibh1bjij0snxx5mjf7ip7"))))
533 (uri (string-append "http://festvox.org/packed/festival/"
534 (version-major+minor version)
535 "/voices/festvox_kallpc16k.tar.gz"))
538 "136hmsyiwnlg2qwa508dy0imf19mzrb5r3dmb2kg8kcyxnslm740"))))
542 (uri (string-append "http://festvox.org/packed/festival/"
543 (version-major+minor version)
544 "/speech_tools-" version "-release.tar.gz"))
547 "1k2xh13miyv48gh06rgsq2vj25xwj7z6vwq9ilsn8i7ig3nrgzg4"))))))
548 (home-page "https://www.cstr.ed.ac.uk/projects/festival/")
549 (synopsis "Speech synthesis system")
550 (description "Festival offers a general framework for building speech
551 synthesis systems as well as including examples of various modules. As a
552 whole it offers full text to speech through a number APIs: from shell level,
553 though a Scheme command interpreter, as a C++ library, from Java, and an Emacs
554 interface. Festival is multi-lingual though English is the most advanced.
555 The system is written in C++ and uses the Edinburgh Speech Tools Library for
556 low level architecture and has a Scheme (SIOD) based command interpreter for
558 (license (license:non-copyleft "file://COPYING"))))
568 (string-append "mirror://sourceforge/e-guidedog/Ekho/"
569 version "/ekho-" version ".tar.xz"))
571 (base32 "1v476kpw09ljj8mavasj4hya2w11jwlx7q22rh1lsn9jkkam5i2a"))))
573 `(("pkg-config" ,pkg-config)))
575 `(("alsa-lib" ,alsa-lib)
576 ("espeak-ng" ,espeak-ng)
577 ("libsndfile" ,libsndfile)
578 ("pulseaudio" ,pulseaudio)))
579 (build-system gnu-build-system)
581 (list (search-path-specification
582 (variable "EKHO_DATA_PATH")
583 (files '("share/ekho-data")))))
584 (home-page "https://eguidedog.net/ekho.php")
585 (synopsis "Chinese text-to-speech software")
587 "Ehko is a Text-To-Speech (TTS) software. It supports Cantonese,
588 Mandarin, Toisanese, Zhaoan Hakka, Tibetan, Ngangien and Korean (in trial).
589 It can also speak English through eSpeak or Festival.")
590 (license (list license:gpl2+
594 (define-public sphinxbase
597 (version "5prealpha")
601 (uri (string-append "mirror://sourceforge/cmusphinx/"
602 "sphinxbase/" version "/"
603 "sphinxbase-" version ".tar.gz"))
605 (base32 "0vr4k8pv5a8nvq9yja7kl13b5lh0f9vha8fc8znqnm8bwmcxnazp"))
606 (patches (search-patches "sphinxbase-fix-doxygen.patch"))))
607 (build-system gnu-build-system)
609 `(#:parallel-tests? #f)) ;tests fail otherwise
613 ("perl" ,perl) ;for tests
617 `(("pulseaudio" ,pulseaudio)))
618 (home-page "https://cmusphinx.github.io/")
619 (synopsis "Support library required by Pocketsphinx and Sphinxtrain")
620 (description "This package contains the basic libraries shared by
621 the CMU Sphinx trainer and all the Sphinx decoders (Sphinx-II,
622 Sphinx-III, and PocketSphinx), as well as some common utilities for
623 manipulating acoustic feature and audio files.")
624 (license license:bsd-4)))
626 (define-public pocketsphinx
628 (name "pocketsphinx")
629 (version "5prealpha")
633 (uri (string-append "mirror://sourceforge/cmusphinx/"
634 "pocketsphinx/" version "/"
635 "pocketsphinx-" version ".tar.gz"))
637 (base32 "1n9yazzdgvpqgnfzsbl96ch9cirayh74jmpjf7svs4i7grabanzg"))))
638 (build-system gnu-build-system)
640 `(("pkg-config" ,pkg-config)
641 ("perl" ,perl) ;for tests
645 `(("gstreamer" ,gstreamer)
647 ("pulseaudio" ,pulseaudio)
648 ("sphinxbase" ,sphinxbase)))
649 (home-page "https://cmusphinx.github.io/")
650 (synopsis "Recognizer library written in C")
651 (description "PocketSphinx is one of Carnegie Mellon University's
652 large vocabulary, speaker-independent continuous speech recognition
654 (license license:bsd-2)))