服务器和虚拟机怎么安装Kaldi?

2024-02-13 10:30

本文主要是介绍服务器和虚拟机怎么安装Kaldi?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

  • 前言
  • 克隆kaldi到本地
  • tools/INSTALL安装
    • 检查依赖extras/check_dependencies.sh
    • 把四个依赖包放在tools/目录下
    • 修改Makefile文件
    • 检查g++是否安装
    • 安装irstlm(非必须)
  • Src/INSTALL安装
    • ./configure --shared
    • make depend和make
    • 测试egs/yesno/s5/的案例

前言

安装kaldi折腾十个小时,终于安装完成,踩了各种坑,好多问题网上查不到,我都怀疑实验室的服务器有问题了,最后还是在宏林师兄的帮忙下解决,感谢!学习语音道阻且长呀,大家一起努力一起进步吧!

克隆kaldi到本地

(如果你是用的实验室服务器,最好创建一个自己的文件夹,不要放在公用的地方)
在自己文件目录下输入

git clone https://github.com/kaldi-asr/kaldi.git kaldi --origin upstream

因为文件比较大,如果出现拷贝错误,可以通过特殊手段(说了过不了审),然后自己改成你懂得ip

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
git config --list

如果还是不行记得通过

git config --edit

修改,多试几次,肯定可以

tools/INSTALL安装

进入tools目录

cd tools/

查看当前目录的INSTALL安装文件

(base) [Sxd13StuA@gpu13 tools]$ cat INSTALL
To check the prerequisites for Kaldi, first runextras/check_dependencies.shand see if there are any system-level installations you need to do. Check the
output carefully. There are some things that will make your life a lot easier
if you fix them at this stage. If your system default C++ compiler is not
supported, you can do the check with another compiler by setting the CXX
environment variable, e.g.CXX=g++-4.8 extras/check_dependencies.shThen runmakewhich by default will install ATLAS headers, OpenFst, SCTK and sph2pipe.
OpenFst requires a relatively recent C++ compiler with C++11 support, e.g.
g++ >= 4.7, Apple clang >= 5.0 or LLVM clang >= 3.3. If your system default
compiler does not have adequate support for C++11, you can specify a C++11
compliant compiler as a command argument, e.g.make CXX=g++-4.8If you have multiple CPUs and want to speed things up, you can do a parallel
build by supplying the "-j" option to make, e.g. to use 4 CPUsmake -j 4In extras/, there are also various scripts to install extra bits and pieces that
are used by individual example scripts.  If an example script needs you to run
one of those scripts, it will tell you what to do.

检查依赖extras/check_dependencies.sh

上述文件要求我们进入extras/目录下执行check_dependencies.sh脚本查看系统依赖是否满足需要。

(base) [Sxd13StuA@gpu13 tools]$ cd extras/
(base) [Sxd13StuA@gpu13 extras]$ ./check_dependencies.sh

如果出现这样的结果就是没有问题,但是我猜你一定会不会这么顺利

./check_dependencies.sh: WARNING python 2.7 is not the default python. We fixed this by adding a correct symlink more prominently on the path.... If you really want to use python 3.6.10 as default, add an empty file /home/Sxd13/Sxd13StuA/zhudaobin/kaldi/tools/extras/python/.use_default_python and run this script again.
./check_dependencies.sh: all OK.

把四个依赖包放在tools/目录下

你先把这四个文件放在你的tools/目录下

在这里插入图片描述

我会给提供链接,你们可以免费下载,点我下载!

修改Makefile文件

然后更改Makefile文件

(base) [Sxd13StuA@gpu13 extras]$ cd ..
(base) [Sxd13StuA@gpu13 tools]$ vim Makefile 

WGETOPENFST_VERSION改成这样,如果你的openfst文件是其他版本,你就改成你自己的版本,改成这样,你会少出现很多bug(血泪教训)

WGET ?= wget--no-check-certificate
OPENFST_VERSION ?= 1.6.7

检查g++是否安装

输入g++ --version查看自己有没有安装g++,没安后面也执行不了,跟管理员要一下密码或者找管理员帮你安装一下g++

sudo apt install g++

默认安装的都是比较高的版本,不用担心版本问题。

(base) [Sxd13StuA@gpu13 tools]$ g++ --version
g++ (GCC) 7.3.0
Copyright © 2017 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。

这样就ok了
继续按照INSTALL的要求make,不过先看看你的服务器CPU核心数

(base) [Sxd13StuA@gpu13 tools]$ nproc
32

输出的数字表示你的服务器有多少核,决定了你的并行速度,不过照我的经验,最好不要用make -j 4这个指令,直接make就好了,不过make的话会非常非常慢,但是出错概率比make -j 4要小很多
(make -j 4中的4可以理解为几倍速,它是由计算机的CPU核心数决定的,也就是上面nproc查到的结果)
在这里插入图片描述

