speech-recognitionkaldi

Unable to extract delta and delta delta power spectrum computation


I am currently trying to extract the delta + delta-delta using add-deltas binary file provided by kaldi. But for some reason i am not able to extract it.

I usually extract power spectrum using the make_spectrum.sh script. I modified it a bit to also include deltas, but the output doesn't to be any different to the one received without the delta part..

What am i doing wrong?

$cmd JOB=1:$nj $logdir/spect_${name}.JOB.log \
    compute-spectrogram-feats --frame-length=25 --frame-shift=10 --verbose=2 \
     scp,p:$logdir/wav_spect_${name}.JOB.scp ark:- \| \
    copy-feats --compress=$compress $write_num_frames_opt ark:- \
      ark,scp:$specto_dir/raw_spectogram_$name.JOB.ark,$specto_dir/raw_spectogram_$name.JOB.scp \| \
      add-deltas ark:- ark,scp:$specto_dir/raw_spectogram_$name.JOB.ark,$specto_dir/raw_spectogram_$name.JOB.scp \

Solution

  • The output of every command in a pipe is passed to the next command. There is no way to write the output to a file and pass it to the next command in the same time. You are trying to write data in compress-feats and in the same time you are trying to pass it to the add-deltas.

    You can not write both raw and delta feats with a single command. Either you write deltas without writing raw passing stdout of compute-feats to add-deltas:

    $cmd JOB=1:$nj $logdir/spect_${name}.JOB.log \
        compute-spectrogram-feats --frame-length=25 --frame-shift=10 --verbose=2 \
          scp,p:$logdir/wav_spect_${name}.JOB.scp ark:- \| 
        add-deltas ark:- ark,scp:$specto_dir/delta_spectogram_$name.JOB.ark,$specto_dir/delta_spectogram_$name.JOB.scp
    

    Or run two jobs:

    $cmd JOB=1:$nj $logdir/spect_${name}.JOB.log \
        compute-spectrogram-feats --frame-length=25 --frame-shift=10 --verbose=2 \
         scp,p:$logdir/wav_spect_${name}.JOB.scp ark:- \| \
        copy-feats --compress=$compress $write_num_frames_opt ark:- \
          ark,scp:$specto_dir/raw_spectogram_$name.JOB.ark,$specto_dir/raw_spectogram_$name.JOB.scp
    
    $cmd JOB=1:$nj $logdir/spect_${name}_deltas.JOB.log \
          add-deltas scp:$specto_dir/raw_spectogram_$name.JOB.scp ark,scp:$specto_dir/delta_spectogram_$name.JOB.ark,$specto_dir/delta_spectogram_$name.JOB.scp \
    

    It is possible to do tricks with named pipes to combine those two in a single command, but I would not recommend that. It is more straightforward to simply run the single job above