1{ lib 2, stdenv 3, blas 4, lapack 5, openfst 6, icu 7, pkg-config 8, fetchFromGitHub 9, python3 10, openblas 11, zlib 12, gfortran 13}: 14 15let 16 old-openfst = openfst.overrideAttrs (self: { 17 src = fetchFromGitHub { 18 owner = "kkm000"; 19 repo = "openfst"; 20 rev = "0bca6e76d24647427356dc242b0adbf3b5f1a8d9"; 21 sha256 = "1802rr14a03zl1wa5a0x1fa412kcvbgprgkadfj5s6s3agnn11rx"; 22 }; 23 buildInputs = [ zlib ]; 24 }); in 25 26assert blas.implementation == "openblas" && lapack.implementation == "openblas"; 27 28stdenv.mkDerivation rec { 29 pname = "kaldi"; 30 version = "kag-v2.1.0"; 31 32 src = fetchFromGitHub { 33 owner = "daanzu"; 34 repo = "kaldi-fork-active-grammar"; 35 rev = version; 36 sha256 = "+kT2xJRwDj/ECv/v/J1FpsINWOK8XkP9ZvZ9moFRl70="; 37 }; 38 39 patches = [ 40 ./0004-fork-cmake.patch 41 ./0006-fork-configure.patch 42 ]; 43 44 enableParallelBuilding = true; 45 46 buildInputs = [ 47 openblas 48 old-openfst 49 icu 50 ]; 51 52 nativeBuildInputs = [ 53 pkg-config 54 python3 55 gfortran 56 ]; 57 58 buildFlags = [ 59 "dragonfly" 60 "dragonflybin" 61 "bin" 62 "fstbin" 63 "lmbin" 64 ]; 65 66 postPatch = '' 67 # Replace the shebangs for the various build scripts 68 patchShebangs src 69 ''; 70 71 configurePhase = '' 72 cd src 73 ./configure --shared --fst-root="${old-openfst}" --use-cuda=no --openblas-root="${openblas}" --mathlib=OPENBLAS 74 ''; 75 76 installPhase = '' 77 # Fixes "patchelf: wrong ELF type" 78 find . -type f -name "*.o" -print0 | xargs -0 rm -f 79 mkdir -p $out/{bin,lib} 80 cp lib/* $out/lib/ 81 patchelf \ 82 --set-rpath "${lib.makeLibraryPath buildInputs}:$out/lib" \ 83 $out/lib/* 84 ''; 85 86 meta = with lib; { 87 description = "Speech Recognition Toolkit"; 88 homepage = "https://kaldi-asr.org"; 89 license = licenses.mit; 90 maintainers = with maintainers; [ ckie ]; 91 platforms = platforms.linux; 92 }; 93}