summaryrefslogtreecommitdiffstats
path: root/pkgs/tools/audio
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2020-12-31 09:24:02 +0100
committerJörg Thalheim <joerg@thalheim.io>2021-01-01 11:07:37 +0100
commite03e3c5fad8b56d1f3f252ea92271dadc639f4aa (patch)
tree803fbf2c81db0b1a5a83b2245b1f7a5e1b61b33d /pkgs/tools/audio
parent68a8e7bb26d62125b6551bc10e198eef8f057e34 (diff)
kaldi: init at 2020-12-26
State-of-the-art speech-to-text engine - used in rhasspy Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Diffstat (limited to 'pkgs/tools/audio')
-rw-r--r--pkgs/tools/audio/kaldi/default.nix88
1 files changed, 88 insertions, 0 deletions
diff --git a/pkgs/tools/audio/kaldi/default.nix b/pkgs/tools/audio/kaldi/default.nix
new file mode 100644
index 000000000000..fa291a05078e
--- /dev/null
+++ b/pkgs/tools/audio/kaldi/default.nix
@@ -0,0 +1,88 @@
+{ stdenv
+, openblas
+, blas
+, lapack
+, openfst
+, icu
+, cmake
+, pkg-config
+, fetchFromGitHub
+, git
+, python3
+}:
+
+assert blas.implementation == "openblas" && lapack.implementation == "openblas";
+let
+ # rev from https://github.com/kaldi-asr/kaldi/blob/master/cmake/third_party/openfst.cmake
+ openfst = fetchFromGitHub {
+ owner = "kkm000";
+ repo = "openfst";
+ rev = "0bca6e76d24647427356dc242b0adbf3b5f1a8d9";
+ sha256 = "1802rr14a03zl1wa5a0x1fa412kcvbgprgkadfj5s6s3agnn11rx";
+ };
+in
+stdenv.mkDerivation {
+ pname = "kaldi";
+ version = "2020-12-26";
+
+ src = fetchFromGitHub {
+ owner = "kaldi-asr";
+ repo = "kaldi";
+ rev = "813b73185a18725e4f6021981d17221d6ee23a19";
+ sha256 = "sha256-lTqXTG5ZTPmhCgt+BVzOwjKEIj+bLGUa+IxJq+XtHUg=";
+ };
+
+ cmakeFlags = [
+ "-DKALDI_BUILD_TEST=off"
+ "-DBUILD_SHARED_LIBS=on"
+ ];
+
+ preConfigure = ''
+ mkdir bin
+ cat > bin/git <<'EOF'
+ #!${stdenv.shell}
+ if [[ "$1" == "--version" ]]; then
+ # cmake checks this
+ ${git}/bin/git --version
+ elif [[ "$1" == "clone" ]]; then
+ # mock this call:
+
+ # https://github.com/kaldi-asr/kaldi/blob/c9d8b9ad3fef89237ba5517617d977b7d70a7ed5/cmake/third_party/openfst.cmake#L5
+ cp -r ${openfst} ''${@: -1}
+ chmod -R +w ''${@: -1}
+ elif [[ "$1" == "rev-list" ]]; then
+ # fix up this call:
+ # https://github.com/kaldi-asr/kaldi/blob/c9d8b9ad3fef89237ba5517617d977b7d70a7ed5/cmake/VersionHelper.cmake#L8
+ echo 0
+ fi
+ true
+ EOF
+ chmod +x bin/git
+ export PATH=$(pwd)/bin:$PATH
+ '';
+
+ buildInputs = [
+ openblas
+ openfst
+ icu
+ ];
+
+ nativeBuildInputs = [
+ cmake
+ pkg-config
+ python3
+ ];
+
+ postInstall = ''
+ mkdir -p $out/share/kaldi
+ cp -r ../egs $out/share/kaldi
+ '';
+
+ meta = with stdenv.lib; {
+ description = "Speech Recognition Toolkit";
+ homepage = "https://kaldi-asr.org";
+ license = licenses.mit;
+ maintainers = with maintainers; [ mic92 ];
+ platforms = platforms.linux;
+ };
+}