You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

460 lines
20 KiB

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