安装irstlm(非必须)

可能还会提示你没有安装irstlm,这个不是必须的,但是还是安了省心

(base) [Sxd13StuA@gpu13 tools]$ ./extras/install_irstlm.sh 
***() Installation of IRSTLM finished successfully
***() Please source the tools/extras/env.sh in your path.sh to enable it

安装后进入env.sh文件更改

(base) [Sxd13StuA@gpu13 tools]$ vim env.sh
export PATH=/home/你的文件目录/kaldi/tools/python:${PATH}
export IRSTLM=/home/你的文件目录/kaldi/tools/irstlm
export PATH=${PATH}:${IRSTLM}/bin

记得把文件目录改成你自己的目录。

(base) [Sxd13StuA@gpu13 tools]$ source env.sh 

Src/INSTALL安装

我们先进入Src查看INSTALL,看看怎么安装:

(base) [Sxd13StuA@gpu13 tools]$ cd ../src/
(base) [Sxd13StuA@gpu13 src]$ cat INSTALL These instructions are valid for UNIX-like systems (these steps have
been run on various Linux distributions; Darwin; Cygwin).  For native Windows
compilation, see ../windows/INSTALL.You must first have completed the installation steps in ../tools/INSTALL
(compiling OpenFst; getting ATLAS and CLAPACK headers).The installation instructions are./configure --sharedmake depend -j 8make -j 8Note that we added the "-j 8" to run in parallel because "make" takes a long
time.  8 jobs might be too many for a laptop or small desktop machine with not
many cores.For more information, see documentation at http://kaldi-asr.org/doc/
and click on "The build process (how Kaldi is compiled)".

可以看出有三个必要指令:

  ./configure --sharedmake depend -j 8make -j 8

我们依次执行:

./configure --shared

(base) [Sxd13StuA@gpu13 src]$ ./configure --shared
Configuring KALDI to use MKL.
Backing up kaldi.mk to kaldi.mk.bak ...
Checking compiler g++ ...
Checking OpenFst library in /home/Sxd13/Sxd13StuA/zhudaobin/kaldi/tools/openfst-1.6.7 ...
Checking cub library in /home/Sxd13/Sxd13StuA/zhudaobin/kaldi/tools/cub-1.8.0 ...
Performing OS specific configuration ...
On Linux: Checking for linear algebra header files ...
Configuring MKL library directory: Found /opt/intel/mkl/lib/intel64
MKL libs MKL_LDLIBS = -L/opt/intel/mkl/lib/intel64 -Wl,-rpath=/opt/intel/mkl/lib/intel64 -l:libmkl_intel_lp64.so -l:libmkl_core.so -l:libmkl_sequential.so -ldl -lpthread -lm.
MKL compile flags MKL_CXXFLAGS = -I/opt/intel/mkl/include.
*** MKL self-reported version:
Intel(R) Math Kernel Library Version 2019.0.2 Product Build 20190118 for Intel(R) 64 architecture applications
Successfully configured for Linux with MKL libraries found in /opt/intel/mkl
Using CUDA toolkit /usr/local/cuda (nvcc compiler and runtime libraries)
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.

如果你前面都按照我说的做了,这里应该不会出现中文警告。
如果出现找不到openfst之类的错误,一定是你前面没安那四个包。

make depend和make

一种makefile的规则,通过扫描仪个目录下的所有C\C++ 代码,从而判断出文件之间的依赖关系,如a.cc文件中调用了b.h(如以形势include<b.h>),如果之后a.cc文件被改动,那 么只需要重新编译a.cc文件,不需要编译b.h文件。否则所有的文件都需要重新编译。

(base) [Sxd13StuA@gpu13 src]$ make depend
(base) [Sxd13StuA@gpu13 src]$ make

持续时间大约一个小时。
我们检测一下看看有没有安装成功:

测试egs/yesno/s5/的案例

(base) [Sxd13StuA@gpu13 src]$ cd ../egs/yesno/s5/
(base) [Sxd13StuA@gpu13 s5]$ ./run.sh 

出现以下内容就是安装成功了!

