GNU bug report logs - #58140
Simple offline text-to-speech incoming !

Previous Next

Package: guix-patches;

Reported by: Nicolas Graves <ngraves <at> ngraves.fr>

Date: Wed, 28 Sep 2022 11:36:02 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58140 in the body.
You can then email your comments to 58140 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 11:36:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nicolas Graves <ngraves <at> ngraves.fr>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 28 Sep 2022 11:36:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: guix-patches <at> gnu.org
Subject: Simple offline text-to-speech incoming !
Date: Wed, 28 Sep 2022 13:34:52 +0200
Hi guix!

I've been trying to build python-nerd-dictation for guix for the past
few days, and eventually managed to get a working package.

I'm quite enthousiast about this one, I think it makes a great addition
to the distribution, but it also raises some questions.

1) The wayland version relies on ydotool. Which is not packaged yet, so
https://issues.guix.gnu.org/50847 is a prerequisite for this patch
series.

2) Vosk-API relies on models. I was thinking about the opportunity to
also package these models in guix, since it's only a copy and would make
it more guixy. BUT the big downside is that some of these models are
huge (~2G). Is there a way to not provide substitutes in some such cases
? Maybe that's a thing we can do for all packages relying on a
copy-build-system or something like that ?

3) The wayland version requires some configuration in order to work, for
ydotool particularly. For now, I keep this configuration in a "feature"
from Andrew's Tropin RDE (see
https://lists.sr.ht/~abcdw/rde-devel/patches/35600), but it might be
smarter to try and put that in a service for guix. WDYT ?

I'm going to check everything builds before sending patches, so it might
take an hour or so before patches arrive.

-- 
Best regards,
Nicolas Graves




Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 11:59:01 GMT) Full text and rfc822 format available.

Message #8 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH 1/6] gnu: Add openfst-for-vosk.
Date: Wed, 28 Sep 2022 13:57:50 +0200
* gnu/packages/machine-learning.scm (openfst-for-vosk): New variable.
---
 gnu/packages/machine-learning.scm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index e702e499fc..3ad907e0c9 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -583,6 +583,22 @@ (define-public openfst-1.7.3
     (arguments '(#:configure-flags '("--enable-ngram-fsts" "CXXFLAGS=-std=c++14")
                  #:make-flags '("CXXFLAGS=-std=c++14")))))
 
+(define openfst-for-vosk
+  (package
+    (inherit openfst)
+    (version "1.8.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "http://www.openfst.org/twiki/pub/FST/"
+                           "FstDownload/openfst-" version ".tar.gz"))
+       (sha256
+        (base32 "0h2lfhhihg63b804hrcljnkggijbjmp84i5g8q735wb09y9z2c4p"))))
+    (arguments
+     '(#:configure-flags
+       '("--enable-shared" "--enable-far" "--enable-ngram-fsts"
+         "--enable-lookahead-fsts" "--with-pic" "--disable-bin")))))
+
 (define-public shogun
   (package
     (name "shogun")
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 11:59:02 GMT) Full text and rfc822 format available.

Message #11 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH 2/6] gnu: Add kaldi-for-vosk.
Date: Wed, 28 Sep 2022 13:57:51 +0200
* gnu/packages/machine-learning.scm (kaldi-for-vosk): New variable.
---
 gnu/packages/machine-learning.scm | 98 +++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 3ad907e0c9..9b2e01c102 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1596,6 +1596,104 @@ (define-public kaldi
 written in C++.")
       (license license:asl2.0))))
 
