From 25a9106faf2d9bd34fb48b689d39232a01a90cba Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Fri, 30 Jul 2021 17:21:07 +0200
Subject: [PATCH v3 2/2] gnu: Add mycroft-core.
* gnu/packages/speech.scm (mycroft-core): New variable.
@@ -210,6 +210,7 @@ (define-module (gnu packages python-xyz)
#:use-module (gnu packages search)
#:use-module (gnu packages serialization)
#:use-module (gnu packages shells)
+ #:use-module (gnu packages speech)
#:use-module (gnu packages sphinx)
#:use-module (gnu packages ssh)
#:use-module (gnu packages swig)
@@ -8,7 +8,7 @@
;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2021 qblade <qblade@protonmail.com>
-;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
+;;; Copyright © 2021, 2022 Petr Hodina <phodina@protonmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -32,28 +32,43 @@ (define-module (gnu packages speech)
#:use-module (guix git-download)
#:use-module (guix utils)
#:use-module (guix build-system gnu)
+ #:use-module (guix build-system python)
#:use-module (gnu packages)
#:use-module (gnu packages audio)
#:use-module (gnu packages autotools)
#:use-module (gnu packages base) ;for 'which'
#:use-module (gnu packages bison)
+ #:use-module (gnu packages check)
#:use-module (gnu packages compression)
+ #:use-module (gnu packages curl)
#:use-module (gnu packages documentation)
#:use-module (gnu packages emacs)
+ #:use-module (gnu packages freedesktop)
#:use-module (gnu packages gcc)
#:use-module (gnu packages gettext)
#:use-module (gnu packages glib)
#:use-module (gnu packages gstreamer)
+ #:use-module (gnu packages icu4c)
+ #:use-module (gnu packages image)
#:use-module (gnu packages linux)
+ #:use-module (gnu packages libffi)
#:use-module (gnu packages ncurses)
+ #:use-module (gnu packages machine-learning)
+ #:use-module (gnu packages mp3)
#:use-module (gnu packages pcre)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages pulseaudio)
#:use-module (gnu packages python)
+ #:use-module (gnu packages python-xyz)
+ #:use-module (gnu packages python-web)
+ #:use-module (gnu packages screen)
+ #:use-module (gnu packages sphinx)
#:use-module (gnu packages swig)
#:use-module (gnu packages texinfo)
- #:use-module (gnu packages textutils))
+ #:use-module (gnu packages textutils)
+ #:use-module (gnu packages time)
+ #:use-module (gnu packages xiph))
(define-public flite
(package
@@ -652,6 +667,127 @@ (define-public sphinxbase
manipulating acoustic feature and audio files.")
(license license:bsd-4)))
+(define-public mycroft-core
+ (package
+ (name "mycroft-core")
+ (version "21.2.2")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/MycroftAI/mycroft-core")
+ (commit (string-append "release/v" version))))
+ (file-name (git-file-name name version))
+ (patches (search-patches "mycroft-core-remove-venv.patch"))
+ (sha256
+ (base32
+ "02r0vxw0hsihnvviwn4fyspwky3kwq42f9z455q1s70k0snzhb28"))))
+ (build-system python-build-system)
+ (arguments
+ `(#:tests? #f ; Currently failing due to ALSA lib
+ ; https://github.com/MycroftAI/mycroft-core/issues/3074
+ #:phases (modify-phases %standard-phases
+ (add-after 'unpack 'patch-requirements
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((mycroft-home (string-append (assoc-ref outputs
+ "out")
+ "/opt/mycroft")))
+ (mkdir-p mycroft-home)
+ ;; Fix home Mycroft directory (used for e.g. skills)
+ (substitute* "scripts/mycroft-use.sh"
+ (("/opt/mycroft") mycroft-home))
+ (substitute* "scripts/my-info.sh"
+ (("/opt/mycroft") mycroft-home))
+ (substitute* "mycroft/skills/mycroft_skill/mycroft_skill.py"
+ (("/opt/mycroft") mycroft-home))
+ (substitute* "mycroft/configuration/mycroft.conf"
+ (("/opt/mycroft") mycroft-home))
+ (substitute* "mycroft/util/file_utils.py"
+ (("/opt/mycroft") mycroft-home))
+ (substitute* "test/unittests/tts/test_mimic_tts.py"
+ (("/opt/mycroft") mycroft-home))
+ (substitute* "test/unittests/api/test_api.py"
+ (("/opt/mycroft") mycroft-home))
+ (substitute* "test/integrationtests/skills/test_all_skills.py"
+ (("/opt/mycroft") mycroft-home))
+ (substitute* "README.md"
+ (("/opt/mycroft") mycroft-home))
+ ;; Fix mimic binary path
+ (substitute* "mycroft/tts/mimic_tts.py"
+ (("bin_ = config.*") (string-append "bin_ = \""
+ (assoc-ref
+ inputs
+ "mycroft-mimic")
+ "/bin/mimic\"
+"))
+ (("os.path.join\\(MYCROFT_ROOT_PATH.*") ""))
+ ;; Fix sanity-check errors
+ (substitute* "setup.py"
+ (("client\\.ws") "client.client"))
+ (substitute* "mycroft/client/text/text_client.py"
+ (("\\.gui_server") "mycroft.client.text.gui_server"))
+ (substitute* "mycroft/client/text/__main__.py"
+ (("\\.text_client")
+ "mycroft.client.text.text_client"))
+ ;; Use newer version of pkg
+ (setenv "MYCROFT_LOOSE_REQUIREMENTS" "1")
+ (substitute* "requirements/requirements.txt"
+ (("requests>=2.20.0,<2.26.0") "requests>=2.20.0")))))
+ (replace 'check
+ (lambda* (#:key tests? #:allow-other-keys
+ #:rest args)
+ (when tests?
+ (setenv "HOME" "/tmp")
+ (setenv "PYTHONPATH"
+ (string-append "./build/lib:"
+ (or (getenv "PYTHONPATH") "")))
+ (apply (assoc-ref %standard-phases
+ 'check) args)))))))
+ (native-inputs (list python-pytest swig))
+ (inputs (list curl
+ fann
+ flac
+ icu4c
+ libffi
+ libjpeg-turbo
+ mpg123
+ mycroft-mimic
+ portaudio
+ pocketsphinx
+ pulseaudio
+ screen))
+ (propagated-inputs (list python-adapt-parser
+ python-dateutil
+ python-fann2
+ python-fasteners
+ python-gtts
+ python-inflection
+ python-lingua-franca
+ python-msk
+ python-msm
+ python-mycroft-messagebus-client
+ python-padaos
+ python-padatious
+ python-petact
+ python-pillow
+ python-pocketsphinx
+ python-precise-runner
+ python-psutil
+ python-pyaudio
+ python-pyee
+ python-pyserial
+ python-pyxdg
+ python-pyyaml
+ python-requests
+ python-requests-futures
+ python-speech-recognition
+ python-tornado-6
+ python-websocket-client
+ python-xdg))
+ (home-page "https://github.com/HelloChatterbox/HolmesIV")
+ (synopsis "Mycroft Core, the Mycroft Artificial Intelligence platform")
+ (description "This module provides a hackable voice assistant - Mycroft")
+ (license license:asl2.0)))
+
(define-public pocketsphinx
(package
(name "pocketsphinx")
--
2.34.0