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>
9 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
52 (uri (string-append "mirror://sourceforge/espeak/espeak/"
53 "espeak-" (version-major+minor version)
54 "/espeak-" version "-source.zip"))
57 "0n86gwh9pw0jqqpdz7mxggllfr8k0r7pc67ayy7w5z6z79kig6mz"))
58 (modules '((guix build utils)))
60 ;; remove prebuilt binaries
62 (delete-file-recursively "linux_32bit")
64 (build-system gnu-build-system)
66 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
67 (string-append "DATADIR="
68 (assoc-ref %outputs "out")
70 (string-append "LDFLAGS=-Wl,-rpath="
71 (assoc-ref %outputs "out")
73 ;; The package fails to build with newer C++ standards.
76 #:tests? #f ; no check target
78 (modify-phases %standard-phases
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"
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+)))
101 (define-public espeak-ng
105 (home-page "https://github.com/espeak-ng/espeak-ng")
108 (uri (string-append home-page "/releases/download/" version
109 "/espeak-ng-" version ".tar.gz"))
111 (base32 "1d10x9rbvqi2zwcz65fxh04k0x0scnk7732l37laz6xra1ldhzng"))))
112 (build-system gnu-build-system)
114 `(#:configure-flags '("--disable-static")
115 ;; Building in parallel triggers a race condition in 1.49.2.
117 ;; XXX: Some tests require an audio device.
121 ("pcaudiolib" ,pcaudiolib)))
122 (synopsis "Software speech synthesizer")
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+)))
135 (uri (string-append "https://github.com/mitlm/mitlm/releases/"
136 "download/v" version "/"
137 name "-" version ".tar.xz"))
140 "09fv4fcpmw9g1j0zml0k5kk1lgjw2spr8gn51llbkaaph6v8d62a"))))
141 (build-system gnu-build-system)
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)))
152 (define-public speech-dispatcher
154 (name "speech-dispatcher")
158 (uri (string-append "https://github.com/brailcom/speechd/releases"
159 "/download/" version "/speech-dispatcher-"
163 "16bg52hnkrsrs7kgbzanb34b9zb6fqxwj0a9bmsxmj1skkil1h1p"))))
164 (build-system gnu-build-system)
166 `(#:configure-flags '("--disable-static"
168 ;; Disable support for proprietary TTS engines.
170 "--with-kali=no" "--with-baratinoo=no")))
172 `(("intltool" ,intltool)
173 ("pkg-config" ,pkg-config)))
175 `(("dotconf" ,dotconf)
176 ("espeak" ,espeak-ng)
179 ("libsndfile" ,libsndfile)
180 ("pulseaudio" ,pulseaudio)
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+.
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.
205 (url "https://github.com/waywardgeek/sonic")
206 (commit (string-append "release-" version))))
207 (file-name (git-file-name name version))
210 "08xwnpw9cnaix1n1i7gvpq5hrfrqc2z1snjhjapfam506hrc77g4"))))
211 (build-system gnu-build-system)
213 `(#:tests? #f ; No test suite.
215 (list (string-append "DESTDIR=" (assoc-ref %outputs "out")))
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
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)))
232 (define-public festival
238 (uri (string-append "http://festvox.org/packed/festival/"
239 (version-major+minor version)
240 "/festival-" version "-release.tar.gz"))
243 "1d5415nckiv19adxisxfm1l1xxfyw88g87ckkmcr0lhjdd10g42c"))))
244 (build-system gnu-build-system)
246 `(#:tests? #f ; there is no test target
248 (list (string-append "RM="
249 (assoc-ref %build-inputs "coreutils")
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)
257 (guix build emacs-utils))
258 #:imported-modules (,@%gnu-build-system-modules
259 (guix build emacs-utils))
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"))))
272 (add-after 'unpack 'patch-/bin/sh
274 (substitute* '("config/test_make_rules"
275 "config/make_system.mak")
276 (("/bin/sh") (which "sh")))
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"))
285 (apply invoke "make" make-flags))))
286 (add-after 'build 'build-documentation
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"
295 (string-append "FTLIBDIR=" out "/share/festival/lib")))
296 (substitute* "config/systems/default.mak"
297 (("^INSTALL_PREFIX.*")
298 (string-append "INSTALL_PREFIX=" out)))
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)))
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"))
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"))
324 (for-each (lambda (file)
325 (install-file file (string-append out "/lib")))
326 (find-files "lib" "lib.*\\.so.*"))
334 (string-append out "/include/speech_tools/" dir)))
335 (find-files (string-append "include/" dir)
337 '("." "instantiate" "ling_class" "rxp" "sigpr" "unix")))
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"))
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"
362 "examples/powmeanstd"
363 "examples/run-festival-script"
365 "examples/scfg_parse_text"
367 "examples/text2wave")))
369 (("exec /tmp/guix-build.*/bin/festival")
370 (string-append "exec " bin "/festival")))
371 (for-each (lambda (script)
372 (install-file script bin))
376 (for-each (lambda (file)
377 (install-file file info))
378 (find-files "doc/info/" "festival.info.*"))
382 (for-each (lambda (header)
384 (string-append incdir "/"
386 (find-files "src/include" "\\.h$"))
390 (for-each (lambda (file)
392 (string-append share "/"
394 (find-files "lib" ".*"))
395 (for-each delete-file
396 (append (find-files share "Makefile")
397 (find-files bin "Makefile")))))
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)
406 ;; Rebuild the very old configure script that is confused by extra
408 (add-before 'configure 'bootstrap
409 (lambda _ (invoke "autoreconf" "-vif"))))))
411 `(("ncurses" ,ncurses)))
413 `(("autoconf" ,autoconf)
414 ("automake" ,automake)
416 ("emacs" ,emacs-minimal)
420 (uri (string-append "http://festvox.org/packed/festival/"
421 (version-major+minor version)
422 "/festlex_CMU.tar.gz"))
425 "01vwidqhhg2zifvk1gby91mckg1z2pv2mj6lihvdaifakf8k1561"))))
429 (uri (string-append "http://festvox.org/packed/festival/"
430 (version-major+minor version)
431 "/festlex_POSLEX.tar.gz"))
434 "18wywilxaqwy63lc47p5g5529mpxhslibh1bjij0snxx5mjf7ip7"))))
438 (uri (string-append "http://festvox.org/packed/festival/"
439 (version-major+minor version)
440 "/voices/festvox_kallpc16k.tar.gz"))
443 "136hmsyiwnlg2qwa508dy0imf19mzrb5r3dmb2kg8kcyxnslm740"))))
447 (uri (string-append "http://festvox.org/packed/festival/"
448 (version-major+minor version)
449 "/speech_tools-" version "-release.tar.gz"))
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
463 (license (license:non-copyleft "file://COPYING"))))