projects/guix·blob ruby-team · refs

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