projects/guix·blob java-team · refs

1128 lines · 46.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 David Thompson <[email protected]>
3;;; Copyright © 2016, 2019, 2020 Marius Bakke <[email protected]>
4;;; Copyright © 2017 Leo Famulari <[email protected]>
5;;; Copyright © 2018, 2020–2022 Tobias Geerinckx-Rice <[email protected]>
6;;; Copyright © 2016 Kei Kebreau <[email protected]>
7;;; Copyright © 2019, 2021, 2022, 2023 Ricardo Wurmus <[email protected]>
8;;; Copyright © 2020, 2025 Nicolas Goaziou <[email protected]>
9;;; Copyright © 2020 Efraim Flashner <[email protected]>
10;;; Copyright © 2021 qblade <[email protected]>
11;;; Copyright © 2024 Sébastien Lerique <[email protected]>
12;;; Copyright © 2026 Anderson Torres <[email protected]>
13;;;
14;;; This file is part of GNU Guix.
15;;;
16;;; GNU Guix is free software; you can redistribute it and/or modify it
17;;; under the terms of the GNU General Public License as published by
18;;; the Free Software Foundation; either version 3 of the License, or (at
19;;; your option) any later version.
20;;;
21;;; GNU Guix is distributed in the hope that it will be useful, but
22;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;;; GNU General Public License for more details.
25;;;
26;;; You should have received a copy of the GNU General Public License
27;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29(define-module (gnu packages speech)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix gexp)
34 #:use-module (guix git-download)
35 #:use-module (guix utils)
36 #:use-module (guix build-system cmake)
37 #:use-module (guix build-system gnu)
38 #:use-module (guix build-system meson)
39 #:use-module (guix build-system pyproject)
40 #:use-module (gnu packages)
41 #:use-module (gnu packages audio)
42 #:use-module (gnu packages autotools)
43 #:use-module (gnu packages bash)
44 #:use-module (gnu packages base) ;for 'which'
45 #:use-module (gnu packages bison)
46 #:use-module (gnu packages build-tools)
47 #:use-module (gnu packages nss)
48 #:use-module (gnu packages compression)
49 #:use-module (gnu packages documentation)
50 #:use-module (gnu packages emacs)
51 #:use-module (gnu packages freedesktop)
52 #:use-module (gnu packages gcc)
53 #:use-module (gnu packages gettext)
54 #:use-module (gnu packages glib)
55 #:use-module (gnu packages gstreamer)
56 #:use-module (gnu packages linux)
57 #:use-module (gnu packages machine-learning)
58 #:use-module (gnu packages mp3)
59 #:use-module (gnu packages ncurses)
60 #:use-module (gnu packages perl)
61 #:use-module (gnu packages pkg-config)
62 #:use-module (gnu packages pulseaudio)
63 #:use-module (gnu packages python)
64 #:use-module (gnu packages python-build)
65 #:use-module (gnu packages python-science)
66 #:use-module (gnu packages python-web)
67 #:use-module (gnu packages python-xyz)
68 #:use-module (gnu packages python-check)
69 #:use-module (gnu packages check)
70 #:use-module (gnu packages swig)
71 #:use-module (gnu packages texinfo)
72 #:use-module (gnu packages textutils)
73 #:use-module (gnu packages version-control)
74 #:use-module (gnu packages video))
75
76(define-public flite
77 (package
78 (name "flite")
79 (version "2.2")
80 (source
81 (origin
82 (method git-fetch)
83 (uri (git-reference
84 (url "https://github.com/festvox/flite")
85 (commit (string-append "v" version))))
86 (file-name (git-file-name name version))
87 (sha256
88 (base32 "1n0p81jzndzc1rzgm66kw9ls189ricy5v1ps11y0p2fk1p56kbjf"))))
89 (build-system gnu-build-system)
90 (arguments
91 ;; XXX:
92 ;; There numerous issues with the testsuite.
93 ;; Enable all of them once they are fixed in upstream.
94 (list
95 #:tests? #f
96 #:parallel-build? #f
97 #:configure-flags
98 #~(list "--enable-shared"
99 (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib"))
100 #:phases
101 #~(modify-phases %standard-phases
102 (add-after 'unpack 'patch-rpath
103 (lambda _
104 (substitute* "main/Makefile"
105 (("flite_LIBS_flags \\+= -Wl,-rpath [^ ]*")
106 "flite_LIBS_flags +="))))
107 (delete 'check)
108 ;; Modifying testsuite/Makefile is not done in favor of
109 ;; overriding 'check.
110 ;; The path not taken would be:
111 ;; 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
112 (add-after 'install 'check
113 (lambda _
114 (invoke "make" "-C" "testsuite")
115 (with-directory-excursion "testsuite"
116 (invoke "./token_test")
117 (invoke "./hrg_test")
118 (invoke "./regex_test")
119 (invoke "./nums_test")
120 (invoke "./lex_test")
121 (invoke "./utt_test")
122 (invoke "./multi_thread"))))
123 (add-after 'install 'remove-static-libs
124 (lambda _
125 (for-each delete-file
126 (find-files #$output "\\.a$")))))))
127 (native-inputs
128 (list perl))
129 (inputs
130 (list alsa-lib))
131 (synopsis "Speech synthesis system")
132 (description "Flite (festival-lite) is a small, fast run-time text to speech
133synthesis engine developed at CMU and primarily designed for small embedded
134machines and/or large servers. It is designed as an alternative text to speech
135synthesis engine to Festival for voices built using the FestVox suite of voice
136building tools.")
137 (home-page "http://www.festvox.org/flite/index.html")
138 (license (license:non-copyleft "file:///COPYING"))))
139
140(define-public espeak
141 (package
142 (name "espeak")
143 (version "1.48.04")
144 (source (origin
145 (method url-fetch)
146 (uri (string-append "mirror://sourceforge/espeak/espeak/"
147 "espeak-" (version-major+minor version)
148 "/espeak-" version "-source.zip"))
149 (sha256
150 (base32
151 "0n86gwh9pw0jqqpdz7mxggllfr8k0r7pc67ayy7w5z6z79kig6mz"))
152 (modules '((guix build utils)))
153 (snippet
154 ;; remove prebuilt binaries
155 '(begin
156 (delete-file-recursively "linux_32bit")
157 #t))))
158 (build-system gnu-build-system)
159 (arguments
160 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
161 (string-append "DATADIR="
162 (assoc-ref %outputs "out")
163 "/share/espeak-data")
164 (string-append "LDFLAGS=-Wl,-rpath="
165 (assoc-ref %outputs "out")
166 "/lib")
167 ;; The package fails to build with newer C++ standards.
168 "CXXFLAGS=-std=c++98"
169 "AUDIO=pulseaudio")
170 #:tests? #f ; no check target
171 #:phases
172 (modify-phases %standard-phases
173 (replace 'configure
174 (lambda _
175 (chdir "src")
176 ;; We use version 19 of the PortAudio library, so we must copy the
177 ;; corresponding file to be sure that espeak compiles correctly.
178 (copy-file "portaudio19.h" "portaudio.h")
179 (substitute* "Makefile"
180 (("/bin/ln") "ln")
181 (("\\$\\(INSTALL\\).*\\$\\(STATIC_LIB.*") "")))))))
182 (inputs
183 (list portaudio pulseaudio))
184 (native-inputs (list unzip))
185 (home-page "https://espeak.sourceforge.net/")
186 (synopsis "Software speech synthesizer")
187 (description "eSpeak is a software speech synthesizer for English and
188other languages. eSpeak uses a \"formant synthesis\" method. This allows many
189languages to be provided in a small size. The speech is clear, and can be used
190at high speeds, but is not as natural or smooth as larger synthesizers which are
191based on human speech recordings.")
192 (license license:gpl3+)))
193
194(define-public espeak-ng
195 (let ((commit "0d451f8c1c6ae837418b823bd9c4cbc574ea9ff5")
196 (revision "1"))
197 (package
198 (name "espeak-ng")
199 (version (git-version "1.52.0" revision commit))
200 (source
201 (origin
202 (method git-fetch)
203 (uri (git-reference
204 (url "https://github.com/espeak-ng/espeak-ng")
205 (commit commit)))
206 (file-name (git-file-name name version))
207 (sha256
208 (base32 "0s1kiq8y7vlz8p5xgkxdrbiyh3p0rd32hdzib421nbnji3wy54y2"))))
209 (build-system cmake-build-system)
210 (arguments
211 `(#:configure-flags '("-DBUILD_SHARED_LIBS=ON")
212 ;; Building in parallel triggers a race condition in 1.49.2.
213 #:parallel-build? #f
214 ;; XXX: Some tests require an audio device.
215 #:tests? #f))
216 (native-inputs
217 (list which))
218 (inputs
219 (list libcap pcaudiolib sonic))
220 (home-page "https://github.com/espeak-ng/espeak-ng")
221 (synopsis "Software speech synthesizer")
222 (description
223 "eSpeak NG is a software speech synthesizer for more than 100 languages.
224It is based on the eSpeak engine and supports spectral and Klatt formant
225synthesis, and the ability to use MBROLA voices.")
226 (license license:gpl3+))))
227
228(define-public mitlm
229 (package
230 (name "mitlm")
231 (version "0.4.2")
232 (source (origin
233 (method url-fetch)
234 (uri (string-append "https://github.com/mitlm/mitlm/releases/"
235 "download/v" version "/"
236 name "-" version ".tar.xz"))
237 (sha256
238 (base32
239 "09fv4fcpmw9g1j0zml0k5kk1lgjw2spr8gn51llbkaaph6v8d62a"))))
240 (build-system gnu-build-system)
241 (native-inputs
242 (list gfortran))
243 (synopsis "The MIT Language Modeling toolkit")
244 (description "The MIT Language Modeling (MITLM) toolkit is a set of
245tools designed for the efficient estimation of statistical n-gram language
246models involving iterative parameter estimation. It achieves much of its
247efficiency through the use of a compact vector representation of n-grams.")
248 (home-page "https://github.com/mitlm/mitlm")
249 (license license:expat)))
250
251(define-public speech-dispatcher
252 (package
253 (name "speech-dispatcher")
254 (version "0.12.1")
255 (source (origin
256 (method git-fetch)
257 (uri (git-reference
258 (url "https://github.com/brailcom/speechd")
259 (commit version)))
260 (file-name (git-file-name name version))
261 (sha256
262 (base32
263 "0f1mqs80b4fbnpii5mn82xn54nbxy229hwjfqbir26zqk4pinf7q"))))
264 (build-system gnu-build-system)
265 (arguments
266 `(#:configure-flags '("--disable-static"
267
268 ;; Disable support for proprietary TTS engines.
269 "--with-voxin=no" "--with-ibmtts=no"
270 "--with-kali=no" "--with-baratinoo=no")
271 #:imported-modules ,%pyproject-build-system-modules
272 #:modules ((guix build gnu-build-system)
273 ((guix build pyproject-build-system)
274 #:prefix python:)
275 (guix build utils))
276 #:phases
277 (modify-phases %standard-phases
278 (add-after 'unpack 'patch-bin-bash
279 (lambda* (#:key inputs #:allow-other-keys)
280 (substitute* "src/modules/generic.c"
281 (("/bin/bash")
282 (search-input-file inputs "/bin/bash")))))
283 (add-after 'install 'wrap-spd-conf
284 (lambda* (#:key inputs outputs #:allow-other-keys)
285 (wrap-program (search-input-file outputs "bin/spd-conf")
286 `("GUIX_PYTHONPATH" =
287 (,(getenv "GUIX_PYTHONPATH")
288 ,(python:site-packages inputs outputs)))))))))
289 (native-inputs
290 (list autoconf
291 automake
292 gettext-minimal
293 libtool
294 pkg-config
295 texinfo))
296 (inputs
297 (list bash-minimal
298 dotconf
299 espeak-ng
300 flite
301 glib
302 libltdl
303 libsndfile
304 pipewire
305 pulseaudio
306 python
307 python-pyxdg))
308 (synopsis "Common interface to speech synthesizers")
309 (description "The Speech Dispatcher project provides a high-level
310device independent layer for access to speech synthesis through a simple,
311stable and well documented interface.")
312 (home-page "https://devel.freebsoft.org/speechd")
313 ;; The software is distributed under GPL2+, but includes a number
314 ;; of files covered by other licenses. Note: in practice, this
315 ;; is linked against dotconf, which is LGPL 2.1 only.
316 (license (list license:gpl2+
317 license:fdl1.2+ ; Most files in doc/ are dual gpl2+/fdl1.2+.
318 license:lgpl2.1+
319 (license:non-copyleft
320 ;; festival_client.{c,h} carries an expat-style license.
321 "See src/modules/festival_client.c in the distribution.")
322 license:gpl3+)))) ; doc/texinfo.tex -- with TeX exception.
323
324(define-public sonic
325 (package
326 (name "sonic")
327 (version "0.2.0")
328 (source (origin
329 (method git-fetch)
330 (uri (git-reference
331 (url "https://github.com/waywardgeek/sonic")
332 (commit (string-append "release-" version))))
333 (file-name (git-file-name name version))
334 (sha256
335 (base32
336 "08xwnpw9cnaix1n1i7gvpq5hrfrqc2z1snjhjapfam506hrc77g4"))))
337 (build-system gnu-build-system)
338 (arguments
339 `(#:tests? #f ; no test suite
340 #:make-flags
341 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
342 (string-append "LDFLAGS=-Wl,-rpath="
343 (assoc-ref %outputs "out") "/lib"))
344 #:phases
345 (modify-phases %standard-phases
346 (add-after 'unpack 'respect-LDFLAGS
347 (lambda _
348 (substitute* "Makefile"
349 ((" -o sonic " match)
350 (string-append " $(LDFLAGS)" match)))
351 #t))
352 (delete 'configure)))) ; no ./configure script
353 (synopsis "Speed up or slow down speech")
354 (description "Sonic implements a simple algorithm for speeding up or slowing
355down speech. However, it's optimized for speed ups of over 2X, unlike previous
356algorithms for changing speech rate. Sonic is a C library designed to be easily
357integrated into streaming voice applications such as text-to-speech (TTS) back
358ends.
359
360The primary motivation behind Sonic is to enable the blind and visually impaired
361to improve their productivity with speech engines, like eSpeak. Sonic can also
362be used by the sighted.")
363 (home-page "https://github.com/waywardgeek/sonic")
364 (license license:asl2.0)))
365
366(define-public festival
367 (package
368 (name "festival")
369 (version "2.5.0")
370 (source (origin
371 (method url-fetch)
372 (uri (string-append "http://festvox.org/packed/festival/"
373 (version-major+minor version)
374 "/festival-" version "-release.tar.gz"))
375 (sha256
376 (base32
377 "1d5415nckiv19adxisxfm1l1xxfyw88g87ckkmcr0lhjdd10g42c"))))
378 (build-system gnu-build-system)
379 (arguments
380 `(#:tests? #f ; there is no test target
381 #:make-flags
382 (list (string-append "RM="
383 (assoc-ref %build-inputs "coreutils")
384 "/bin/rm")
385 (string-append "ECHO_N="
386 (assoc-ref %build-inputs "coreutils")
387 "/bin/printf \"%s\"")
388 "LINUXAUDIO=alsa")
389 #:parallel-build? #f ; not supported
390 #:modules ((guix build gnu-build-system)
391 (guix build utils)
392 (guix build emacs-utils))
393 #:imported-modules (,@%default-gnu-imported-modules
394 (guix build emacs-utils))
395 #:phases
396 (modify-phases %standard-phases
397 (add-after 'unpack 'unpack-and-patch-speech-tools
398 (lambda* (#:key inputs #:allow-other-keys)
399 (invoke "tar" "-C" ".."
400 "-xf" (assoc-ref inputs "speech-tools"))
401 (with-directory-excursion "../speech_tools"
402 (substitute* '("config/rules/modules.mak"
403 "config/rules/test_make_rules.mak"
404 "config/make_system.mak")
405 (("/bin/sh") (which "sh"))))
406 #t))
407 (add-after 'unpack-and-patch-speech-tools 'set-fcommon
408 (lambda _
409 (substitute* "../speech_tools/config/rules/defaults.mak"
410 (("\\(CFLAGS\\)") "(CFLAGS) -fcommon")
411 (("\\(CXXFLAGS\\)") "(CXXFLAGS) -fcommon"))))
412 (add-after 'unpack 'patch-/bin/sh
413 (lambda _
414 (substitute* '("config/test_make_rules"
415 "config/make_system.mak")
416 (("/bin/sh") (which "sh")))
417 #t))
418 (add-before 'build 'build-speech-tools
419 (lambda* (#:key configure-flags make-flags #:allow-other-keys)
420 (with-directory-excursion "../speech_tools"
421 (apply invoke "sh" "configure"
422 (string-append "CONFIG_SHELL=" (which "sh"))
423 (string-append "SHELL=" (which "sh"))
424 configure-flags)
425 (apply invoke "make" make-flags))))
426 (add-after 'build 'build-documentation
427 (lambda _
428 (with-directory-excursion "doc"
429 (invoke "make" "festival.info"))))
430 (add-after 'unpack 'set-installation-directories
431 (lambda* (#:key outputs #:allow-other-keys)
432 (let ((out (assoc-ref outputs "out")))
433 (substitute* "config/project.mak"
434 (("^FTLIBDIR.*")
435 (string-append "FTLIBDIR=" out "/share/festival/lib")))
436 (substitute* "config/systems/default.mak"
437 (("^INSTALL_PREFIX.*")
438 (string-append "INSTALL_PREFIX=" out)))
439 #t)))
440 (add-after 'install 'actually-install
441 (lambda* (#:key inputs outputs #:allow-other-keys)
442 (let ((out (assoc-ref outputs "out")))
443 ;; Install Speech Tools first
444 (with-directory-excursion "../speech_tools"
445 ;; Target directories
446 (for-each (lambda (dir)
447 (mkdir-p (string-append out dir)))
448 '("/bin"
449 "/lib"
450 "/include/speech_tools/"
451 "/include/speech_tools/instantiate"
452 "/include/speech_tools/ling_class"
453 "/include/speech_tools/rxp"
454 "/include/speech_tools/sigpr"
455 "/include/speech_tools/unix"))
456 ;; Install binaries
457 (for-each (lambda (file)
458 (install-file file (string-append out "/bin")))
459 (find-files "bin" ".*"))
460 (for-each (lambda (file)
461 (delete-file (string-append out "/bin/" file)))
462 '("est_gdb" "est_examples" "est_program"))
463 ;; Install libraries
464 (for-each (lambda (file)
465 (install-file file (string-append out "/lib")))
466 (find-files "lib" "lib.*\\.so.*"))
467
468 ;; Install headers
469 (for-each
470 (lambda (dir)
471 (for-each
472 (lambda (header)
473 (install-file header
474 (string-append out "/include/speech_tools/" dir)))
475 (find-files (string-append "include/" dir)
476 "\\.h$")))
477 '("." "instantiate" "ling_class" "rxp" "sigpr" "unix")))
478
479 ;; Unpack files that will be installed together with the
480 ;; Festival libraries.
481 (invoke "tar" "--strip-components=1"
482 "-xvf" (assoc-ref inputs "festvox-cmu"))
483 (invoke "tar" "--strip-components=1"
484 "-xvf" (assoc-ref inputs "festvox-poslex"))
485 (invoke "tar" "--strip-components=1"
486 "-xvf" (assoc-ref inputs "default-voice"))
487
488 ;; Install Festival
489 (let ((bin (string-append out "/bin"))
490 (incdir (string-append out "/include/festival"))
491 (share (string-append out "/share/festival"))
492 (info (string-append out "/share/info")))
493 (for-each (lambda (executable)
494 (install-file executable bin))
495 '("src/main/festival"
496 "src/main/festival_client"
497 "examples/benchmark"))
498 (let ((scripts '("examples/dumpfeats"
499 "examples/durmeanstd"
500 "examples/latest"
501 "examples/make_utts"
502 "examples/powmeanstd"
503 "examples/run-festival-script"
504 "examples/saytime"
505 "examples/scfg_parse_text"
506 "examples/text2pos"
507 "examples/text2wave")))
508 (substitute* scripts
509 (("exec /tmp/guix-build.*/bin/festival")
510 (string-append "exec " bin "/festival")))
511 (for-each (lambda (script)
512 (install-file script bin))
513 scripts))
514
515 ;; Documentation
516 (for-each (lambda (file)
517 (install-file file info))
518 (find-files "doc/info/" "festival.info.*"))
519
520 ;; Headers
521 (mkdir-p incdir)
522 (for-each (lambda (header)
523 (install-file header
524 (string-append incdir "/"
525 (dirname header))))
526 (find-files "src/include" "\\.h$"))
527
528 ;; Data
529 (mkdir-p share)
530 (for-each (lambda (file)
531 (install-file file
532 (string-append share "/"
533 (dirname file))))
534 (find-files "lib" ".*"))
535 (for-each delete-file
536 (append (find-files share "Makefile")
537 (find-files bin "Makefile")))))
538 #t))
539 (add-after 'actually-install 'install-emacs-mode
540 (lambda* (#:key outputs #:allow-other-keys)
541 (let ((emacs-dir (string-append (assoc-ref outputs "out")
542 "/share/emacs/site-lisp")))
543 (install-file "lib/festival.el" emacs-dir)
544 (emacs-generate-autoloads ,name emacs-dir)
545 #t)))
546 ;; Rebuild the very old configure script that is confused by extra
547 ;; arguments.
548 (add-before 'configure 'bootstrap
549 (lambda _ (invoke "autoreconf" "-vif"))))))
550 (inputs
551 (list alsa-lib
552 ncurses))
553 (native-inputs
554 `(("autoconf" ,autoconf)
555 ("automake" ,automake)
556 ("texinfo" ,texinfo)
557 ("emacs" ,emacs-minimal)
558 ("festvox-cmu"
559 ,(origin
560 (method url-fetch)
561 (uri (string-append "http://festvox.org/packed/festival/"
562 (version-major+minor version)
563 "/festlex_CMU.tar.gz"))
564 (sha256
565 (base32
566 "01vwidqhhg2zifvk1gby91mckg1z2pv2mj6lihvdaifakf8k1561"))))
567 ("festvox-poslex"
568 ,(origin
569 (method url-fetch)
570 (uri (string-append "http://festvox.org/packed/festival/"
571 (version-major+minor version)
572 "/festlex_POSLEX.tar.gz"))
573 (sha256
574 (base32
575 "18wywilxaqwy63lc47p5g5529mpxhslibh1bjij0snxx5mjf7ip7"))))
576 ("default-voice"
577 ,(origin
578 (method url-fetch)
579 (uri (string-append "http://festvox.org/packed/festival/"
580 (version-major+minor version)
581 "/voices/festvox_kallpc16k.tar.gz"))
582 (sha256
583 (base32
584 "136hmsyiwnlg2qwa508dy0imf19mzrb5r3dmb2kg8kcyxnslm740"))))
585 ("speech-tools"
586 ,(origin
587 (method url-fetch)
588 (uri (string-append "http://festvox.org/packed/festival/"
589 (version-major+minor version)
590 "/speech_tools-" version "-release.tar.gz"))
591 (sha256
592 (base32
593 "1k2xh13miyv48gh06rgsq2vj25xwj7z6vwq9ilsn8i7ig3nrgzg4"))))))
594 (home-page "https://www.cstr.ed.ac.uk/projects/festival/")
595 (synopsis "Speech synthesis system")
596 (description "Festival offers a general framework for building speech
597synthesis systems as well as including examples of various modules. As a
598whole it offers full text to speech through a number APIs: from shell level,
599though a Scheme command interpreter, as a C++ library, from Java, and an Emacs
600interface. Festival is multi-lingual though English is the most advanced.
601The system is written in C++ and uses the Edinburgh Speech Tools Library for
602low level architecture and has a Scheme (SIOD) based command interpreter for
603control.")
604 (license (license:non-copyleft "file://COPYING"))))
605
606(define-public gst-vosk
607 (package
608 (name "gst-vosk")
609 (version "0.3.1")
610 (source (origin
611 (method git-fetch)
612 (uri (git-reference
613 (url "https://github.com/PhilippeRo/gst-vosk")
614 (commit version)))
615 (file-name (git-file-name name version))
616 (sha256
617 (base32
618 "1zxifssh57a251af9x4ahglcipvmkgc1pmc67l59s805za9yvq3p"))
619 (modules '((guix build utils)))
620 (snippet
621 ;; Do not use prebuilt vosk library
622 '(begin
623 (delete-file-recursively "vosk")
624 (substitute* "meson.build"
625 (("subdir\\('vosk'\\)") ""))
626 (substitute* "src/meson.build"
627 (("vosk_libdir =.*") "")
628 ((", dirs : vosk_libdir") "")
629 (("include_directories : include_directories.*") ""))
630 (substitute* '("src/gstvosk.h"
631 "src/gstvosk.c")
632 (("vosk-api.h") "vosk_api.h"))))))
633 (build-system meson-build-system)
634 (arguments
635 (list
636 #:phases
637 '(modify-phases %standard-phases
638 (add-after 'unpack 'install-vosk-api-header
639 (lambda* (#:key inputs #:allow-other-keys)
640 (install-file (search-input-file inputs "src/vosk_api.h")
641 "src"))))))
642 (inputs
643 (list vosk-api gstreamer gobject-introspection))
644 (native-inputs (list pkg-config gettext-minimal))
645 (home-page "https://github.com/PhilippeRo/gst-vosk")
646 (synopsis "Gstreamer plugin for VOSK voice recognition engine")
647 (description "This package provides a Gstreamer plugin for the VOSK voice
648recognition engine.")
649 (license license:gpl2+)))
650
651(define-public ekho
652 (package
653 (name "ekho")
654 (version "9.0")
655 (source
656 (origin
657 (method url-fetch)
658 (uri
659 (string-append "mirror://sourceforge/e-guidedog/Ekho/"
660 version "/ekho-" version ".tar.xz"))
661 (sha256
662 (base32 "04wcz9g8cbpq3x0ymxwg2kyd82pjbk620b6hm11285283k1z13px"))))
663 (build-system gnu-build-system)
664 (arguments
665 (list
666 #:phases
667 #~(modify-phases %standard-phases
668 (add-after 'unpack 'remove-configure-script
669 ;; Trigger the rebuild of configure script
670 (lambda _
671 (delete-file "configure")))
672 (add-before 'configure 'set-cxxflag-utf8cpp
673 (lambda _
674 (setenv "CXXFLAGS"
675 (string-append "-I"
676 #$(this-package-input "utfcpp")
677 "/include/utf8cpp")))))))
678 (inputs
679 (list alsa-lib
680 espeak-ng
681 libsndfile
682 libout123
683 pulseaudio
684 sonic
685 utfcpp))
686 (native-inputs
687 (list autoconf
688 automake
689 libtool
690 pkg-config))
691 (native-search-paths
692 (list (search-path-specification
693 (variable "EKHO_DATA_PATH")
694 (files '("share/ekho-data")))))
695 (home-page "https://eguidedog.net/ekho.php")
696 (synopsis "Chinese text-to-speech software")
697 (description
698 "Ehko is a @acronym{TTS, Text-To-Speak} software. It supports Cantonese,
699Mandarin, Toisanese, Zhaoan Hakka, Tibetan, Ngangien and Korean (in trial).
700It can also speak English through eSpeak or Festival.")
701 (license (list license:gpl2+
702 ;; libmusicxml
703 license:mpl2.0))))
704
705(define-public pocketsphinx
706 (package
707 (name "pocketsphinx")
708 (version "5.0.4")
709 (source
710 (origin
711 (method git-fetch)
712 (uri (git-reference
713 (url "https://github.com/cmusphinx/pocketsphinx")
714 (commit (string-append "v" version))))
715 (file-name (git-file-name name version))
716 (sha256
717 (base32
718 "16andx54333rdyf6c33s8pfns2wvqfapqp9dhh8fpgzdyg6bfhhd"))))
719 (build-system cmake-build-system)
720 (arguments
721 (list #:tests? #false ;XXX: test binaries are missing
722 #:configure-flags #~(list "-DBUILD_SHARED_LIBS=ON"
723 "-DBUILD_GSTREAMER=ON")))
724 (native-inputs
725 (list pkg-config
726 perl ;for tests
727 python
728 swig-4.0))
729 (inputs
730 (list alsa-lib
731 ffmpeg
732 gstreamer
733 libcap
734 pulseaudio
735 portaudio
736 sox))
737 (home-page "https://cmusphinx.github.io/")
738 (synopsis "Recognizer library written in C")
739 (description "PocketSphinx is one of Carnegie Mellon University's
740large vocabulary, speaker-independent continuous speech recognition
741engine.")
742 (license license:bsd-2)))
743
744(define-deprecated-package sphinxbase
745 pocketsphinx)
746
747(define-public python-onnx-ir
748 (package
749 (name "python-onnx-ir")
750 (version "0.2.1")
751 (source
752 (origin
753 (method git-fetch)
754 (uri (git-reference
755 (url "https://github.com/onnx/ir-py")
756 (commit (string-append "v" version))))
757 (file-name (git-file-name name version))
758 (sha256
759 (base32 "145frvf8cpyvvwc5dz8z6y9g55qdqv1q2bcrvhmx96rv4433rnmx"))))
760 (build-system pyproject-build-system)
761 (arguments
762 (list
763 #:test-flags
764 #~(list "--ignore=tools/model_zoo_test"
765 ;; This test imports onnxscript which is not available (circular
766 ;; dependency: python-onnx-ir -> python-onnxscript -> python-onnx-ir).
767 "--ignore=src/onnx_ir/passes/common/common_subexpression_elimination_test.py"
768 ;; These tests require safetensors >= 0.7.0, Guix has 0.4.3.
769 "--ignore=src/onnx_ir/_safetensors/"
770 ;; This test imports all onnx_ir modules including
771 ;; common_subexpression_elimination_test.py which imports onnxscript.
772 ;; Cannot add onnxscript to native-inputs: circular dependency
773 ;; (python-onnx-ir -> python-onnxscript -> python-onnx-ir).
774 "--ignore=tests/public_api_test.py"
775 ;; These tests use [node_name] syntax in ONNX text format, which
776 ;; was added in onnx 1.18.0 (PR #6349). Guix has onnx 1.17.0.
777 "-k" (string-join
778 '("not test_from_to_onnx_text"
779 "not test_to_onnx_text_excluding_initializers"
780 "not test_deserialize_builds_correct_value_connections_for_subgraphs")
781 " and "))))
782 (propagated-inputs
783 (list python-numpy
784 onnx
785 python-typing-extensions
786 python-ml-dtypes))
787 (native-inputs
788 (list python-setuptools
789 python-pytest
790 python-parameterized
791 python-hypothesis
792 python-pyyaml
793 python-pytorch
794 python-torchvision
795 python-transformers
796 python-safetensors
797 (list onnxruntime "python")))
798 (home-page "https://github.com/onnx/ir-py")
799 (synopsis "ONNX IR Python library")
800 (description "This package provides a Python library for ONNX
801intermediate representation.")
802 (license license:asl2.0)))
803
804(define-public python-onnxscript
805 (package
806 (name "python-onnxscript")
807 (version "0.6.2")
808 (source
809 (origin
810 (method git-fetch)
811 (uri (git-reference
812 (url "https://github.com/microsoft/onnxscript")
813 (commit (string-append "v" version))))
814 (file-name (git-file-name name version))
815 (sha256
816 (base32 "0sqkp3sjj6immvqgyc8s5kx6661g3lhcbka1z8hczxcqydmqv9xd"))))
817 (build-system pyproject-build-system)
818 (arguments
819 (list
820 #:phases
821 #~(modify-phases %standard-phases
822 (add-before 'check 'delete-build-lib
823 (lambda _
824 ;; Pytest gets confused when test modules exist in both
825 ;; build/lib and source tree.
826 (delete-file-recursively "build/lib"))))
827 #:test-flags
828 #~(list
829 ;; These tests require 2.1 GB of test fixtures stored in Git LFS
830 ;; (testdata/unittest_models/, testdata/e2e_models/).
831 "--ignore=tests/ir/serde_roundtrip_test.py"
832 "--ignore=tests/ir/graph_view_test.py"
833 "--ignore=tests/optimizer/test_models.py"
834 "--ignore=tests/version_converter/version_conversion_test.py"
835 ;; Uses onnx.hub to download models from the internet.
836 "--ignore=tools/ir/model_zoo_test/"
837 ;; 2.2e-5 relative error is above the 2e-5 threshold, but it
838 ;; looks acceptable here.
839 (string-append
840 "--deselect=tests/function_libs/torch_lib/ops_test.py"
841 "::TestOutputConsistencyFullGraphCPU"
842 "::test_complex_output_match_opinfo__matmul_cpu_complex64"))))
843 (propagated-inputs
844 (list onnx
845 python-ml-dtypes
846 python-numpy
847 python-onnx-ir
848 python-packaging
849 python-typing-extensions))
850 (native-inputs
851 (list git-minimal
852 python-setuptools
853 python-pytest
854 python-parameterized
855 python-expecttest
856 python-pytorch
857 python-torchvision
858 (list onnxruntime "python")))
859 (home-page "https://github.com/microsoft/onnxscript")
860 (synopsis "ONNX Script enables authoring ONNX models in Python")
861 (description "This package enables developers to author ONNX models
862using a Python-based domain-specific language.")
863 (license license:expat)))
864
865;;; Parakeet TDT V3 ONNX model weights from istupakov/parakeet-tdt-0.6b-v3-onnx
866;;; (HuggingFace, revision abd2878d52a678ce380088ef9d9b1d9664404565).
867;;; License: CC-BY-4.0 (NVIDIA).
868;;; Int8 quantized variant (~670 MB total).
869
870(define %parakeet-hf-base
871 "https://huggingface.co/istupakov/parakeet-tdt-0.6b-v3-onnx/resolve/abd2878d52a678ce380088ef9d9b1d9664404565")
872
873(define parakeet-tdt-config
874 (origin
875 (method url-fetch)
876 (uri (string-append %parakeet-hf-base "/config.json"))
877 (file-name "config.json")
878 (sha256
879 (base32 "0rn4i8ad5h1vga6yq04qpy6qmc30rpvd9bqhqbrcm64pdg3h6sb6"))))
880
881(define parakeet-tdt-vocab
882 (origin
883 (method url-fetch)
884 (uri (string-append %parakeet-hf-base "/vocab.txt"))
885 (file-name "vocab.txt")
886 (sha256
887 (base32 "0pf3wcvps76wq7iadw37lk7xcjs7gpmlbxficg2nmg54krkl91fm"))))
888
889(define parakeet-tdt-encoder-int8
890 (origin
891 (method url-fetch)
892 (uri (string-append %parakeet-hf-base "/encoder-model.int8.onnx"))
893 (file-name "encoder-model.int8.onnx")
894 (sha256
895 (base32 "02gzb82y86vl7jr69bn7qyfbifpd4nbi9ivpnabn020vgvxd4fb1"))))
896
897(define parakeet-tdt-decoder-joint-int8
898 (origin
899 (method url-fetch)
900 (uri (string-append %parakeet-hf-base "/decoder_joint-model.int8.onnx"))
901 (file-name "decoder_joint-model.int8.onnx")
902 (sha256
903 (base32 "0w3scrvqj74xv6h2f8c1k2q9234nwf1yvj7dv9sh78yiwcz4i9zf"))))
904
905(define-public python-onnx-asr
906 (package
907 (name "python-onnx-asr")
908 (version "0.10.2")
909 (source
910 (origin
911 (method url-fetch)
912 (uri (pypi-uri "onnx_asr" version))
913 (sha256
914 (base32 "0d5vmkavcqjf7b2aa0nc118b2pf34mc7yzjkaw92rl42rwwijf3h"))
915 (patches
916 (search-patches "python-onnx-asr-0.10.2-bundled-parakeet-model.patch"))))
917 (build-system pyproject-build-system)
918 (arguments
919 (list
920 #:test-flags
921 #~(list ;; These tests try to download models from HuggingFace Hub.
922 "--ignore=tests/onnx_asr/test_recognize.py"
923 "--ignore=tests/onnx_asr/test_cli.py"
924 "--ignore=tests/onnx_asr/test_load_model_errors.py"
925 ;;; These tests would compare preprocessor output against
926 ;;; reference implementations that are not in Guix:
927 ;;; - kaldi_native_fbank (C++ lib, not packaged)
928 ;;; - nemo (NVIDIA NeMo framework, not packaged)
929 ;;; - openai-whisper (Python package, not packaged;
930 ;;; whisper-cpp exists but is C++ only, no Python module)
931 "--ignore=tests/preprocessors/test_kaldi.py"
932 "--ignore=tests/preprocessors/test_nemo.py"
933 "--ignore=tests/preprocessors/test_whisper_preprocessor.py")
934 #:phases
935 #~(modify-phases %standard-phases
936 (add-after 'install 'install-parakeet-model
937 (lambda* (#:key inputs outputs #:allow-other-keys)
938 (let* ((out (assoc-ref outputs "out"))
939 (site (string-append out "/lib/python"
940 #$(version-major+minor
941 (package-version python))
942 "/site-packages/onnx_asr"))
943 (model-dir (string-append site
944 "/models-data"
945 "/parakeet-tdt-0.6b-v3")))
946 (mkdir-p model-dir)
947 (symlink (assoc-ref inputs "config.json")
948 (string-append model-dir "/config.json"))
949 (symlink (assoc-ref inputs "vocab.txt")
950 (string-append model-dir "/vocab.txt"))
951 (symlink (assoc-ref inputs "encoder-model.int8.onnx")
952 (string-append model-dir
953 "/encoder-model.int8.onnx"))
954 (symlink (assoc-ref inputs
955 "decoder_joint-model.int8.onnx")
956 (string-append model-dir
957 "/decoder_joint-model.int8.onnx")))))
958 (add-after 'install-parakeet-model 'patch-model-paths
959 (lambda* (#:key outputs #:allow-other-keys)
960 (let* ((out (assoc-ref outputs "out"))
961 (site (string-append out "/lib/python"
962 #$(version-major+minor
963 (package-version python))
964 "/site-packages/onnx_asr"))
965 (model-dir (string-append site
966 "/models-data"
967 "/parakeet-tdt-0.6b-v3")))
968 (substitute* (string-append site "/loader.py")
969 (("@PARAKEET_MODEL_DIR@") model-dir))))))))
970 (propagated-inputs
971 (list python-numpy
972 python-huggingface-hub
973 (list onnxruntime "python")))
974 (native-inputs
975 (list nss-certs-for-test
976 onnx
977 parakeet-tdt-config
978 parakeet-tdt-vocab
979 parakeet-tdt-encoder-int8
980 parakeet-tdt-decoder-joint-int8
981 python-hatchling
982 python-onnxscript
983 python-pytorch
984 python-pytest
985 python-torchaudio))
986 (home-page "https://github.com/istupakov/onnx-asr")
987 (synopsis "Speech recognition using ONNX models")
988 (description
989 "ONNX ASR is a Python library for automatic speech recognition using
990ONNX Runtime. It supports models including Whisper and NeMo Parakeet.
991Includes bundled Parakeet TDT V3 model weights (int8, CC-BY-4.0, NVIDIA).")
992 (license license:expat)))
993
994(define-public python-piper-tts
995 (package
996 (name "python-piper-tts")
997 (version "1.5.0")
998 (source
999 (origin
1000 (method git-fetch)
1001 (uri (git-reference
1002 (url "https://github.com/OHF-Voice/piper1-gpl")
1003 (commit (string-append "v" version))))
1004 (file-name (git-file-name name version))
1005 (sha256
1006 (base32 "0a043ra92dm2i20861xj1l55zz8i3rry8j576a2mqqab20ajd4as"))))
1007 (build-system pyproject-build-system)
1008 (arguments
1009 (list
1010 #:phases
1011 #~(modify-phases %standard-phases
1012 (add-after 'unpack 'no-embedded-git-fetch
1013 ;; This project compiles a recent version of espeak-ng using
1014 ;; an "ExternalProject_Add(...)" in the CMakeLists file that
1015 ;; lets `CMake` use `git` to fetch and build espeak-ng, see:
1016 ;; https://github.com/OHF-Voice/piper1-gpl/blob/main/docs/BUILDING.md#design-decisions
1017 ;; It will work just fine with the version of espeak-ng we have
1018 ;; so we will edit the CMakeLists file in-place.
1019 (lambda* (#:key inputs #:allow-other-keys)
1020 (use-modules (ice-9 regex)
1021 (ice-9 rdelim))
1022 (let ((pattern (make-regexp
1023 "ExternalProject_Add\\(espeak_ng_external[^)]+\\)"
1024 regexp/extended))
1025 (replacement "add_library(espeak_ng_external INTERFACE)"))
1026 ;; Delete the multi-line "ExternalProject_Add(...)" block
1027 ;; replacing it with a stub so cmake doesn't complain.
1028 (with-atomic-file-replacement "CMakeLists.txt"
1029 (lambda (in out)
1030 (display (regexp-substitute/global
1031 #f
1032 pattern
1033 (read-string in)
1034 'pre
1035 replacement
1036 'post) out))))
1037 (let ((espeak (assoc-ref inputs "espeak-ng"))
1038 (espeak-lib (search-input-file inputs
1039 "lib/libespeak-ng.so.1"))
1040 (espeak-data (search-input-directory inputs
1041 "share/espeak-ng-data"))
1042 (cmake-setter (lambda (k v)
1043 (string-append "set(" k " \"" v "\")\n"))))
1044 ;; set paths to find dependencies in our guix env
1045 (substitute* "CMakeLists.txt"
1046 (("set\\(ESPEAKNG_INSTALL_DIR .*")
1047 (cmake-setter "ESPEAKNG_INSTALL_DIR" espeak))
1048 (("set\\(ESPEAKNG_STATIC_LIB .*")
1049 (cmake-setter "ESPEAKNG_STATIC_LIB" espeak-lib))
1050 ;; espeak-ng in guix does not have UCD in its outputs
1051 ;; but piper finds all it needs from linked .so library
1052 (("set\\(UCD_STATIC_LIB .*")
1053 (cmake-setter "UCD_STATIC_LIB" ""))
1054 (("set\\(DATA_SRC .*")
1055 (cmake-setter "DATA_SRC" espeak-data)))))))))
1056 (native-inputs (list ninja python-scikit-build python-setuptools
1057 python-pytest))
1058 (propagated-inputs (list espeak-ng python-flask python-pathvalidate
1059 python-numpy
1060 (list onnxruntime "python")))
1061 (home-page "https://github.com/OHF-Voice/piper1-gpl")
1062 (synopsis "Fast and local neural text-to-speech engine")
1063 (description
1064 "Piper is a fast and local neural TTS (text-to-speech) engine that embeds
1065espeak-ng for phonemization. It is available as a library, a CLI (command-line
1066interface) tool and a web-server.
1067
1068@example
1069piper -m en_US-lessac-medium -f spoken.wav -- 'Hello, World.'
1070@end example
1071
1072It comes with an HTTP server for repeated usage:
1073
1074@example
1075python3 -m piper.http_server -m en_US-lessac-medium
1076curl -X POST -H 'Content-Type: application/json' \\
1077 -d '@{\"text\":\"This is a test.\"@}' -o spoken.wav localhost:5000/synthesize
1078@end example
1079
1080It does not come with voices installed. Visit the project home-page to sample
1081or download them. Alternatively use: @code{python -m piper.download_voices}.")
1082 (license license:gpl3+)))
1083
1084(define-public python-pocket-tts
1085 (package
1086 (name "python-pocket-tts")
1087 (version "1.1.1")
1088 (source
1089 (origin
1090 (method git-fetch)
1091 (uri (git-reference
1092 (url "https://github.com/kyutai-labs/pocket-tts")
1093 (commit (string-append "v" version))))
1094 (file-name (git-file-name name version))
1095 (sha256
1096 (base32 "0b9xxyrwa8vsz6r6fi7p47z8rd7q2gjjnwq47br89zp2lkzym3zm"))))
1097 (build-system pyproject-build-system)
1098 (arguments
1099 (list
1100 #:test-flags
1101 #~(list ;;; These tests try to download models from HuggingFace Hub.
1102 "--ignore=tests/test_cli_generate.py"
1103 "--ignore=tests/test_documentation_examples.py")))
1104 (propagated-inputs
1105 (list python-beartype
1106 python-einops
1107 python-fastapi
1108 python-huggingface-hub
1109 python-numpy
1110 python-pydantic
1111 python-pytorch
1112 python-safetensors
1113 python-scipy
1114 python-sentencepiece
1115 python-soundfile
1116 python-typer
1117 python-typing-extensions
1118 python-uvicorn))
1119 (native-inputs
1120 (list nss-certs-for-test
1121 python-hatchling
1122 python-pytest))
1123 (home-page "https://github.com/kyutai-labs/pocket-tts")
1124 (synopsis "Fast neural text-to-speech")
1125 (description
1126 "Pocket TTS is a fast neural text-to-speech engine with ~100M parameters,
1127running at approximately 6x realtime on CPU. English only.")
1128 (license license:expat)))