kaldi生成自己数据的mfcc

两个月前为了走通整个流程,只是在yesno中生成了部分样本的mfcc,针对大批量数据的训练需求远不能满足,因此必须走出这种有风险的方法。

今天介绍一种没有任何遗漏的方法,整体流程如下:

1、修改wav文件为真正的wav文件:

#!/bin/bash
indexForSave = wav
for file in /home/kaldi/examples/*
do
   if [ -d "$file" ]                     
   then
      echo "$file is a directory"
   elif [ -f "$file" ]
   then
      echo "$file is a file"
	  #echo ${fileForSave}${file%.*}${indexForSave}
	  ffmpeg -i ${file} -ar 1600 ${file%.*}".wav"
   fi
done

2、准备工程目录文件:

以嫁接的方式还在yesno中进行准备,所以不必创建data、conf、local、steps、utils等文件夹及其内部相关脚本文件。

1)、在data内新建test文件夹,这个文件夹内需要三个文件:wav.scp、utt2spk、spk2utt,格式分别如下:

wav.scp: 

test1 test/test1.wav

test2 test/test2.wav

test3 test/test3.wav

utt2spk:

test1 global

test2 global

test3 global

spk2utt:

global test1 test2 test3

至此,都准备好了。

2)、修改conf文件夹内的conf文件中的8000为1600

3)、写脚本实现提取特征:

#!/bin/bash

train_cmd="utils/run.pl"
decode_cmd="utils/run.pl"

# Feature extraction
for x in test; do 
 steps/make_mfcc.sh --nj 1 data/$x exp/make_mfcc/$x mfcc
done
3、为了避免如下错误出现,进行修改源码:

utils/validate_data_dir.sh: utt2spk is not in sorted order when sorted first on speaker-id 
(fix this by making speaker-ids prefixes of utt-ids)
找到文件 出错文件件,修改为如下代码:

check_sorted_and_uniq $data/utt2spk
#if ! $no_spk_sort; then
#  ! cat $data/utt2spk |sort -u|uniq |sort -k2 | cmp -s - $data/utt2spk && \
#     echo "$0: utt2spk is not in sorted order when sorted first on speaker-id " && \
#     echo "(fix this by making speaker-ids prefixes of utt-ids)" && exit 1;
#fi

4、运行s5中的run.sh文件,生成结果在mfcc文件内。

5、为了可视化特征数据,对生成的mfcc/raw_mfcc_test1.1.ark进行转换:

/home/kaldi/src/featbin/copy-feats ark:/home/kaldi/egs/yesno/s5/mfcc/raw_mfcc_test.1.ark ark,t:copy4.txt
至此,在项目跟目录下即可看到已经转换好的文件copy4.txt,内容如下:

test1  [
  16.11501 -14.6801 -20.28999 -4.350059 -7.852748 -7.136274 6.838698 -6.445731 3.465607 1.650866 2.449686 -1.091172 3.505853 
  20.49912 -7.514845 6.58767 -2.504859 7.047224 -2.105474 8.218792 5.698094 -4.918198 -15.46097 -2.552441 10.24138 -0.9173498 
  66.97064 -6.471962 -2.231833 4.431138 -16.17352 10.50142 -7.338736 -15.85075 7.795192 -1.807603 -6.524718 1.924375 -0.6301212 
  70.47792 -9.600613 0.5532729 4.431138 -17.66381 7.636552 -15.60448 -1.581066 4.663292 1.650866 1.714079 0.2356682 -19.55912 
  68.72428 -6.81959 -12.90807 -3.48173 -16.91867 4.771686 8.218792 -14.39135 -7.484668 5.801028 -3.876533 -1.694282 6.319921 
  70.47792 -6.81959 -13.74152 -2.6134 13.96665 -9.86728 3.388465 1.8242 -19.54714 3.034253 -22.42225 18.47069 -13.61175 
  66.09382 -9.600613 -20.17092 0.884684 -2.388359 -5.123955 -1.441861 0.8512669 4.663292 -10.44998 -27.3418 2.28624 -13.11613 
  69.6011 -9.252985 -20.05186 -12.49065 -27.13936 -1.818001 5.458605 -3.851243 -6.286982 2.515483 0.5371084 7.352358 3.505853 
  66.97064 -13.09431 -6.873677 2.657911 17.11185 -0.2418299 -16.67597 -30.5313 -25.70683 10.29704 10.2323 18.92787 -0.534379 
  69.6011 -6.471962 -13.62245 -22.13002 -6.859222 -4.692743 -18.97201 25.55484 8.578167 -2.845144 6.12772 5.301786 1.284733 
  70.47792 -16.45244 -16.59903 -29.41717 -16.79448 6.204119 -11.77775 23.46465 7.795192 -6.870705 9.558505 16.64195 -3.215175 
  66.97064 -9.94824 -5.016939 -10.64545 -0.5012425 13.36628 6.838698 -3.040465 -28.01672 -9.734127 -20.57742 17.55632 2.050674 
  65.217 -7.514845 -6.873677 -19.32727 -11.33009 12.65007 2.698419 -12.60764 14.05899 9.432421 -11.96821 -4.709828 -20.55035 
  72.23157 -7.862473 -2.696018 -1.479618 -0.5012425 -8.717382 -5.961111 1.013422 -4.918198 -15.46097 -3.582291 -4.951072 13.15409 
  70.47792 -12.44134 -9.194598 -12.92481 -12.4478 -13.31697 -6.726458 19.28429 10.14412 6.665646 -10.20275 -9.034351 2.816616 
  72.89487 -5.776707 -13.74152 -3.48173 -7.231794 -10.44223 -7.491805 15.10392 -10.22224 -24.76709 -11.82109 7.352358 3.907863 
  69.6011 -6.124334 -10.58715 -3.48173 -16.67028 -9.148594 -0.7518145 7.788278 2.610115 -3.709761 -9.172902 17.09914 -25.50649 
  70.47792 -7.862473 0.08908796 0.2936084 -15.42838 -5.698903 -15.60448 4.653002 3.807802 1.477942 -18.11765 0.5975342 -6.278941 
  68.72428 -10.38915 -16.00372 -10.86253 5.160107 6.204119 9.598886 26.59993 5.446267 -7.586559 -27.3418 1.924375 2.337902 
  72.80012 -3.69094 -5.016939 -9.560036 -18.83818 -3.399109 -10.55319 30.7803 -1.838433 -8.302418 -9.761388 4.578055 -2.066262 
  69.6011 -7.862473 -1.303465 -7.17213 -9.343036 1.190603 4.768559 17.19411 -14.15749 -11.88169 4.656506 8.869834 -6.183198 
  71.35475 -10.94884 -11.9797 0.2936084 -11.57847 1.190603 -14.22686 -2.87831 -3.549414 17.37671 -4.317897 3.009971 -6.087456 
  71.35475 -4.038568 -5.481124 -9.88566 -11.33009 -10.87344 -12.54309 -14.55351 4.321096 0.9591722 -8.437296 -11.10131 -0.2471504 
  68.72428 -11.50853 -13.1462 -2.939024 -13.06876 -14.32313 7.528745 7.788278 14.84197 -0.7700624 -0.0513773 17.09914 -0.1514082 
  70.47792 -11.32196 -24.93345 -11.40524 -8.10113 15.51493 2.698419 22.41957 24.23767 -10.44998 3.626657 -0.005575657 -10.63807 
  66.97064 -8.557729 -11.05134 -0.8885428 -18.03638 1.190603 2.698419 22.41957 -10.22224 12.37212 13.60127 12.5273 -10.63807 
  70.47792 -10.29587 -6.873677 -0.2974672 -12.19942 -0.9580464 -4.583487 24.50975 -16.38177 -8.302418 -24.88203 8.869834 -1.779034 
  70.47792 -10.38915 -6.409493 -5.869636 -8.34951 17.66359 -10.55319 -18.4226 -10.05114 -4.055608 -16.88776 8.869834 -8.863995 
  68.72428 2.913988 -18.50404 -14.01023 -2.388359 6.204119 -17.74745 16.14901 2.096821 -14.02926 -10.49699 5.784274 -9.646837 
  70.47792 -13.18759 -17.43247 -11.07961 -7.355986 13.36628 3.388465 16.14901 -9.537844 -0.9429855 -9.908509 -10.58457 -0.2471504 
  71.35475 -6.124334 -11.05134 -2.830482 19.628 1.90682 -4.277348 3.60791 -10.73553 -11.88169 -18.73259 4.698677 8.32997 
  70.47792 -9.600613 -7.802046 -2.070694 3.90203 -1.674263 10.28893 10.92355 -22.62699 -8.302418 -11.96821 14.81322 -5.321514 
  68.72428 -7.167218 -1.767649 -5.109847 3.272991 -13.46071 -15.91062 31.82539 -23.39695 -13.3134 5.392113 -18.33567 7.525951 
  80.57028 -1.257546 -20.76624 -19.88782 -25.47913 -7.423748 2.698419 -14.2292 -22.62699 1.132095 -9.908509 -10.06783 -8.00231 



参考:http://blog.csdn.net/jojozhangju/article/details/36279703

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值