+(define kaldi-for-vosk
+  (let* ((commit "6417ac1dece94783e80dfbac0148604685d27579")
+         (revision "0")
+         (openfst openfst-for-vosk))
+    (package
+      (inherit kaldi)
+      (name "kaldi")
+      (version (git-version "0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/alphacep/kaldi")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "04xw2dpfvpla8skpk08azmgr9k97cd8hn83lj4l85q165gbzql4s"))))
+      (inputs
+       (list alsa-lib
+             ;; `(,gfortran "lib") ;; replaced by lapack
+             lapack
+             glib
+             gstreamer
+             jack-1
+             openblas
+             openfst
+             portaudio
+             python))
+      (arguments
+       (list
+        #:test-target "test"
+        #:make-flags ''("online2" "lm" "rnnlm")
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'chdir
+              (lambda _ (chdir "src") #t))
+            (replace 'configure
+              (lambda* (#:key build system inputs outputs #:allow-other-keys)
+                (when (not (or (string-prefix? "x86_64" system)
+                               (string-prefix? "i686" system)))
+                  (substitute* "makefiles/linux_openblas.mk"
+                    (("-msse -msse2") "")))
+                (substitute* "makefiles/default_rules.mk"
+                  (("/bin/bash") (which "bash")))
+                (substitute* "Makefile"
+                  (("ext_depend: check_portaudio")
+                   "ext_depend:"))
+                (substitute* '("online/Makefile"
+                               "onlinebin/Makefile"
+                               "gst-plugin/Makefile")
+                  (("../../tools/portaudio/install")
+                   (assoc-ref inputs "portaudio")))
+                (substitute* "matrix/Makefile"     ;temporary test bypass
+                  (("matrix-lib-test sparse-matrix-test") ""))
+
+                ;; This `configure' script doesn't support variables passed as
+                ;; arguments, nor does it support "prefix".
+                (let ((out (assoc-ref outputs "out")))
+                  (substitute* "configure"
+                    (("check_for_slow_expf;") "")
+                    ;; This affects the RPATH and also serves as the installation
+                    ;; directory.
+                    (("KALDILIBDIR=`pwd`/lib")
+                     (string-append "KALDILIBDIR=" out "/lib"))
+                    (("OPENBLASROOT=\\\"\\$\\(rel2abs ..\\/tools\\/OpenBLAS\\/install\\)\\\"")
+                     (string-append "OPENBLASROOT=\"" #$openblas "\""))
+                    (("-L\\$OPENBLASLIBDIR -l:libopenblas.a -l:libblas.a -l:liblapack.a -l:libf2c.a")
+                     (string-append "-L$OPENBLASLIBDIR -lopenblas "
+                                    "-L" #$lapack "/lib -lblas -llapack")))
+                  (mkdir-p out) ; must exist
+                  (setenv "CONFIG_SHELL" (which "bash"))
+                  (setenv "OPENFST_VER" #$(package-version openfst))
+                  (invoke "./configure"
+                          "--use-cuda=no"
+                          "--mathlib=OPENBLAS_CLAPACK"
+                          "--shared"
+                          (string-append "--fst-root=" #$openfst)))))
+            (add-after 'configure 'optimize-build
+                       (lambda _ (substitute* "kaldi.mk" ((" -O1") " -O3"))))
+            (replace 'install
+              (lambda* (#:key outputs #:allow-other-keys)
+                (let* ((out (assoc-ref outputs "out"))
+                       (inc (string-append out "/include"))
+                       (lib (string-append out "/lib")))
+                  (mkdir-p lib)
+                  ;; The build phase installed symlinks to the actual
+                  ;; libraries.  Install the actual targets.
+                  (for-each (lambda (file)
+                              (let ((target (readlink file)))
+                                (delete-file file)
+                                (install-file target lib)))
+                            (find-files lib "\\.so"))
+                  ;; Install headers
+                  (for-each (lambda (file)
+                              (let ((target-dir (string-append inc "/" (dirname file))))
+                                (install-file file target-dir)))
+                            (find-files "." "\\.h")))))))))))
+
 (define-public gst-kaldi-nnet2-online
   (let ((commit "cb227ef43b66a9835c14eb0ad39e08ee03c210ad")
         (revision "2"))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 11:59:02 GMT) Full text and rfc822 format available.

Message #14 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH 4/6] gnu: Add python-vosk.
Date: Wed, 28 Sep 2022 13:57:53 +0200
* gnu/packages/machine-learning.scm (python-vosk): New variable.
---
 gnu/packages/machine-learning.scm | 40 +++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index df91a3a2ac..cbbc80db1c 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -3559,3 +3559,43 @@ (define-public vosk-api
 vocabulary for better accuracy, and supports speaker identification beside
 simple speech recognition.")
       (license license:asl2.0))))
+
+(define-public python-vosk
+  (package
+    (inherit vosk-api)
+    (name "python-vosk")
+    (build-system python-build-system)
+    (propagated-inputs
+     (list python-cffi python-requests python-tqdm python-srt python-websockets))
+    (inputs (list vosk-api))
+    (arguments
+     (list
+      #:tests? #f  ;; TODO There are tests but not run through Makefile.
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'config
+            (lambda _
+              (chdir "python")
+              (setenv "VOSK_SOURCE" #$vosk-api)))
+          (add-before 'build 'from-abi-to-api
+            (lambda _
+              (substitute* "vosk_builder.py"
+                (("ffibuilder\\.set_source\\(\"vosk.vosk_cffi\", None\\)")
+                 (string-append
+                  "ffibuilder.set_source(\"vosk.vosk_cffi\", "
+                  "r\"\"\"\n#include<vosk_api.h>\n#include<Python.h>\"\"\",\n\t"
+                  "library_dirs=["
+                  "'" #$vosk-api "/lib'"
+                  "],\n\t"
+                  "libraries=['vosk', 'python3.9'],\n\t"
+                  "include_dirs=["
+                  "'" #$vosk-api "/src'" "])")))
+              (substitute* "vosk/__init__.py"
+                (("_c = open_dll\\(\\)")
+                 "")
+                (("_ffi")
+                 "ffi")
+                (("from \\.vosk_cffi import ffi as ffi")
+                 "from .vosk_cffi import ffi, lib")
+                (("_c\\.")
+                 "lib.")))))))))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 11:59:03 GMT) Full text and rfc822 format available.

Message #17 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH 3/6] gnu: Add vosk-api.
Date: Wed, 28 Sep 2022 13:57:52 +0200
* gnu/packages/machine-learning.scm (vosk-api): New variable.
---
 gnu/packages/machine-learning.scm | 74 +++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 9b2e01c102..df91a3a2ac 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -3485,3 +3485,77 @@ (define-public python-pyro-ppl
      "This package provides a Python library for probabilistic modeling and
 inference.")
     (license license:asl2.0)))
+
+(define-public vosk-api
+  (let* ((openfst openfst-for-vosk)
+         (kaldi kaldi-for-vosk))
+    (package
+      (name "vosk-api")
+      (version "0.3.43")
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/alphacep/vosk-api")
+               (commit (string-append "v" version))))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "0xmp8i140c2hd3rj9dap8a2rnsvzb1k9hnqm12xzbaxrw73rkc29"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list
+        #:tests? #f
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'chdir
+              (lambda _ (chdir "src") #t))
+            (replace 'configure
+              (lambda _
+                (substitute* "./Makefile"
+                  (("USE_SHARED\\?=0")
+                   "USE_SHARED?=1")
+                  (("-DFST_NO_DYNAMIC_LINKING")
+                   "")
+                  (("-lopenblas -llapack -lblas -lf2c")
+                   (string-append
+                    "-L" #$openblas "/lib " "-lopenblas "
+                    "-L" #$lapack "/lib " "-llapack -lblas "))
+                  (("-lfst -lfstngram")
+                   (string-append
+                    "-L" #$openfst "/lib " "-lfst -lfstngram "))
+                  (("\\$\\(HOME\\)\\/travis\\/kaldi")
+                   #$(file-append kaldi "/include"))
+                  (("\\$\\(KALDI_ROOT\\)\\/tools\\/openfst")
+                   #$openfst)
+                  (("\\$\\(KALDI_ROOT\\)\\/tools\\/OpenBLAS\\/install")
+                   #$openblas)
+                  (("\\$\\(KALDI_ROOT\\)\\/libs")
+                   #$(file-append kaldi "/lib")))))
+            (replace 'install
+              (lambda* (#:key outputs #:allow-other-keys)
+                (let* ((out (assoc-ref outputs "out"))
+                       (lib (string-append out "/lib"))
+                       (src (string-append out "/src")))
+                  (mkdir-p lib)
+                  (mkdir-p src)
+                  (install-file "libvosk.so" lib)
+                  (for-each
+                   (lambda (x) (install-file x src))
+                   (find-files "." "\\.h$"))))))))
+      (inputs (list kaldi openfst lapack openblas))
+      (home-page "https://alphacephei.com/vosk")
+      (synopsis "Speech recognition toolkit based on @code{kaldi}")
+      (description "\
+This package provides a speech recognition toolkit based on @code{kaldi}.  It
+supports more than 20 languages and dialects - English, Indian English,
+German, French, Spanish, Portuguese, Chinese, Russian, Turkish, Vietnamese,
+Italian, Dutch, Catalan, Arabic, Greek, Farsi, Filipino, Ukrainian, Kazakh,
+Swedish, Japanese, Esperanto, Hindi, Czech, Polish. The program works offline,
+even on lightweight devices.  Portable per-language models are about 50Mb each,
+and there are much bigger and precise models available.
+
+Vosk API provides a streaming API allowing to use it `on-the-fly' and bindings
+for different programming languages.  It allows quick reconfiguration of
+vocabulary for better accuracy, and supports speaker identification beside
+simple speech recognition.")
+      (license license:asl2.0))))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 11:59:03 GMT) Full text and rfc822 format available.

Message #20 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH 5/6] gnu: Add python-nerd-dictation.
Date: Wed, 28 Sep 2022 13:57:54 +0200
* gnu/packages/machine-learning.scm (python-nerd-dictation): New variable.
---
 gnu/packages/machine-learning.scm | 34 +++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index cbbc80db1c..3fec07e6a1 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -3599,3 +3599,37 @@ (define-public python-vosk
                  "from .vosk_cffi import ffi, lib")
                 (("_c\\.")
                  "lib.")))))))))
+
+(define-public python-nerd-dictation
+  (let* ((commit "53ab129a5ee0f8b5df284e8cf2229219b732c59e")
+         (revision "0"))
+    (package
+      (name "python-nerd-dictation")
+      (version (git-version "0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/ideasman42/nerd-dictation")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "184qijiva1h1x00dzicik0yzgh78pq2lqr5fkgicgp26mkarlyhc"))))
+      (build-system python-build-system)
+      (arguments
+       '(#:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'chdir
+             (lambda _ (chdir "package/python"))))))
+      (propagated-inputs (list python-vosk))
+      (inputs (list pulseaudio xdotool))
+      (home-page "https://github.com/ideasman42/nerd-dictation")
+      (synopsis "Offline speech-to-text for desktop Linux")
+      (description "\
+This package provides simple access speech to text for using in
+Linux without being tied to a desktop environment, using the @code{vosk-api}.
+The user configuration lets you manipulate text using Python string
+operations.  It has zero overhead, as this relies on manual activation and
+there are no background processes.  Dictation is accessed manually with
+@code{nerd-dictation begin} and @code{nerd-dictation end} commands.")
+      (license license:gpl3+))))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 11:59:03 GMT) Full text and rfc822 format available.

Message #23 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH 6/6] gnu: Add python-nerd-dictation/wayland.
Date: Wed, 28 Sep 2022 13:57:55 +0200
* gnu/packages/machine-learning.scm (python-nerd-dictation/wayland): New variable.
---
 gnu/packages/machine-learning.scm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 3fec07e6a1..12c5586aa8 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -45,6 +45,7 @@ (define-module (gnu packages machine-learning)
   #:use-module (guix build-system ocaml)
   #:use-module (guix build-system python)
   #:use-module (guix build-system r)
+  #:use-module (guix build-system trivial)
   #:use-module (guix git-download)
   #:use-module (gnu packages)
   #:use-module (gnu packages adns)
@@ -103,6 +104,7 @@ (define-module (gnu packages machine-learning)
   #:use-module (gnu packages video)
   #:use-module (gnu packages web)
   #:use-module (gnu packages xml)
+  #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xorg)
   #:use-module (ice-9 match))
 
@@ -3633,3 +3635,28 @@ (define-public python-nerd-dictation
 there are no background processes.  Dictation is accessed manually with
 @code{nerd-dictation begin} and @code{nerd-dictation end} commands.")
       (license license:gpl3+))))
+
+(define-public python-nerd-dictation/wayland
+  (package
+    (inherit python-nerd-dictation)
+    (name "python-nerd-dictation-wayland")
+    (inputs (list bash-minimal python-nerd-dictation sox ydotool))
+    (build-system trivial-build-system)
+    (arguments
+     (list
+      #:modules '((guix build utils))
+      #:builder
+      #~(begin
+          (use-modules (guix build utils))
+          (let* ((out (assoc-ref %outputs "out"))
+                 (exe (string-append out "/bin/nerd-dictation")))
+
+            (mkdir-p (dirname exe))
+            (call-with-output-file exe
+              (lambda (port)
+                (format port "#!~a
+exec ~a $@ --input=SOX --simulate-input-tool=YDOTOOL"
+                        #$(file-append bash-minimal "/bin/bash")
+                        #$(file-append python-nerd-dictation
+                                       "/bin/nerd-dictation"))))
+            (chmod exe #o555)))))))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 17:59:02 GMT) Full text and rfc822 format available.

Message #26 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
To: 58140 <at> debbugs.gnu.org
Subject: Re: Simple offline text-to-speech incoming !
Date: Wed, 28 Sep 2022 19:58:34 +0200
[Message part 1 (text/plain, inline)]
Nicolas Graves wrote:
> 2) Vosk-API relies on models. I was thinking about the opportunity to
> also package these models in guix, since it's only a copy and would
> make it more guixy. BUT the big downside is that some of these models
> are huge (~2G). Is there a way to not provide substitutes in some
> such cases ? Maybe that's a thing we can do for all packages relying
> on a copy-build-system or something like that ?

Some free software games also take similar amount of space because they
have a big data set, and often compression doesn't work on already
compressed data like lossless pictures and so on.

Wesnoth that is not that big takes about 600M:
> $ du -hs /gnu/store/1gn6xij7nngy02pqvld21qmshqspmarg-wesnoth-1.16.1
> 590M	/gnu/store/1gn6xij7nngy02pqvld21qmshqspmarg-wesnoth-1.16.1

If we take 0ad its data take way more space:
> $ du -hs
> /gnu/store/95rhwdnxyxvycjn1yp25qy5v4x255l8r-0ad-data-0.0.25b-alpha
> 3.2G
> /gnu/store/95rhwdnxyxvycjn1yp25qy5v4x255l8r-0ad-data-0.0.25b-alpha

Though for some reasons the substitute compression somehow works on its
data because it takes only 1.15GiB to download:
> $ guix package -i 0ad
> The following package will be installed:
>    0ad 0.0.25b-alpha
> 
[...]
>  0ad-data-0.0.25b-alpha  1.15GiB

Xonotic is in the middle: its data is about 1GiB to download:
> xonotic-data-0.8.5  1.08GiB
And once installed it also takes about 1GiB:
> $ du -hs
> /gnu/store/iw1dg3inm4y6z6ch5y3bfziapnc978j7-xonotic-data-0.8.5
> 1.1G
> /gnu/store/iw1dg3inm4y6z6ch5y3bfziapnc978j7-xonotic-data-0.8.5

In your case since you don't build the data it will probably not be
rebuilt often because the dependencies won't change often.

Though I'd be very interested to know if there is some limits or how
to handle way bigger data as I'm interested in finding how to handle
things like the Wikipedia English file for kiwix which takes 80GiB or
more.

Denis.
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 20:08:01 GMT) Full text and rfc822 format available.

Message #29 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>, 58140 <at> debbugs.gnu.org
Subject: Re: [bug#58140] Simple offline text-to-speech incoming !
Date: Wed, 28 Sep 2022 22:07:15 +0200
> In your case since you don't build the data it will probably not be
> rebuilt often because the dependencies won't change often.

Yes that's true but I do find it unecessary, because it uses a
copy-build-system which only unzips a big zipbomb. Plus in the case
where we want to provide several models for several languages, it can
amount to ~15 models *2Go, which is indeed a lot.

Maybe that could be done somehow through the proprieties alist? Make
something like cuirass ignoring certain files based on a propriety
keyword?

-- 
Best regards,
Nicolas Graves




Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 21:06:03 GMT) Full text and rfc822 format available.

Message #32 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Nicolas Graves <ngraves <at> ngraves.fr>, 58140 <at> debbugs.gnu.org
Subject: Re: [bug#58140] [PATCH 2/6] gnu: Add kaldi-for-vosk.
Date: Wed, 28 Sep 2022 23:05:26 +0200
[Message part 1 (text/plain, inline)]
>+            (add-after 'unpack 'chdir
>+              (lambda _ (chdir "src") #t))

Trailing #t haven't been required since a long time.

On 28-09-2022 13:57, Nicolas Graves via Guix-patches via wrote:
> +                (when (not (or (string-prefix? "x86_64" system)
> +                               (string-prefix? "i686" system)))
> +                  (substitute* "makefiles/linux_openblas.mk"
> +                    (("-msse -msse2") "")))

You are testing for the system it is being compiled on ('system'), not 
the system it is being compiled for ('target').  For cross-compilation, 
usually the latter is required.  You may find
#$@(if (target-x86?) #~((substitute* ...) #~())
useful, it automatically handles cross-compilation, both 32-bit and 
64-bit, a hypothetical i786 it it ever starts existing, i586 if we ever 
lower the requirements ...

> +                     (string-append "OPENBLASROOT=\"" #$openblas "\""))

#$PACKAGE does not compose with --with-input.  I recommend doing 
something like
(dirname (dirname (search-input-file inputs "lib/libblas.so")))
instead.  Likewise for other uses of #$PACKAGE.

> +                  (setenv "OPENFST_VER" #$(package-version openfst))

I recommend referring to 'openfst' with 'this-package-input', that way 
when --with-input or --with-latest is used to change it to something 
with a different version, the version should still be detetcxed properly.

> +                (substitute* "./Makefile"
> +                  (("USE_SHARED\\?=0")
> +                   "USE_SHARED?=1")

IIUC, ?=0 means that 0 is the default, you can override it by setting 
#:make-flags.

> dialects - English, 

I think one of the special dashes (en dashes, em dashes, figure dash? 
Don't know which one) would be appropriate here.

> +(define-public python-nerd-dictation
> +  (let* ((commit "53ab129a5ee0f8b5df284e8cf2229219b732c59e")
> +         (revision "0"))
> +    (package
> +      (name "python-nerd-dictation")
> +      (version (git-version "0" revision commit))

Going by <https://github.com/ideasman42/nerd-dictation>, 'python-' is 
not part of its name, you can drop the prefix AFAICT.

> +      (synopsis "Offline speech-to-text for desktop Linux")

If it's Linux only, you can use the 'supported-systems' field for that, 
see (gnu packages linux) for examples.

> +                        #$(file-append bash-minimal "/bin/bash")

You can use 'search-input-file' to avoid depending on input labels.

> +          (let* ((out (assoc-ref %outputs "out"))

If you are using G-exps, you can replace (assoc-ref %outputs "out") with 
its G-exp equivalent #$output.

> +(define openfst-for-vosk
> +  (package
> +    (inherit openfst)
> +    (version "1.8.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "http://www.openfst.org/twiki/pub/FST/"
> +                           "FstDownload/openfst-" version ".tar.gz"))
> +       (sha256
> +        (base32 "0h2lfhhihg63b804hrcljnkggijbjmp84i5g8q735wb09y9z2c4p"))))

Why select an older version?  Would keeping the original (and more 
up-to-date) version work?  To avoid a name conflict between the openfst 
(which would be inconvenient for "guix show", "guix install", "guix 
shell"), you can override the 'name' field.

Greetings,
Maxime.
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 21:31:02 GMT) Full text and rfc822 format available.

Message #35 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Subject: [PATCH 6/6 v2] gnu: Add python-nerd-dictation/wayland.
Date: Wed, 28 Sep 2022 23:30:02 +0200
* gnu/packages/machine-learning.scm (python-nerd-dictation/wayland): New variable.
---
 gnu/packages/machine-learning.scm | 34 +++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 3fec07e6a1..4846a9103e 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -45,6 +45,7 @@ (define-module (gnu packages machine-learning)
   #:use-module (guix build-system ocaml)
   #:use-module (guix build-system python)
   #:use-module (guix build-system r)
+  #:use-module (guix build-system trivial)
   #:use-module (guix git-download)
   #:use-module (gnu packages)
   #:use-module (gnu packages adns)
@@ -103,6 +104,7 @@ (define-module (gnu packages machine-learning)
   #:use-module (gnu packages video)
   #:use-module (gnu packages web)
   #:use-module (gnu packages xml)
+  #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xorg)
   #:use-module (ice-9 match))

@@ -3633,3 +3635,35 @@ (define-public python-nerd-dictation
 there are no background processes.  Dictation is accessed manually with
 @code{nerd-dictation begin} and @code{nerd-dictation end} commands.")
       (license license:gpl3+))))
+
+(define-public python-nerd-dictation/wayland
+  (package
+    (inherit python-nerd-dictation)
+    (name "python-nerd-dictation-wayland")
+    (inputs (list bash-minimal python-nerd-dictation sox ydotool))
+    (build-system trivial-build-system)
+    (arguments
+     (list
+      #:modules '((guix build utils))
+      #:builder
+      #~(begin
+          (use-modules (guix build utils))
+          (let* ((out (assoc-ref %outputs "out"))
+                 (exe (string-append out "/bin/nerd-dictation")))
+
+            (mkdir-p (dirname exe))
+            (call-with-output-file exe
+              (lambda (port)
+                (format port "#!~a
+if [ \"$1\" = begin ]
+  then
+    exec ~a $@ --input=SOX --simulate-input-tool=YDOTOOL
+  else
+    exec ~a $@
+fi"
+                        #$(file-append bash-minimal "/bin/bash")
+                        #$(file-append python-nerd-dictation
+                                       "/bin/nerd-dictation")
+                        #$(file-append python-nerd-dictation
+                                       "/bin/nerd-dictation"))))
+            (chmod exe #o555)))))))
--
2.37.3


<#secure method=pgpmime mode=sign>

--
Best regards,
Nicolas Graves




Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Wed, 28 Sep 2022 21:40:02 GMT) Full text and rfc822 format available.

Message #38 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Nicolas Graves <ngraves <at> ngraves.fr>, 58140 <at> debbugs.gnu.org
Subject: Re: [bug#58140] [PATCH 6/6 v2] gnu: Add python-nerd-dictation/wayland.
Date: Wed, 28 Sep 2022 23:39:00 +0200
[Message part 1 (text/plain, inline)]

On 28-09-2022 23:30, Nicolas Graves via Guix-patches via wrote:
> +    (inputs (list bash-minimal python-nerd-dictation sox ydotool))
> +    (build-system trivial-build-system)
> +    (arguments
> +     (list
> +      #:modules '((guix build utils))
> +      #:builder
> +      #~(begin
> +          (use-modules (guix build utils))
> +          (let* ((out (assoc-ref %outputs "out"))
> +                 (exe (string-append out "/bin/nerd-dictation")))
> +
> +            (mkdir-p (dirname exe))
> +            (call-with-output-file exe
> +              (lambda (port)
> +                (format port "#!~a
> +if [ \"$1\" = begin ]
> +  then
> +    exec ~a $@ --input=SOX --simulate-input-tool=YDOTOOL
> +  else
> +    exec ~a $@
> +fi"
> +                        #$(file-append bash-minimal "/bin/bash")
> +                        #$(file-append python-nerd-dictation
> +                                       "/bin/nerd-dictation")
> +                        #$(file-append python-nerd-dictation
> +                                       "/bin/nerd-dictation"))))
> +            (chmod exe #o555)))))))

The input 'ydotool' seems to be unused here, you might need to patch it 
in, or failing that, propagate it.

(Also see previous reply, I think I replied to the v1 instead of the v2 
previously?)

Greetings,
Maxime.
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 06:45:01 GMT) Full text and rfc822 format available.

Message #41 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: "(" <paren <at> disroot.org>
To: "Maxime Devos" <maximedevos <at> telenet.be>, "Nicolas Graves"
 <ngraves <at> ngraves.fr>, <58140 <at> debbugs.gnu.org>
Subject: Re: [bug#58140] [PATCH 2/6] gnu: Add kaldi-for-vosk.
Date: Thu, 29 Sep 2022 07:44:26 +0100
On Wed Sep 28, 2022 at 10:05 PM BST, Maxime Devos wrote:
> > +                     (string-append "OPENBLASROOT=\"" #$openblas "\""))
>
> #$PACKAGE does not compose with --with-input.  I recommend doing 
> something like
> (dirname (dirname (search-input-file inputs "lib/libblas.so")))
> instead.  Likewise for other uses of #$PACKAGE.

Why not ``#$(this-package-input openblas)''?

    -- (




Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 08:21:02 GMT) Full text and rfc822 format available.

Message #44 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: Maxime Devos <maximedevos <at> telenet.be>, 58140 <at> debbugs.gnu.org
Subject: Re: [bug#58140] [PATCH 2/6] gnu: Add kaldi-for-vosk.
Date: Thu, 29 Sep 2022 10:20:47 +0200
> Trailing #t haven't been required since a long time.
A big part of the code, and in particular old forms, come from the code
of the current kaldi package. Should I also change the same code chunks
for kaldi in an additional patch ?

> If it's Linux only, you can use the 'supported-systems' field for that,
> see (gnu packages linux) for examples.
I don't really know that. Ydotool probably only work on Linux, since
they rely on linux keycodes. I don't know for X. Maybe someone should
test. Should I suppose it only supports Linux by default?

> Why select an older version?  Would keeping the original (and more
> up-to-date) version work?  To avoid a name conflict between the openfst
> (which would be inconvenient for "guix show", "guix install", "guix
> shell"), you can override the 'name' field.

No, it doesn't work and that's the reason why I used this version. It
might however work with the version that's present for kaldi (1.7.3
IIRC), I can test that. But the flags aren't the same, so we probably
should do another package anyway.

I didn't change the name, but I also haven't exported the variable
(define instead of define-public). I expected the package to not be
available through "guix search" or "guix install". Is that OK?

I've done a V3, testing it before sending. 

--
Best regards,
Nicolas Graves




Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 09:01:02 GMT) Full text and rfc822 format available.

Message #47 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH v3 1/6] gnu: Add openfst-for-vosk.
Date: Thu, 29 Sep 2022 11:00:17 +0200
* gnu/packages/machine-learning.scm (openfst-for-vosk): New variable.
---
 gnu/packages/machine-learning.scm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index e702e499fc..3ad907e0c9 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -583,6 +583,22 @@ (define-public openfst-1.7.3
     (arguments '(#:configure-flags '("--enable-ngram-fsts" "CXXFLAGS=-std=c++14")
                  #:make-flags '("CXXFLAGS=-std=c++14")))))
 
+(define openfst-for-vosk
+  (package
+    (inherit openfst)
+    (version "1.8.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "http://www.openfst.org/twiki/pub/FST/"
+                           "FstDownload/openfst-" version ".tar.gz"))
+       (sha256
+        (base32 "0h2lfhhihg63b804hrcljnkggijbjmp84i5g8q735wb09y9z2c4p"))))
+    (arguments
+     '(#:configure-flags
+       '("--enable-shared" "--enable-far" "--enable-ngram-fsts"
+         "--enable-lookahead-fsts" "--with-pic" "--disable-bin")))))
+
 (define-public shogun
   (package
     (name "shogun")
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 09:01:02 GMT) Full text and rfc822 format available.

Message #50 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH v3 2/6] gnu: Add kaldi-for-vosk.
Date: Thu, 29 Sep 2022 11:00:18 +0200
* gnu/packages/machine-learning.scm (kaldi-for-vosk): New variable.
---
 gnu/packages/machine-learning.scm | 99 +++++++++++++++++++++++++++++++
 1 file changed, 99 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 3ad907e0c9..b444352337 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1596,6 +1596,105 @@ (define-public kaldi
 written in C++.")
       (license license:asl2.0))))
 
+(define kaldi-for-vosk
+  (let* ((commit "6417ac1dece94783e80dfbac0148604685d27579")
+         (revision "0")
+         (openfst openfst-for-vosk))
+    (package
+      (inherit kaldi)
+      (name "kaldi")
+      (version (git-version "0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/alphacep/kaldi")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "04xw2dpfvpla8skpk08azmgr9k97cd8hn83lj4l85q165gbzql4s"))))
+      (inputs
+       (list alsa-lib
+             ;; `(,gfortran "lib") ;; replaced by lapack
+             lapack
+             glib
+             gstreamer
+             jack-1
+             openblas
+             openfst
+             portaudio
+             python))
+      (arguments
+       (list
+        #:test-target "test"
+        #:make-flags ''("online2" "lm" "rnnlm")
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'chdir
+              (lambda _ (chdir "src")))
+            (replace 'configure
+              (lambda _
+                (let* ((portaudio #$(this-package-input "portaudio"))
+                       (lapack    #$(this-package-input "lapack"))
+                       (openfst   #$(this-package-input "openfst"))
+                       (openblas  #$(this-package-input "openblas")))
+                  #$@(if (target-x86?)
+                         '()
+                         #~((substitute* "makefiles/linux_openblas.mk"
+                              (("-msse -msse2") ""))))
+                  (substitute* "makefiles/default_rules.mk"
+                    (("/bin/bash") (which "bash")))
+                  (substitute* "Makefile"
+                    (("ext_depend: check_portaudio")
+                     "ext_depend:"))
+                  (substitute* '("online/Makefile"
+                                 "onlinebin/Makefile"
+                                 "gst-plugin/Makefile")
+                    (("../../tools/portaudio/install")
+                     portaudio))
+                  (substitute* "matrix/Makefile"     ;temporary test bypass
+                    (("matrix-lib-test sparse-matrix-test") ""))
+
+                  ;; This `configure' script doesn't support variables passed as
+                  ;; arguments, nor does it support "prefix".
+                  (substitute* "configure"
+                    (("check_for_slow_expf;") "")
+                    ;; This affects the RPATH and also serves as the installation
+                    ;; directory.
+                    (("KALDILIBDIR=`pwd`/lib")
+                     (string-append "KALDILIBDIR=" #$output "/lib"))
+                    (("OPENBLASROOT=\\\"\\$\\(rel2abs ..\\/tools\\/OpenBLAS\\/install\\)\\\"")
+                     (string-append "OPENBLASROOT=\"" openblas "\""))
+                    (("-L\\$OPENBLASLIBDIR -l:libopenblas.a -l:libblas.a -l:liblapack.a -l:libf2c.a")
+                     (string-append "-L$OPENBLASLIBDIR -lopenblas "
+                                    "-L" lapack "/lib -lblas -llapack")))
+                  (mkdir-p #$output) ; must exist
+                  (setenv "CONFIG_SHELL" (which "bash"))
+                  (setenv "OPENFST_VER" #$(package-version openfst))
+                  (invoke "./configure"
+                          "--use-cuda=no"
+                          "--mathlib=OPENBLAS_CLAPACK"
+                          "--shared"
+                          (string-append "--fst-root=" openfst)))))
+            (add-after 'configure 'optimize-build
+                       (lambda _ (substitute* "kaldi.mk" ((" -O1") " -O3"))))
+            (replace 'install
+              (lambda _
+                (let* ((inc (string-append #$output "/include"))
+                       (lib (string-append #$output "/lib")))
+                  ;; The build phase installed symlinks to the actual
+                  ;; libraries.  Install the actual targets.
+                  (for-each (lambda (file)
+                              (let ((target (readlink file)))
+                                (delete-file file)
+                                (install-file target lib)))
+                            (find-files lib "\\.so"))
+                  ;; Install headers
+                  (for-each (lambda (file)
+                              (let ((target-dir (string-append inc "/" (dirname file))))
+                                (install-file file target-dir)))
+                            (find-files "." "\\.h")))))))))))
+
 (define-public gst-kaldi-nnet2-online
   (let ((commit "cb227ef43b66a9835c14eb0ad39e08ee03c210ad")
         (revision "2"))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 09:01:02 GMT) Full text and rfc822 format available.

Message #53 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH v3 3/6] gnu: Add vosk-api.
Date: Thu, 29 Sep 2022 11:00:19 +0200
* gnu/packages/machine-learning.scm (vosk-api): New variable.
---
 gnu/packages/machine-learning.scm | 80 ++++++++++++++++++++++++++++++-
 1 file changed, 78 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index b444352337..b5e17462eb 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1615,8 +1615,7 @@ (define kaldi-for-vosk
           (base32 "04xw2dpfvpla8skpk08azmgr9k97cd8hn83lj4l85q165gbzql4s"))))
       (inputs
        (list alsa-lib
-             ;; `(,gfortran "lib") ;; replaced by lapack
-             lapack
+             lapack ;; compared to base kaldi, replacing `(,gfortran "lib")
              glib
              gstreamer
              jack-1
@@ -3486,3 +3485,80 @@ (define-public python-pyro-ppl
      "This package provides a Python library for probabilistic modeling and
 inference.")
     (license license:asl2.0)))
+
+(define-public vosk-api
+  (let* ((openfst openfst-for-vosk)
+         (kaldi kaldi-for-vosk))
+    (package
+      (name "vosk-api")
+      (version "0.3.43")
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/alphacep/vosk-api")
+               (commit (string-append "v" version))))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "0xmp8i140c2hd3rj9dap8a2rnsvzb1k9hnqm12xzbaxrw73rkc29"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list
+        #:tests? #f
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'chdir
+              (lambda _ (chdir "src")))
+            (replace 'configure
+              (lambda _
+                (let* ((lapack   #$(this-package-input "lapack"))
+                       (openfst  #$(this-package-input "openfst"))
+                       (openblas #$(this-package-input "openblas"))
+                       (kaldi    #$(this-package-input "kaldi")))
+                  (substitute* "./Makefile"
+                    (("USE_SHARED\\?=0")
+                     "USE_SHARED?=1")
+                    (("-DFST_NO_DYNAMIC_LINKING")
+                     "")
+                    (("-lopenblas -llapack -lblas -lf2c")
+                     (string-append
+                      "-L" openblas "/lib " "-lopenblas "
+                      "-L" lapack "/lib " "-llapack -lblas "))
+                    (("-lfst -lfstngram")
+                     (string-append
+                      "-L" openfst "/lib " "-lfst -lfstngram "))
+                    (("\\$\\(HOME\\)\\/travis\\/kaldi")
+                     (string-append kaldi "/include"))
+                    (("\\$\\(KALDI_ROOT\\)\\/tools\\/openfst")
+                     openfst)
+                    (("\\$\\(KALDI_ROOT\\)\\/tools\\/OpenBLAS\\/install")
+                     openblas)
+                    (("\\$\\(KALDI_ROOT\\)\\/libs")
+                     (string-append kaldi "/lib"))))))
+            (replace 'install
+              (lambda _
+                (let* ((lib (string-append #$output "/lib"))
+                       (src (string-append #$output "/src")))
+                  (mkdir-p lib)
+                  (mkdir-p src)
+                  (install-file "libvosk.so" lib)
+                  (for-each
+                   (lambda (x) (install-file x src))
+                   (find-files "." "\\.h$"))))))))
+      (inputs (list kaldi openfst lapack openblas))
+      (home-page "https://alphacephei.com/vosk")
+      (synopsis "Speech recognition toolkit based on @code{kaldi}")
+      (description "\
+This package provides a speech recognition toolkit based on @code{kaldi}.  It
+supports more than 20 languages and dialects - English, Indian English,
+German, French, Spanish, Portuguese, Chinese, Russian, Turkish, Vietnamese,
+Italian, Dutch, Catalan, Arabic, Greek, Farsi, Filipino, Ukrainian, Kazakh,
+Swedish, Japanese, Esperanto, Hindi, Czech, Polish. The program works offline,
+even on lightweight devices.  Portable per-language models are about 50Mb each,
+and there are much bigger and precise models available.
+
+Vosk API provides a streaming API allowing to use it `on-the-fly' and bindings
+for different programming languages.  It allows quick reconfiguration of
+vocabulary for better accuracy, and supports speaker identification beside
+simple speech recognition.")
+      (license license:asl2.0))))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 09:02:02 GMT) Full text and rfc822 format available.

Message #56 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH v3 5/6] gnu: Add python-nerd-dictation.
Date: Thu, 29 Sep 2022 11:00:21 +0200
* gnu/packages/machine-learning.scm (python-nerd-dictation): New variable.
---
 gnu/packages/machine-learning.scm | 34 +++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 34b82aa101..f2c9b8dace 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -3602,3 +3602,37 @@ (define-public python-vosk
                  "from .vosk_cffi import ffi, lib")
                 (("_c\\.")
                  "lib.")))))))))
+
+(define-public nerd-dictation
+  (let* ((commit "53ab129a5ee0f8b5df284e8cf2229219b732c59e")
+         (revision "0"))
+    (package
+      (name "nerd-dictation")
+      (version (git-version "0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/ideasman42/nerd-dictation")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "184qijiva1h1x00dzicik0yzgh78pq2lqr5fkgicgp26mkarlyhc"))))
+      (build-system python-build-system)
+      (arguments
+       '(#:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'chdir
+             (lambda _ (chdir "package/python"))))))
+      (propagated-inputs (list python-vosk))
+      (inputs (list pulseaudio xdotool))
+      (home-page "https://github.com/ideasman42/nerd-dictation")
+      (synopsis "Offline speech-to-text for desktop Linux")
+      (description "\
+This package provides simple access speech to text for using in
+Linux without being tied to a desktop environment, using the @code{vosk-api}.
+The user configuration lets you manipulate text using Python string
+operations.  It has zero overhead, as this relies on manual activation and
+there are no background processes.  Dictation is accessed manually with
+@code{nerd-dictation begin} and @code{nerd-dictation end} commands.")
+      (license license:gpl3+))))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 09:02:02 GMT) Full text and rfc822 format available.

Message #59 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH v3 6/6] gnu: Add python-nerd-dictation/wayland.
Date: Thu, 29 Sep 2022 11:00:22 +0200
* gnu/packages/machine-learning.scm (python-nerd-dictation/wayland): New variable.
---
 gnu/packages/machine-learning.scm | 35 +++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index f2c9b8dace..c0d6ccfd19 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -45,6 +45,7 @@ (define-module (gnu packages machine-learning)
   #:use-module (guix build-system ocaml)
   #:use-module (guix build-system python)
   #:use-module (guix build-system r)
+  #:use-module (guix build-system trivial)
   #:use-module (guix git-download)
   #:use-module (gnu packages)
   #:use-module (gnu packages adns)
@@ -103,6 +104,7 @@ (define-module (gnu packages machine-learning)
   #:use-module (gnu packages video)
   #:use-module (gnu packages web)
   #:use-module (gnu packages xml)
+  #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xorg)
   #:use-module (ice-9 match))
 
@@ -3636,3 +3638,36 @@ (define-public nerd-dictation
 there are no background processes.  Dictation is accessed manually with
 @code{nerd-dictation begin} and @code{nerd-dictation end} commands.")
       (license license:gpl3+))))
+
+(define-public nerd-dictation/wayland
+  (package
+    (inherit nerd-dictation)
+    (name "nerd-dictation-wayland")
+    (inputs (list bash-minimal nerd-dictation))
+    (propagated-inputs (list ydotool sox))
+    (build-system trivial-build-system)
+    (arguments
+     (list
+      #:modules '((guix build utils))
+      #:builder
+      #~(begin
+          (use-modules (guix build utils))
+          (let* ((exe (string-append #$output "/bin/nerd-dictation"))
+                 (original-exe #$(file-append nerd-dictation
+                                              "/bin/nerd-dictation"))
+                 (bash #$(this-package-input "bash-minimal"))
+                 (bash-exe (string-append bash "/bin/bash")))
+            (mkdir-p (dirname exe))
+            (call-with-output-file exe
+              (lambda (port)
+                (format port "#!~a
+if [ \"$1\" = begin ]
+  then
+    exec ~a $@ --input=SOX --simulate-input-tool=YDOTOOL
+  else
+    exec ~a $@
+fi"
+                        bash-exe
+                        original-exe
+                        original-exe)))
+            (chmod exe #o555)))))))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 09:02:03 GMT) Full text and rfc822 format available.

Message #62 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH v3 4/6] gnu: Add python-vosk.
Date: Thu, 29 Sep 2022 11:00:20 +0200
* gnu/packages/machine-learning.scm (python-vosk): New variable.
---
 gnu/packages/machine-learning.scm | 40 +++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index b5e17462eb..34b82aa101 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -3562,3 +3562,43 @@ (define-public vosk-api
 vocabulary for better accuracy, and supports speaker identification beside
 simple speech recognition.")
       (license license:asl2.0))))
+
+(define-public python-vosk
+  (package
+    (inherit vosk-api)
+    (name "python-vosk")
+    (build-system python-build-system)
+    (propagated-inputs
+     (list python-cffi python-requests python-tqdm python-srt python-websockets))
+    (inputs (list vosk-api))
+    (arguments
+     (list
+      #:tests? #f  ;; TODO There are tests but not run through Makefile.
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'config
+            (lambda _
+              (chdir "python")
+              (setenv "VOSK_SOURCE" #$vosk-api)))
+          (add-before 'build 'from-abi-to-api
+            (lambda _
+              (substitute* "vosk_builder.py"
+                (("ffibuilder\\.set_source\\(\"vosk.vosk_cffi\", None\\)")
+                 (string-append
+                  "ffibuilder.set_source(\"vosk.vosk_cffi\", "
+                  "r\"\"\"\n#include<vosk_api.h>\n#include<Python.h>\"\"\",\n\t"
+                  "library_dirs=["
+                  "'" #$vosk-api "/lib'"
+                  "],\n\t"
+                  "libraries=['vosk', 'python3.9'],\n\t"
+                  "include_dirs=["
+                  "'" #$vosk-api "/src'" "])")))
+              (substitute* "vosk/__init__.py"
+                (("_c = open_dll\\(\\)")
+                 "")
+                (("_ffi")
+                 "ffi")
+                (("from \\.vosk_cffi import ffi as ffi")
+                 "from .vosk_cffi import ffi, lib")
+                (("_c\\.")
+                 "lib.")))))))))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 09:03:02 GMT) Full text and rfc822 format available.

Message #65 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH v4 1/2] gnu: Add nerd-dictation.
Date: Thu, 29 Sep 2022 11:02:02 +0200
* gnu/packages/machine-learning.scm (nerd-dictation): New variable.
---
 gnu/packages/machine-learning.scm | 34 +++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 34b82aa101..f2c9b8dace 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -3602,3 +3602,37 @@ (define-public python-vosk
                  "from .vosk_cffi import ffi, lib")
                 (("_c\\.")
                  "lib.")))))))))
+
+(define-public nerd-dictation
+  (let* ((commit "53ab129a5ee0f8b5df284e8cf2229219b732c59e")
+         (revision "0"))
+    (package
+      (name "nerd-dictation")
+      (version (git-version "0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/ideasman42/nerd-dictation")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "184qijiva1h1x00dzicik0yzgh78pq2lqr5fkgicgp26mkarlyhc"))))
+      (build-system python-build-system)
+      (arguments
+       '(#:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'chdir
+             (lambda _ (chdir "package/python"))))))
+      (propagated-inputs (list python-vosk))
+      (inputs (list pulseaudio xdotool))
+      (home-page "https://github.com/ideasman42/nerd-dictation")
+      (synopsis "Offline speech-to-text for desktop Linux")
+      (description "\
+This package provides simple access speech to text for using in
+Linux without being tied to a desktop environment, using the @code{vosk-api}.
+The user configuration lets you manipulate text using Python string
+operations.  It has zero overhead, as this relies on manual activation and
+there are no background processes.  Dictation is accessed manually with
+@code{nerd-dictation begin} and @code{nerd-dictation end} commands.")
+      (license license:gpl3+))))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 09:03:02 GMT) Full text and rfc822 format available.

