Kaldi是一款基于C++的开源语音识别工具箱,根据官方的说法,可以再UNIX和Windows编译并执行。(吐槽一下,最近kaldi的作者也是风雨漂泊,说是要来中国发展,希望能够接触到大牛)。无论语音识别还是语音评测,大部分公司都是基于这套框架的,也是进入语音识别领域的基石,可以很快上手。不过代码是C++写的,里面有些坑还需要挖,比如有些模块的线程安全问题(具体的模块忘记了,后面记起来再补上),对于python相关的AI工程师还是有点难度的。讲真C++比python可优化的速度空间还是大很多的。

1. 下载

直接到Github上下载就可以了,https://github.com/kaldi-asr/kaldi,可以Git clone下来,也可以直接download zip文件到本地。

2. 需要预安装的包

automake

autoconf

g++

sox

subversion

apt-get

zlib

基于你的机器情况,提示要安装的包可能不太一样,可以参考tools/extras/check_dependencies.sh。

到tools目录下面执行make命令。

make -j 4

有些教程可能会让你执行make -j 4,采用4核同时build,但是可能确实的包就不会提示了。这里我们保险起见,可以直接用make。比如你没有安装成功openfst,那么你到src目录下执行./configure命令时就会报错。

$ ./configure
Configuring KALDI to use MKL.
Checking compiler g++ ...
Checking OpenFst library in  ...
***configure failed: Could not find file /include/fst/fst.h:you may not have installed OpenFst. See ../tools/INSTALL ***

我们直接根据操作系统用brew(MacOS)、apt-get(Linux)或者yum(Centos)安装相应的包就可以了。

3. 安装Kaldi

之后再次执行./configure,会提示你没有MKL,让你用ATLAS,我们采用ATLAS,但是还是会有错误

$ ./configure  --mathlib=ATLAS
Configuring KALDI to use ATLAS.
Backing up kaldi.mk to kaldi.mk.bak ...
Checking compiler g++ ...
Checking OpenFst library in /home/kkm/work/kaldi2/tools/openfst ...
Checking cub library in /home/kkm/work/kaldi2/tools/cub ...
Doing OS specific configurations ...
On Linux: Checking for linear algebra header files ...
Using ATLAS as the linear algebra library.
Could not find libatlas.a in any of the generic-Linux places, but we'll try other stuff...
** Failed to configure ATLAS libraries ***
**  ERROR   **
** Configure cannot proceed automatically.
**  If you know that you have ATLAS installed somewhere on your machine, you
** may be able to proceed by replacing [somewhere] in kaldi.mk with a directory.
**  If you have sudo (root) access you could install the ATLAS package on your
** machine, e.g. 'sudo apt-get install libatlas-dev libatlas-base-dev' or
** 'sudo yum install atlas.x86_64' or 'sudo zypper install libatlas3-devel',
** or on cygwin, install atlas from the installer GUI; and then run ./configure
** again.
**
**  Otherwise (or if you prefer OpenBLAS for speed), you could go the OpenBLAS
** route: cd to ../tools, type 'extras/install_openblas.sh', cd back to here,
** and type './configure  --openblas-root=../tools/OpenBLAS/install'

搜了一下,网上提供了一种方案https://github.com/kaldi-asr/kaldi/pull/3216

$ sudo apt install -y libatlas-base-dev
. . .
$ ./configure  --mathlib=ATLAS
Configuring KALDI to use ATLAS.
Backing up kaldi.mk to kaldi.mk.bak ...
Checking compiler g++ ...
Checking OpenFst library in /data00/home/liuwenchuang/cpphere/kaldi/source/kaldi-master/tools/openfst-1.6.7 ...
Checking cub library in /data00/home/liuwenchuang/cpphere/kaldi/source/kaldi-master/tools/cub-1.8.0 ...
Doing OS specific configurations ...
On Linux: Checking for linear algebra header files ...
Using ATLAS as the linear algebra library.
Successfully configured ATLAS with ATLASLIBS=/usr/lib/libatlas.so.3 /usr/lib/libf77blas.so.3 /usr/lib/libcblas.so.3 /usr/lib/liblapack_atlas.so.3
WARNING: CUDA will not be used! If you have already installed cuda driversand CUDA toolkit, try using the --cudatk-dir= option. A GPU and CUDAare required to run neural net experiments in a realistic time.
INFO: Configuring Kaldi not to link with Speex. Don't worry, it's only needed ifyou intend to use 'compress-uncompress-speex', which is very unlikely.
Kaldi has been successfully configured. To compile:make -j clean depend; make -j <NCPU>where <NCPU> is the number of parallel builds you can afford to do. If unsure,
use the smaller of the number of CPUs or the amount of RAM in GB divided by 2,
to stay within safe limits. 'make -j' without the numeric value may not limit
the number of parallel jobs at all, and overwhelm even a powerful workstation,
since Kaldi build is highly parallelized.$ make -j clean depend; make -j 4
. . .
Done$ sudo apt remove -y libatlas-base-dev --auto-remove

