diff options
author | Nicolas Graves <ngraves@ngraves.fr> | 2022-09-29 11:00:20 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-10-17 09:47:44 +0200 |
commit | a3e20f35f53ab0809d128a68694b5f94a000b6b7 (patch) | |
tree | 968882052637c71178745e4bd6c510d9bb416ffb /gnu | |
parent | fadfeeede5338aabafc81dc40c481089f7c46e6e (diff) | |
download | guix-a3e20f35f53ab0809d128a68694b5f94a000b6b7.tar.gz guix-a3e20f35f53ab0809d128a68694b5f94a000b6b7.zip |
gnu: Add python-vosk.
* gnu/packages/machine-learning.scm (python-vosk): New variable.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/packages/machine-learning.scm | 40 |
1 files changed, 40 insertions, 0 deletions
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 @@ 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)))) + +(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."))))))))) |