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