Message #68 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 58140 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH v4 2/2] gnu: Add nerd-dictation/wayland.
Date: Thu, 29 Sep 2022 11:02:03 +0200
* gnu/packages/machine-learning.scm (nerd-dictation/wayland): New variable.
---
 gnu/packages/machine-learning.scm | 35 +++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index f2c9b8dace..c0d6ccfd19 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -45,6 +45,7 @@ (define-module (gnu packages machine-learning)
   #:use-module (guix build-system ocaml)
   #:use-module (guix build-system python)
   #:use-module (guix build-system r)
+  #:use-module (guix build-system trivial)
   #:use-module (guix git-download)
   #:use-module (gnu packages)
   #:use-module (gnu packages adns)
@@ -103,6 +104,7 @@ (define-module (gnu packages machine-learning)
   #:use-module (gnu packages video)
   #:use-module (gnu packages web)
   #:use-module (gnu packages xml)
+  #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xorg)
   #:use-module (ice-9 match))
 
@@ -3636,3 +3638,36 @@ (define-public nerd-dictation
 there are no background processes.  Dictation is accessed manually with
 @code{nerd-dictation begin} and @code{nerd-dictation end} commands.")
       (license license:gpl3+))))
+
+(define-public nerd-dictation/wayland
+  (package
+    (inherit nerd-dictation)
+    (name "nerd-dictation-wayland")
+    (inputs (list bash-minimal nerd-dictation))
+    (propagated-inputs (list ydotool sox))
+    (build-system trivial-build-system)
+    (arguments
+     (list
+      #:modules '((guix build utils))
+      #:builder
+      #~(begin
+          (use-modules (guix build utils))
+          (let* ((exe (string-append #$output "/bin/nerd-dictation"))
+                 (original-exe #$(file-append nerd-dictation
+                                              "/bin/nerd-dictation"))
+                 (bash #$(this-package-input "bash-minimal"))
+                 (bash-exe (string-append bash "/bin/bash")))
+            (mkdir-p (dirname exe))
+            (call-with-output-file exe
+              (lambda (port)
+                (format port "#!~a
+if [ \"$1\" = begin ]
+  then
+    exec ~a $@ --input=SOX --simulate-input-tool=YDOTOOL
+  else
+    exec ~a $@
+fi"
+                        bash-exe
+                        original-exe
+                        original-exe)))
+            (chmod exe #o555)))))))
-- 
2.37.3





Information forwarded to guix-patches <at> gnu.org:
bug#58140; Package guix-patches. (Thu, 29 Sep 2022 09:33:01 GMT) Full text and rfc822 format available.

Message #71 received at 58140 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Nicolas Graves <ngraves <at> ngraves.fr>, 58140 <at> debbugs.gnu.org
Subject: Re: [bug#58140] [PATCH 2/6] gnu: Add kaldi-for-vosk.
Date: Thu, 29 Sep 2022 11:32:45 +0200
[Message part 1 (text/plain, inline)]

On 29-09-2022 10:20, Nicolas Graves wrote:
> 
>> Trailing #t haven't been required since a long time.
> A big part of the code, and in particular old forms, come from the code
> of the current kaldi package. Should I also change the same code chunks
> for kaldi in an additional patch ?

That would be nice, but not required I'd say.

>> If it's Linux only, you can use the 'supported-systems' field for that,
>> see (gnu packages linux) for examples.
> I don't really know that. Ydotool probably only work on Linux, since
> they rely on linux keycodes. I don't know for X. Maybe someone should
> test. Should I suppose it only supports Linux by default?

I think that usually 'if it works on Linux, it probably can work on 
similar-ish systems as well’ is a reasonable assumption, but perhaps 
with the keycodes, it isn't.

However, if the problem is in 'ydotool', you can mention that in the 
supported-systems of 'ydotool', 'supported-systems' has a kind of 
implicit transitivity going by the use of 
package-transitive-supported-systems in (guix ui).

>> Why select an older version?  Would keeping the original (and more
>> up-to-date) version work?  To avoid a name conflict between the openfst
>> (which would be inconvenient for "guix show", "guix install", "guix
>> shell"), you can override the 'name' field.
> 
> No, it doesn't work and that's the reason why I used this version.

In that case, I recommend adding a comment to the definition, to avoid 
the risk of someone 'helpfully' updating the package anyway, and an 
upstream report, such that upstream can address the compatibility 
problems with the new version.

> It
> might however work with the version that's present for kaldi (1.7.3
> IIRC), I can test that. But the flags aren't the same, so we probably
> should do another package anyway.
> 
> I didn't change the name, but I also haven't exported the variable
> (define instead of define-public). I expected the package to not be
> available through "guix search" or "guix install". Is that OK?

I suppose it is OK, though personally I think it might be a bit 
confusing, e.g. to people using "guix shell -D ..." ending up with a 
package version in their environment that they can't find with "guix 
search".

Greetings,
Maxime.
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Mon, 17 Oct 2022 08:48:01 GMT) Full text and rfc822 format available.

Notification sent to Nicolas Graves <ngraves <at> ngraves.fr>:
bug acknowledged by developer. (Mon, 17 Oct 2022 08:48:02 GMT) Full text and rfc822 format available.

Message #76 received at 58140-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Nicolas Graves <ngraves <at> ngraves.fr>
Cc: 58140-done <at> debbugs.gnu.org
Subject: Re: bug#58140: Simple offline text-to-speech incoming !
Date: Mon, 17 Oct 2022 10:46:52 +0200
Hi Nicolas,

I applied the whole series, thank you!

  d5b54e0137 gnu: Add nerd-dictation/wayland.
  eecb288ca2 gnu: Add nerd-dictation.
  a3e20f35f5 gnu: Add python-vosk.
  fadfeeede5 gnu: Add vosk-api.
  0c7a2639bb gnu: Add kaldi-for-vosk.
  9ca6416a19 gnu: Add openfst-for-vosk.

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 14 Nov 2022 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 164 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.