Kaldi学习笔记 -- 构建字典FST脚本 -- prepare_lang.sh 关键内容解析

摘要:本文介绍了Kaldi训练过程中数据准备部分 如何通过字典构造其FST模型。摘取其中较难理解的部分,此为自我见解,欢迎纠正。

1
2
3
4
5
6
7

bash: cd: ../egs/yesno/s5: 没有那个文件或目录 Preparing train and test data Dictionary preparation succeeded utils/prepare_lang.sh --position-dependent-phones false data/local/dict <SIL> data/local/lang data/lang Checking data/local/dict/silence_phones.txt ... --> reading data/local/dict/silence_phones.txt --> text seems to be UTF-8 or ASCII, checking whitespaces --> text contains only allowed whitespaces --> data/local/dict/silence_phones.txt is OK Checking data/local/dict/optional_silence.txt ... --> reading data/local/dict/optional_silence.txt --> text seems to be UTF-8 or ASCII, checking whitespaces --> text contains only allowed whitespaces --> data/local/dict/optional_silence.txt is OK Checking data/local/dict/nonsilence_phones.txt ... --> reading data/local/dict/nonsilence_phones.txt --> text seems to be UTF-8 or ASCII, checking whitespaces --> text contains only allowed whitespaces --> data/local/dict/nonsilence_phones.txt is OK Checking disjoint: silence_phones.txt, nonsilence_phones.txt --> disjoint property is OK. Checking data/local/dict/lexicon.txt --> reading data/local/dict/lexicon.txt --> text seems to be UTF-8 or ASCII, checking whitespaces --> text contains only allowed whitespaces --> data/local/dict/lexicon.txt is OK Checking data/local/dict/extra_questions.txt ... --> data/local/dict/extra_questions.txt is empty (this is OK) --> SUCCESS [validating dictionary directory data/local/dict] **Creating data/local/dict/lexiconp.txt from data/local/dict/lexicon.txt utils/prepare_lang.sh: line 466: fstcompile: command not found utils/prepare_lang.sh: line 468: fstarcsort: command not found Exception ignored in: <_io.TextIOWrapper name=1 mode='w' encoding='latin-1'> BrokenPipeError: [Errno 32] Broken pipe Preparing language models for test local/prepare_lm.sh: line 13: arpa2fst: command not found local/prepare_lm.sh: line 15: fstisstochastic: command not found local/prepare_lm.sh: line 31: fstcompile: command not found local/prepare_lm.sh: line 32: fstarcsor
最新发布
03-10
<think>好的,我现在需要帮助用户解决Kaldi工具链中出现的命令未找到的问题,特别是fstcompile、fstarcsort和arpa2fst这些命令。首先,我得回忆一下Kaldi的安装过程和依赖项。用户提到了这些命令找不到,通常这可能是因为环境变量没有正确设置,或者相关的库没有安装。 根据引用[1],用户遇到了“arpa2fst: command not found”的错误。这可能是因为这些命令所在的目录没有被添加到PATH环境变量中。通常,Kaldi编译后,可执行文件会放在src/bin、src/fstbin等目录下。用户需要检查这些目录是否存在,并将它们添加到PATH中。 接下来看引用[2],用户提到在Kaldi根目录下查找缺失的库,比如libfstscript.so.16。这说明可能需要安装或重新编译OpenFst,因为Kaldi依赖它。如果库文件缺失,可能需要重新配置和编译OpenFst,并确保在编译Kaldi时正确链接这些库。 然后引用[3]中的脚本utils/format_lm_sri.sh调用了arpa2fst命令。如果这个脚本执行失败,可能是因为arpa2fst不在PATH中,或者OpenFst没有正确安装。用户可能需要检查OpenFst的安装情况,并确认相关工具是否可用。 引用[4]提到在Ubuntu上安装Kaldi的官方指南,可能需要用户重新按照步骤检查安装过程,特别是依赖项的安装,如OpenFst和IRSTLM等。 综合这些信息,解决方案可能包括以下几个步骤: 1. 确认Kaldi已经正确编译,尤其是src目录下的相关工具是否生成。 2. 将生成的工具路径添加到环境变量PATH中,方便直接调用。 3. 检查OpenFst的安装,确保库文件和工具正确编译并链接。 4. 如果库文件缺失,可能需要重新编译OpenFstKaldi。 5. 使用提供的脚本时,确保路径正确,并且所有依赖项都已满足。 用户可能需要按照这些步骤逐步排查问题,确保每个部分都正确安装和配置。此外,查看编译过程中的错误日志也有助于定位问题根源。</think>### Kaldi命令未找到问题的解决方案 #### 一、检查命令路径配置 Kaldi编译生成的可执行文件默认存储在以下目录: $$src/bin \quad src/fstbin \quad src/gmmbin \quad src/latbin$$[^2] 请执行以下操作确认路径: ```bash # 进入kaldi根目录 cd ~/kaldi/kaldi/ # 查找命令位置 find . -name fstcompile find . -name arpa2fst ``` 若找到路径,需将其加入环境变量: ```bash export PATH=$PATH:/your/kaldi/path/src/fstbin:/your/kaldi/path/src/bin ``` #### 二、验证OpenFst依赖 Kaldi依赖OpenFst库的完整安装,请检查: ```bash # 查看库文件链接 ldconfig -p | grep libfst # 典型依赖库示例 libfst.so.16 => /usr/local/lib/libfst.so.16 libfstscript.so.16 => /usr/local/lib/libfstscript.so.16 ``` 若发现库文件缺失,需重新编译OpenFst: ```bash cd tools ./extras/install_openfst.sh ``` #### 三、完整重编译流程 建议按标准流程重新编译: ```bash cd kaldi/tools make -j 8 cd ../src ./configure --shared make depend -j 8 make -j 8 ``` 编译成功后,关键工具文件大小应大于100KB: $$ \text{arpa2fst} \geq 120\text{KB}, \quad \text{fstcompile} \geq 110\text{KB} $$ #### 四、验证命令可用性 使用测试命令确认功能正常: ```bash echo "0 1 100 100" | fstcompile arpa2fst --help | head -n 5 ``` 正常输出应包含版本信息: $$ \text{arpa2fst} \quad \text{OpenFst} \quad 1.8.1 $$
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值