但是用make j 4的话,有错误看不错咋回事。然后你去egs下面去测试会报错提示fstaddselfloops找不到,搜索后发现是kaldi没有build成功: https://github.com/uhh-lt/kaldi-tuda-de/issues/10

回来用sudo make跑,问题暴露了。

make[2]: Entering directory '/home/srinivas/Downloads/kaldi/src/online2'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/srinivas/Downloads/kaldi/src/online2'
make -C bin
make[2]: Entering directory '/home/srinivas/Downloads/kaldi/src/bin'
g++-4.9  -Wl,-rpath=/home/srinivas/Downloads/kaldi/tools/openfst/lib -rdynamic  align-equal.o ../decoder/kaldi-decoder.a ../lat/kaldi-lat.a ../lm/kaldi-lm.a ../fstext/kaldi-fstext.a ../hmm/kaldi-hmm.a ../transform/kaldi-transform.a ../gmm/kaldi-gmm.a ../tree/kaldi-tree.a ../util/kaldi-util.a ../thread/kaldi-thread.a ../matrix/kaldi-matrix.a ../base/kaldi-base.a   /home/srinivas/Downloads/kaldi/tools/openfst/lib/libfst.so /usr/lib/libatlas.so.3 /usr/lib/libf77blas.so.3 /usr/lib/libcblas.so.3 /usr/lib/liblapack_atlas.so.3 -lm -lpthread -ldl -o align-equal
align-equal.o: In function `fst::internal::FstImpl<fst::ArcTpl<fst::TropicalWeightTpl<float> > >::WriteFstHeader(fst::Fst<fst::ArcTpl<fst::TropicalWeightTpl<float> > > const&, std::ostream&, fst::FstWriteOptions const&, int, std::string const&, unsigned long, fst::FstHeader*)':
/home/srinivas/Downloads/kaldi/tools/openfst/include/fst/fst.h:745: undefined reference to `fst::FstHeader::Write(std::ostream&, std::string const&) const'
../decoder/kaldi-decoder.a(training-graph-compiler.o): In function `fst::internal::FstImpl<fst::ReverseArc<fst::ArcTpl<fst::TropicalWeightTpl<float> > > >::WriteFstHeader(fst::Fst<fst::ReverseArc<fst::ArcTpl<fst::TropicalWeightTpl<float> > > > const&, std::ostream&, fst::FstWriteOptions const&, int, std::string const&, unsigned long, fst::FstHeader*)':
/home/srinivas/Downloads/kaldi/tools/openfst/include/fst/fst.h:745: undefined reference to `fst::FstHeader::Write(std::ostream&, std::string const&) const'
../decoder/kaldi-decoder.a(training-graph-compiler.o): In function `fst::internal::FstImpl<fst::ArcTpl<fst::LogWeightTpl<float> > >::WriteFstHeader(fst::Fst<fst::ArcTpl<fst::LogWeightTpl<float> > > const&, std::ostream&, fst::FstWriteOptions const&, int, std::string const&, unsigned long, fst::FstHeader*)':
/home/srinivas/Downloads/kaldi/tools/openfst/include/fst/fst.h:745: undefined reference to `fst::FstHeader::Write(std::ostream&, std::string const&) const'
../fstext/kaldi-fstext.a(kaldi-fst-io.o): In function `fst::ReadFstKaldi(std::string)':
/home/srinivas/Downloads/kaldi/src/fstext/kaldi-fst-io.cc:34: undefined reference to `fst::FstHeader::Read(std::istream&, std::string const&, bool)'
/home/srinivas/Downloads/kaldi/src/fstext/kaldi-fst-io.cc:37: undefined reference to `fst::FstReadOptions::FstReadOptions(std::string const&, fst::FstHeader const*, fst::SymbolTable const*, fst::SymbolTable const*)'
../fstext/kaldi-fstext.a(kaldi-fst-io.o): In function `fst::internal::FstImpl<fst::ArcTpl<fst::TropicalWeightTpl<float> > >::ReadHeader(std::istream&, fst::FstReadOptions const&, int, fst::FstHeader*)':
/home/srinivas/Downloads/kaldi/tools/openfst/include/fst/fst.h:796: undefined reference to `fst::FstHeader::Read(std::istream&, std::string const&, bool)'
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'align-equal' failed
make[2]: *** [align-equal] Error 1
make[2]: Leaving directory '/home/srinivas/Downloads/kaldi/src/bin'
Makefile:142: recipe for target 'bin' failed
make[1]: *** [bin] Error 2
make[1]: Leaving directory '/home/srinivas/Downloads/kaldi/src'
Makefile:35: recipe for target 'all' failed
make: *** [all] Error 2

不管clean多少次,这个align-equal死活build不过,网上查资料后发现是build和link用g++的版本不一致造成的。

https://www.oipapio.com/question-141226

因为我本地有两个g++版本,Debian上输入g++之后按tab键可以看到所有安装的版本。

$ g++
g++      g++-4.9

我这里g++是9.2.0的版本。

这里强行设置一下CXX的版本为g++(当然也可以设置为g++-4.9,两个都做了测试,都能把kaldi build成功)

$ CXX=g++

然后再执行build相关命令竟然echo Done了。

4. 做个简单的测试

1. 回到kaldi-master目录,然后到egs目录下,这个目录里面都是sample,我们也简单用yesno这个测试来简单看下。进去后再到s5目录下,至于为啥取名s5,我也不知道,先搁置一下,到s5目录下,然后执行

$ sudo ./run.sh

然后成功了,有点兴奋。看下这里面的数据集,发现都是yes/no这样的一个人的录音,你仔细看输出会提示你一个人录音训练不好。

2. 我们也可以来个复杂点的,可以参考http://xuxping.com/2019/06/16/20190616_ASR_from_begin_to_abandoned/搞个中文thchs30的测试。测试的时候注意一下,需要自己去openslr.org拉数据,然后解压。你解压的目录要更新到run.sh里面的thchs这个变量。然后你发现跑起来,还会有错误。

creating data/{train,dev,test}
cleaning data/train
preparing scps and text in data/train
cleaning data/dev
preparing scps and text in data/dev
cleaning data/test
preparing scps and text in data/test
creating test_phone for phone decoding
steps/make_mfcc.sh --nj 8 --cmd queue.pl data/mfcc/train exp/make_mfcc/train mfcc/train
utils/validate_data_dir.sh: Successfully validated data-directory data/mfcc/train
steps/make_mfcc.sh: [info]: no segments file exists: assuming wav.scp indexed by utterance.
queue.pl: Error submitting jobs to queue (return status was 32512)
queue log file is exp/make_mfcc/train/q/make_mfcc_train.log, command was qsub -v PATH -cwd -S /bin/bash -j y -l arch=*64* -o exp/make_mfcc/train/q/make_mfcc_train.log   -t 1:8 /data00/home/liuwenchuang/cpphere/kaldi/source/kaldi-master/egs/thchs30/s5/exp/make_mfcc/train/q/make_mfcc_train.sh >>exp/make_mfcc/train/q/make_mfcc_train.log 2>&1
Output of qsub was: sh: 1: qsub: not found

可以修改cmd.sh文件如下:

# you can change cmd.sh depending on what type of queue you are using.
# If you have no queueing system and want to run on a local machine, you
# can change all instances 'queue.pl' to run.pl (but be careful and run
# commands one by one: most recipes will exhaust the memory on your
# machine).  queue.pl works with GridEngine (qsub).  slurm.pl works
# with slurm.  Different queues are configured differently, with different
# queue names and different ways of specifying things like memory;
# to account for these differences you can create and edit the file
# conf/queue.conf to match your queue's configuration.  Search for
# conf/queue.conf in http://kaldi-asr.org/doc/queue.html for more information,
# or search for the string 'default_config' in utils/queue.pl or utils/slurm.pl.#export train_cmd=queue.pl
#export decode_cmd="queue.pl --mem 4G"
#export mkgraph_cmd="queue.pl --mem 8G"
#export cuda_cmd="queue.pl --gpu 1"
export train_cmd=run.pl
export decode_cmd=run.pl
export mkgraph_cmd="run.pl"

参考地址:LiveToolkit

Kaldi的安装与测试相关推荐

  1. kaldi 的安装和thchs30语音识别测试

    kaldi 的安装和测试 文章目录 kaldi 的安装和测试 1. 下载源码 2. 安装 3. Kaldi 目录介绍 子目录egs 子目录src 训练.识别.测试 语料下载 测试结果 1. 下载源码 ...

  2. my SQL下载安装,环境配置,以及密码忘记的解决,以及navicat for mysql下载,安装,测试连接...

    一.下载 在百度上搜索"mysql-5.6.24-winx64下载" 二.安装 选择安装路径,我的路径"C:\Soft\mysql-5.6.24-winx64" ...

  3. http_load安装与测试参数分析

    http_load安装与测试参数分析 http_load以并行复用的方式运行,用以测试 web 服务器的吞吐量与负载.但是它不同于大多数压力测试工具,它可以以一个单一的进程运行,一般不会把客户机搞死. ...

  4. nginx 没有sbin目录_CentOS7下Nginx+ModSecurity配置、安装、测试教程

    " 最近在工作上遇到一点问题,问了大佬.百度,都没有很好地解决:经过大量搜索查阅以及试验,终于将问题解决.于是写下这篇文章以提醒自己,也可供读者参考." 环境:CentOS-7-x ...

  5. AutoBench+Httperf的安装、测试

    首先安装Httperf.主要是Httperf网路上给出的url均无法访问,因此在GitHub上找的源码工程,进行安装. 接下来介绍安装步骤,从Github下载下来的httperf包是zip. unzi ...

  6. 安装并测试nvenc linux sdk

    2019独角兽企业重金招聘Python工程师标准>>> nvidia在cuda之后推出一种官方生成更好视频处理技术nvenc. 网上相关资料很少, 也不知道这个东西到底怎么样,自己测 ...

  7. appium for mac 安装与测试ios说明

    一.安装 安装dmg,可以自己下载appium-1.4.0.dmg或者找rtx我要,文件过大不能添加附件. Appium提供了一个doctor,运行appium-doctor 如果有问题,Fix it ...

  8. Faste R-CNN的安装及测试

    一.拉取源码 下载 fast-rcnn 因下载解压后 caffe-fast-rcnn是空文件夹,故需要单独下 caffe-fast-rcnn-bcd9b4eadc7d8fbc433aeefd564e8 ...

  9. Faster R-CNN的安装及测试(Python版本和Matlab版本)

    rbg的Python版本 一.拉取源码 git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git 拉取完成后,在/h ...

  10. Eclipse JPBC library安装及测试

    Eclipse JPBC library安装及测试 资源下载路径: 安装配置: JPBC库是一个功能很强大的数学库,用于生成椭圆曲线,双线性等,但网上参考资料很少,重复度极高,该分栏用于安装,JPBC ...

最新文章

  1. SSD(Single shot multibox detector)目标检测模型架构和设计细节分析
  2. c语言——求单词个数
  3. 【错误记录】Android 编译时技术版本警告 ( 注解处理器与主应用支持的 Java 版本不匹配 )
  4. 数据结构源码笔记(C语言):二叉树遍历
  5. 我们无法在你选择的位置安装Windows。0x80300002
  6. Keras .ImageDataGenerator图像增强用法大全以及如何和模型结合起来(有代码)
  7. 自动刷新_AutoRefresh插件:开启页面自动刷新!
  8. 2014/School_C_C++_A/5/勾股定理
  9. groovy怎样从sql语句中截取表名_SQL基础教程学习笔记
  10. python中case的用法_python中Switch/Case实现的示例代码
  11. C# :试玩EventLog
  12. nssl1157-简单数学题【约数,换元法】
  13. 【牛客 - 330F】Applese 的QQ群(拓扑排序,二分)
  14. cass生成曲线要素文件_几种常见的CASS字体异常问题,教你如何解决
  15. 步步为营-49-视图
  16. ios keychain 不被清理_iOS签名机制和说明文件【ios企业签名吧】
  17. 学习可以借鉴的大牛们的网站
  18. Pthreads线程的基本常识
  19. arduino的串口缓冲区_C#无法从串口Arduino读取完整缓冲区
  20. qt如何在TetxEdit设置背景色(可以设置行或列)

热门文章

  1. java删除奇数文件_P041 删除ASCII值为奇数的字符 ★★
  2. 变量的三重属性_内存寻梦环游记:一个变量的三重死亡
  3. eval解析json字符串
  4. WEB-QTP随想录—李密的猜想
  5. 海尔计算机无法装win7系统,海尔Haier电脑预装win8换win7系统BIOS设置及安装教程
  6. java中获取农历日期以及星期几
  7. Android动画学习之帧动画二
  8. mysql查询数据库剩余空间大小_MySQL中查询所有数据库占用磁盘空间大小
  9. PHP源码 京东联盟API接口,转链+cha询订单,cha询推广位
  10. 银行等额本息还款算法