HCLGa is not stochastic
add-self-loops --self-loop-scale=0.1 --reorder=true exp/mono0a/final.mdl exp/mono0a/graph_tgpr/HCLGa.fst 
steps/decode.sh --nj 1 --cmd utils/run.pl exp/mono0a/graph_tgpr data/test_yesno exp/mono0a/decode_test_yesno
decode.sh: feature type is delta
steps/diagnostic/analyze_lats.sh --cmd utils/run.pl exp/mono0a/graph_tgpr exp/mono0a/decode_test_yesno
steps/diagnostic/analyze_lats.sh: see stats in exp/mono0a/decode_test_yesno/log/analyze_alignments.log
Overall, lattice depth (10,50,90-percentile)=(1,1,2) and mean=1.2
steps/diagnostic/analyze_lats.sh: see stats in exp/mono0a/decode_test_yesno/log/analyze_lattice_depth_stats.log
local/score.sh --cmd utils/run.pl data/test_yesno exp/mono0a/graph_tgpr exp/mono0a/decode_test_yesno
local/score.sh: scoring with word insertion penalty=0.0,0.5,1.0
%WER 0.00 [ 0 / 232, 0 ins, 0 del, 0 sub ] exp/mono0a/decode_test_yesno/wer_10_0.0

这篇关于服务器和虚拟机怎么安装Kaldi?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/705280

相关文章

ubuntu20.0.4系统中安装Anaconda的超详细图文教程

《ubuntu20.0.4系统中安装Anaconda的超详细图文教程》:本文主要介绍了在Ubuntu系统中如何下载和安装Anaconda,提供了两种方法,详细内容请阅读本文,希望能对你有所帮助... 本文介绍了在Ubuntu系统中如何下载和安装Anaconda。提供了两种方法,包括通过网页手动下载和使用wg

ubuntu如何部署Dify以及安装Docker? Dify安装部署指南

《ubuntu如何部署Dify以及安装Docker?Dify安装部署指南》Dify是一个开源的大模型应用开发平台,允许用户快速构建和部署基于大语言模型的应用,ubuntu如何部署Dify呢?详细请... Dify是个不错的开源LLM应用开发平台,提供从 Agent 构建到 AI workflow 编排、RA

如何在Ubuntu上安装NVIDIA显卡驱动? Ubuntu安装英伟达显卡驱动教程

《如何在Ubuntu上安装NVIDIA显卡驱动?Ubuntu安装英伟达显卡驱动教程》Windows系统不同,Linux系统通常不会自动安装专有显卡驱动,今天我们就来看看Ubuntu系统安装英伟达显卡... 对于使用NVIDIA显卡的Ubuntu用户来说,正确安装显卡驱动是获得最佳图形性能的关键。与Windo

ubuntu16.04如何部署dify? 在Linux上安装部署Dify的技巧

《ubuntu16.04如何部署dify?在Linux上安装部署Dify的技巧》随着云计算和容器技术的快速发展,Docker已经成为现代软件开发和部署的重要工具之一,Dify作为一款优秀的云原生应用... Dify 是一个基于 docker 的工作流管理工具,旨在简化机器学习和数据科学领域的多步骤工作流。它

Docker安装MySQL镜像的详细步骤(适合新手小白)

《Docker安装MySQL镜像的详细步骤(适合新手小白)》本文详细介绍了如何在Ubuntu环境下使用Docker安装MySQL5.7版本,包括从官网拉取镜像、配置MySQL容器、设置权限及内网部署,... 目录前言安装1.访问docker镜像仓库官网2.找到对应的版本,复制右侧的命令即可3.查看镜像4.启

debian12安装docker的实现步骤

《debian12安装docker的实现步骤》本文主要介绍了debian12安装docker的实现步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着... 目录步骤 1:更新你的系统步骤 2:安装依赖项步骤 3:添加 docker 的官方 GPG 密钥步骤

Win安装MySQL8全过程

《Win安装MySQL8全过程》:本文主要介绍Win安装MySQL8全过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Win安装mysql81、下载MySQL2、解压文件3、新建文件夹data,用于保存数据库数据文件4、在mysql根目录下新建文件my.ini

Go语言开发实现查询IP信息的MCP服务器

《Go语言开发实现查询IP信息的MCP服务器》随着MCP的快速普及和广泛应用,MCP服务器也层出不穷,本文将详细介绍如何在Go语言中使用go-mcp库来开发一个查询IP信息的MCP... 目录前言mcp-ip-geo 服务器目录结构说明查询 IP 信息功能实现工具实现工具管理查询单个 IP 信息工具的实现服

最详细安装 PostgreSQL方法及常见问题解决

《最详细安装PostgreSQL方法及常见问题解决》:本文主要介绍最详细安装PostgreSQL方法及常见问题解决,介绍了在Windows系统上安装PostgreSQL及Linux系统上安装Po... 目录一、在 Windows 系统上安装 PostgreSQL1. 下载 PostgreSQL 安装包2.

Maven如何手动安装依赖到本地仓库

《Maven如何手动安装依赖到本地仓库》:本文主要介绍Maven如何手动安装依赖到本地仓库问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、下载依赖二、安装 JAR 文件到本地仓库三、验证安装四、在项目中使用该依赖1、注意事项2、额外提示总结一、下载依赖登