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–2022 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; Copyright © 2016 Kei Kebreau <kkebreau@posteo.net>
7 ;;; Copyright © 2019, 2021 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 gettext)
44 #:use-module (gnu packages glib)
45 #:use-module (gnu packages gstreamer)
46 #:use-module (gnu packages linux)
47 #:use-module (gnu packages ncurses)
48 #:use-module (gnu packages perl)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages pulseaudio)
51 #:use-module (gnu packages python)
52 #:use-module (gnu packages swig)
53 #:use-module (gnu packages texinfo)
54 #:use-module (gnu packages textutils))
64 (url "https://github.com/festvox/flite")
65 (commit (string-append "v" version))))
66 (file-name (git-file-name name version))
68 (base32 "1n0p81jzndzc1rzgm66kw9ls189ricy5v1ps11y0p2fk1p56kbjf"))))
69 (build-system gnu-build-system)
72 ;; There numerous issues with the testsuite.
73 ;; Enable all of them once they are fixed in upstream.
78 (string-append "LDFLAGS=-Wl,-rpath="
79 (assoc-ref %outputs "out")
82 (modify-phases %standard-phases
83 (add-after 'unpack 'patch-rpath
85 (substitute* "main/Makefile"
86 (("flite_LIBS_flags \\+= -Wl,-rpath [^ ]*")
87 "flite_LIBS_flags +="))
90 ;; Modifying testsuite/Makefile is not done in favor of
92 ;; The path not taken would be:
93 ;; 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
94 (add-after 'install 'check
96 (invoke "make" "-C" "testsuite")
97 (with-directory-excursion "testsuite"
98 (invoke "./token_test")
100 (invoke "./regex_test")
101 (invoke "./nums_test")
102 (invoke "./lex_test")
103 (invoke "./utt_test")
104 (invoke "./multi_thread"))
106 (add-after 'install 'remove-static-libs
107 (lambda* (#:key outputs #:allow-other-keys)
108 (let* ((out (assoc-ref outputs "out")))
109 (for-each delete-file
110 (find-files out "\\.a$"))
115 `(("alsa" ,alsa-lib)))
116 (synopsis "Speech synthesis system")
117 (description "Flite (festival-lite) is a small, fast run-time text to speech
118 synthesis engine developed at CMU and primarily designed for small embedded
119 machines and/or large servers. It is designed as an alternative text to speech
120 synthesis engine to Festival for voices built using the FestVox suite of voice
122 (home-page "http://www.festvox.org/flite/index.html")
123 (license (license:non-copyleft "file:///COPYING"))))
125 (define-public espeak
131 (uri (string-append "mirror://sourceforge/espeak/espeak/"
132 "espeak-" (version-major+minor version)
133 "/espeak-" version "-source.zip"))
136 "0n86gwh9pw0jqqpdz7mxggllfr8k0r7pc67ayy7w5z6z79kig6mz"))
137 (modules '((guix build utils)))
139 ;; remove prebuilt binaries
141 (delete-file-recursively "linux_32bit")
143 (build-system gnu-build-system)
145 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
146 (string-append "DATADIR="
147 (assoc-ref %outputs "out")
148 "/share/espeak-data")
149 (string-append "LDFLAGS=-Wl,-rpath="
150 (assoc-ref %outputs "out")
152 ;; The package fails to build with newer C++ standards.
153 "CXXFLAGS=-std=c++98"
155 #:tests? #f ; no check target
157 (modify-phases %standard-phases
161 ;; We use version 19 of the PortAudio library, so we must copy the
162 ;; corresponding file to be sure that espeak compiles correctly.
163 (copy-file "portaudio19.h" "portaudio.h")
164 (substitute* "Makefile"
166 (("\\$\\(INSTALL\\).*\\$\\(STATIC_LIB.*") "")))))))
168 (list portaudio pulseaudio))
169 (native-inputs (list 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
187 (url "https://github.com/espeak-ng/espeak-ng")
189 (file-name (git-file-name name version))
191 (base32 "0xhgdmvpgi464x9ba586c6hvscfkbhry75cv796hl9pz1nawq31b"))))
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 (list autoconf automake libtool which))
202 (list libcap pcaudiolib))
203 (home-page "https://github.com/espeak-ng/espeak-ng")
204 (synopsis "Software speech synthesizer")
206 "eSpeak NG is a software speech synthesizer for more than 100 languages.
207 It is based on the eSpeak engine and supports spectral and Klatt formant
208 synthesis, and the ability to use MBROLA voices.")
209 (license license:gpl3+)))
217 (uri (string-append "https://github.com/mitlm/mitlm/releases/"
218 "download/v" version "/"
219 name "-" version ".tar.xz"))
222 "09fv4fcpmw9g1j0zml0k5kk1lgjw2spr8gn51llbkaaph6v8d62a"))))
223 (build-system gnu-build-system)
226 (synopsis "The MIT Language Modeling toolkit")
227 (description "The MIT Language Modeling (MITLM) toolkit is a set of
228 tools designed for the efficient estimation of statistical n-gram language
229 models involving iterative parameter estimation. It achieves much of its
230 efficiency through the use of a compact vector representation of n-grams.")
231 (home-page "https://github.com/mitlm/mitlm")
232 (license license:expat)))
234 (define-public speech-dispatcher
236 (name "speech-dispatcher")
240 (uri (string-append "https://github.com/brailcom/speechd/releases"
241 "/download/" version "/speech-dispatcher-"
245 "1inxqabbml2vhp0lvx4khhda4g1dp8wyr8mnk4vz315c7pni5nni"))))
246 (build-system gnu-build-system)
248 `(#:configure-flags '("--disable-static"
250 ;; Disable support for proprietary TTS engines.
251 "--with-voxin=no" "--with-ibmtts=no"
252 "--with-kali=no" "--with-baratinoo=no")))
254 (list gettext-minimal pkg-config texinfo))
263 (synopsis "Common interface to speech synthesizers")
264 (description "The Speech Dispatcher project provides a high-level
265 device independent layer for access to speech synthesis through a simple,
266 stable and well documented interface.")
267 (home-page "https://devel.freebsoft.org/speechd")
268 ;; The software is distributed under GPL2+, but includes a number
269 ;; of files covered by other licenses. Note: in practice, this
270 ;; is linked against dotconf, which is LGPL 2.1 only.
271 (license (list license:gpl2+
272 license:fdl1.2+ ; Most files in doc/ are dual gpl2+/fdl1.2+.
274 (license:non-copyleft
275 ;; festival_client.{c,h} carries an expat-style license.
276 "See src/modules/festival_client.c in the distribution.")
277 license:gpl3+)))) ; doc/texinfo.tex -- with TeX exception.
286 (url "https://github.com/waywardgeek/sonic")
287 (commit (string-append "release-" version))))
288 (file-name (git-file-name name version))
291 "08xwnpw9cnaix1n1i7gvpq5hrfrqc2z1snjhjapfam506hrc77g4"))))
292 (build-system gnu-build-system)
294 `(#:tests? #f ; no test suite
296 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
297 (string-append "LDFLAGS=-Wl,-rpath="
298 (assoc-ref %outputs "out") "/lib"))
300 (modify-phases %standard-phases
301 (add-after 'unpack 'respect-LDFLAGS
303 (substitute* "Makefile"
304 ((" -o sonic " match)
305 (string-append " $(LDFLAGS)" match)))
307 (delete 'configure)))) ; no ./configure script
308 (synopsis "Speed up or slow down speech")
309 (description "Sonic implements a simple algorithm for speeding up or slowing
310 down speech. However, it's optimized for speed ups of over 2X, unlike previous
311 algorithms for changing speech rate. Sonic is a C library designed to be easily
312 integrated into streaming voice applications such as text-to-speech (TTS) back
315 The primary motivation behind Sonic is to enable the blind and visually impaired
316 to improve their productivity with speech engines, like eSpeak. Sonic can also
317 be used by the sighted.")
318 (home-page "https://github.com/waywardgeek/sonic")
319 (license license:asl2.0)))
321 (define-public festival
327 (uri (string-append "http://festvox.org/packed/festival/"
328 (version-major+minor version)
329 "/festival-" version "-release.tar.gz"))
332 "1d5415nckiv19adxisxfm1l1xxfyw88g87ckkmcr0lhjdd10g42c"))))
333 (build-system gnu-build-system)
335 `(#:tests? #f ; there is no test target
337 (list (string-append "RM="
338 (assoc-ref %build-inputs "coreutils")
340 (string-append "ECHO_N="
341 (assoc-ref %build-inputs "coreutils")
342 "/bin/printf \"%s\"")
344 #:parallel-build? #f ; not supported
345 #:modules ((guix build gnu-build-system)
347 (guix build emacs-utils))
348 #:imported-modules (,@%gnu-build-system-modules
349 (guix build emacs-utils))
351 (modify-phases %standard-phases
352 (add-after 'unpack 'unpack-and-patch-speech-tools
353 (lambda* (#:key inputs #:allow-other-keys)
354 (invoke "tar" "-C" ".."
355 "-xf" (assoc-ref inputs "speech-tools"))
356 (with-directory-excursion "../speech_tools"
357 (substitute* '("config/rules/modules.mak"
358 "config/rules/test_make_rules.mak"
359 "config/make_system.mak")
360 (("/bin/sh") (which "sh"))))
362 (add-after 'unpack-and-patch-speech-tools 'set-fcommon
364 (substitute* "../speech_tools/config/rules/defaults.mak"
365 (("\\(CFLAGS\\)") "(CFLAGS) -fcommon")
366 (("\\(CXXFLAGS\\)") "(CXXFLAGS) -fcommon"))))
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"))))))
509 `(("autoconf" ,autoconf)
510 ("automake" ,automake)
512 ("emacs" ,emacs-minimal)
516 (uri (string-append "http://festvox.org/packed/festival/"
517 (version-major+minor version)
518 "/festlex_CMU.tar.gz"))
521 "01vwidqhhg2zifvk1gby91mckg1z2pv2mj6lihvdaifakf8k1561"))))
525 (uri (string-append "http://festvox.org/packed/festival/"
526 (version-major+minor version)
527 "/festlex_POSLEX.tar.gz"))
530 "18wywilxaqwy63lc47p5g5529mpxhslibh1bjij0snxx5mjf7ip7"))))
534 (uri (string-append "http://festvox.org/packed/festival/"
535 (version-major+minor version)
536 "/voices/festvox_kallpc16k.tar.gz"))
539 "136hmsyiwnlg2qwa508dy0imf19mzrb5r3dmb2kg8kcyxnslm740"))))
543 (uri (string-append "http://festvox.org/packed/festival/"
544 (version-major+minor version)
545 "/speech_tools-" version "-release.tar.gz"))
548 "1k2xh13miyv48gh06rgsq2vj25xwj7z6vwq9ilsn8i7ig3nrgzg4"))))))
549 (home-page "https://www.cstr.ed.ac.uk/projects/festival/")
550 (synopsis "Speech synthesis system")
551 (description "Festival offers a general framework for building speech
552 synthesis systems as well as including examples of various modules. As a
553 whole it offers full text to speech through a number APIs: from shell level,
554 though a Scheme command interpreter, as a C++ library, from Java, and an Emacs
555 interface. Festival is multi-lingual though English is the most advanced.
556 The system is written in C++ and uses the Edinburgh Speech Tools Library for
557 low level architecture and has a Scheme (SIOD) based command interpreter for
559 (license (license:non-copyleft "file://COPYING"))))
569 (string-append "mirror://sourceforge/e-guidedog/Ekho/"
570 version "/ekho-" version ".tar.xz"))
572 (base32 "1v476kpw09ljj8mavasj4hya2w11jwlx7q22rh1lsn9jkkam5i2a"))))
576 (list alsa-lib espeak-ng libsndfile pulseaudio))
577 (build-system gnu-build-system)
579 (list (search-path-specification
580 (variable "EKHO_DATA_PATH")
581 (files '("share/ekho-data")))))
582 (home-page "https://eguidedog.net/ekho.php")
583 (synopsis "Chinese text-to-speech software")
585 "Ehko is a Text-To-Speech (TTS) software. It supports Cantonese,
586 Mandarin, Toisanese, Zhaoan Hakka, Tibetan, Ngangien and Korean (in trial).
587 It can also speak English through eSpeak or Festival.")
588 (license (list license:gpl2+
592 (define-public sphinxbase
595 (version "5prealpha")
599 (uri (string-append "mirror://sourceforge/cmusphinx/"
600 "sphinxbase/" version "/"
601 "sphinxbase-" version ".tar.gz"))
603 (base32 "0vr4k8pv5a8nvq9yja7kl13b5lh0f9vha8fc8znqnm8bwmcxnazp"))
604 (patches (search-patches "sphinxbase-fix-doxygen.patch"))))
605 (build-system gnu-build-system)
607 `(#:parallel-tests? #f)) ;tests fail otherwise
616 (home-page "https://cmusphinx.github.io/")
617 (synopsis "Support library required by Pocketsphinx and Sphinxtrain")
618 (description "This package contains the basic libraries shared by
619 the CMU Sphinx trainer and all the Sphinx decoders (Sphinx-II,
620 Sphinx-III, and PocketSphinx), as well as some common utilities for
621 manipulating acoustic feature and audio files.")
622 (license license:bsd-4)))
624 (define-public pocketsphinx
626 (name "pocketsphinx")
627 (version "5prealpha")
631 (uri (string-append "mirror://sourceforge/cmusphinx/"
632 "pocketsphinx/" version "/"
633 "pocketsphinx-" version ".tar.gz"))
635 (base32 "1n9yazzdgvpqgnfzsbl96ch9cirayh74jmpjf7svs4i7grabanzg"))))
636 (build-system gnu-build-system)
638 (list pkg-config perl ;for tests
641 (list gstreamer libcap pulseaudio sphinxbase))
642 (home-page "https://cmusphinx.github.io/")
643 (synopsis "Recognizer library written in C")
644 (description "PocketSphinx is one of Carnegie Mellon University's
645 large vocabulary, speaker-independent continuous speech recognition
647 (license license:bsd-2)))