2017-09-24 217 views
1

我正在嘗試做ASR系統。我使用卡爾迪手冊和librispeech語料庫。 在數據準備階段我得到這個錯誤Kaldi librispeech數據準備錯誤

utils/data/get_utt2dur.sh: segments file does not exist so getting durations 
from wave files 
utils/data/get_utt2dur.sh: could not get utterance lengths from sphere-file 
headers, using wav-to-duration 
utils/data/get_utt2dur.sh: line 99: wav-to-duration: command not found 

這裏的代碼段,其中此錯誤occures

if cat $data/wav.scp | perl -e ' 
    while (<>) { s/\|\s*$/ |/; # make sure final | is preceded by space. 

     @A = split; 
     if (!($#A == 5 && $A[1] =~ m/sph2pipe$/ && 
          $A[2] eq "-f" && $A[3] eq "wav" && $A[5] eq "|")) { exit (1); } 

     $utt = $A[0]; $sphere_file = $A[4]; 
     if (!open(F, "<$sphere_file")) { die "Error opening sphere file $sphere_file"; } 
      $sample_rate = -1; $sample_count = -1; 
      for ($n = 0; $n <= 30; $n++) { 
       $line = <F>; 
       if ($line =~ m/sample_rate -i (\d+)/) { $sample_rate = $1; } 
       if ($line =~ m/sample_count -i (\d+)/) { $sample_count = $1; 
      } 
      if ($line =~ m/end_head/) { break; } 
     } 
     close(F); 
     if ($sample_rate == -1 || $sample_count == -1) { 
      die "could not parse sphere header from $sphere_file"; 
     } 
     $duration = $sample_count * 1.0/$sample_rate; 
     print "$utt $duration\n"; 
} ' > $data/utt2dur; then 
echo "$0: successfully obtained utterance lengths from sphere-file headers" 
    else 
     echo "$0: could not get utterance lengths from sphere-file headers, 
using wav-to-duration" 
    if command -v wav-to-duration >/dev/null; then 
     echo "$0: wav-to-duration is not on your path" 
     exit 1; 
    fi 

在文件wav.scp我得到了這樣的詩句:

6295-64301-0002 flac -c -d -s /home/tinin/kaldi/egs/librispeech/s5/LibriSpeech/dev-clean/6295/64301/6295-64301-0002.flac | 

在這個數據集中,我只有flac文件(他們通過提供的腳本下載),我不明白爲什麼我們搜索wav文件?另外,如果你向我解釋在這段代碼中發生了什麼,那麼我將非常感謝你,因爲我不熟悉這個代碼。 bash和perl的。

謝謝你很多!

+0

要讓perl做到這一點,它需要有'$ data/wav.scp'文件。目前,它正在輸出else部分,並且因未找到「wav-to-duration」而失敗。 – bytepusher

回答

1

我從該行看到的問題

utils/data/get_utt2dur.sh: line 99: wav-to-duration: command not found 

是,你有沒有在你的路徑添加kaldi工具。 檢查文件路徑。 sh並查看它添加的目錄到你的路徑是正確的(因爲它有../../ ..裏面,它可能不匹配你當前的文件夾設置)

至於perl腳本,它計數聲音文件的樣本,然後它劃分與採樣率以獲得持續時間。不要擔心'wav'這個詞,你的文件可能是另一種格式,它只是kaldi函數的名字。