2021-01-11 08:54:33 +01:00
|
|
|
{ lib, stdenv
|
2020-12-31 09:24:02 +01:00
|
|
|
, 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";
|
2021-12-03 19:08:03 +01:00
|
|
|
rev = "338225416178ac36b8002d70387f5556e44c8d05";
|
|
|
|
sha256 = "sha256-MGEUuw7ex+WcujVdxpO2Bf5sB6Z0edcAeLGqW/Lo1Hs=";
|
2020-12-31 09:24:02 +01:00
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "kaldi";
|
2021-12-03 19:08:03 +01:00
|
|
|
version = "2021-12-03";
|
2020-12-31 09:24:02 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "kaldi-asr";
|
|
|
|
repo = "kaldi";
|
2021-12-03 19:08:03 +01:00
|
|
|
rev = "2b016ab8cb018e031ab3bf01ec36cc2950c7e509";
|
|
|
|
sha256 = "sha256-R8CrY7cwU5XfeGEgeFuZ0ApsEcEmWN/lrZaCjz85tyk=";
|
2020-12-31 09:24:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DKALDI_BUILD_TEST=off"
|
|
|
|
"-DBUILD_SHARED_LIBS=on"
|
|
|
|
];
|
|
|
|
|
2021-12-03 19:12:31 +01:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2020-12-31 09:24:02 +01:00
|
|
|
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
|
2021-09-24 11:06:31 +02:00
|
|
|
elif [[ "$1" == "rev-parse" ]]; then
|
2021-09-24 13:13:36 +02:00
|
|
|
echo ${openfst.rev}
|
2021-09-24 11:06:31 +02:00
|
|
|
echo 0
|
2020-12-31 09:24:02 +01:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2020-12-31 09:24:02 +01:00
|
|
|
description = "Speech Recognition Toolkit";
|
|
|
|
homepage = "https://kaldi-asr.org";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ mic92 ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|