1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, scikit-build
5, cmake
6, ush
7, requests
8, numpy
9, cffi
10, openfst
11, substituteAll
12, callPackage
13}:
14
15let
16 kaldi = callPackage ./fork.nix { };
17in
18buildPythonPackage rec {
19 pname = "kaldi-active-grammar";
20 version = "2.1.0";
21
22 src = fetchFromGitHub {
23 owner = "daanzu";
24 repo = pname;
25 rev = "v${version}";
26 sha256 = "ArbwduoH7mMmIjlFfYAFvcpR39rrkVUJhYEyQzZqsbY=";
27 };
28
29 KALDI_BRANCH = "foo";
30 KALDIAG_SETUP_RAW = "1";
31
32 patches = [
33 # Makes sure scikit-build doesn't try to build the dependencies for us
34 ./0001-stub.patch
35 # Uses the dependencies' binaries from $PATH instead of a specific directory
36 ./0002-exec-path.patch
37 # Makes it dynamically link to the correct Kaldi library
38 (substituteAll {
39 src = ./0003-ffi-path.patch;
40 kaldiFork = "${kaldi}/lib";
41 })
42 ];
43
44 # scikit-build puts us in the wrong folder. That is bad.
45 preBuild = ''
46 cd ..
47 '';
48
49 buildInputs = [ openfst kaldi ];
50 nativeBuildInputs = [ scikit-build cmake ];
51 propagatedBuildInputs = [ ush requests numpy cffi ];
52
53 meta = with lib; {
54 description = "Python Kaldi speech recognition";
55 homepage = "https://github.com/daanzu/kaldi-active-grammar";
56 license = licenses.agpl3Plus;
57 maintainers = with maintainers; [ ckie ];
58 # Other platforms are supported upstream.
59 platforms = platforms.linux;
60 };
61}