online works in bash
#!/bin/bash
-# Include Path
+# Get run command (which logs) from script file
+. ./cmd.sh
+# Put typical Kaldi binaries onto the path
. ./path.sh
-# AUDIO --> FEATURE VECTORS
+
+# Add online binaries to PATH
+export PATH=$PATH:/kaldi/src/online2bin
+
+# Extract feature vectors for online training
echo "==== Extracting Feature Vectors ===="
steps/make_mfcc.sh --nj 1 data/infer exp/make_mfcc/infer mfcc
+# Apply cepstral mean variance normalisation and add delta features
echo "==== Applying CMVN ===="
-apply-cmvn --utt2spk=ark:data/infer/utt2spk \
+/kaldi/src/featbin/apply-cmvn --utt2spk=ark:data/infer/utt2spk \
scp:mfcc/cmvn_test.scp \
scp:mfcc/raw_mfcc_infer.1.scp ark:- | \
- add-deltas ark:- ark:data/infer/delta-feats.ark
+ /kaldi/src/featbin/add-deltas ark:- ark:data/infer/delta-feats.ark
-# TRAINED GMM-HMM + FEATURE VECTORS --> LATTICE
-echo "==== Producing Lattice ===="
-gmm-latgen-faster \
- --word-symbol-table=exp/tri1/graph/words.txt \
- exp/tri1/final.mdl \
- exp/tri1/graph/HCLG.fst \
- ark:data/infer/delta-feats.ark \
- ark,t:data/infer/lattices.ark
+# Compute cepstral mean variance normalisation stats for online training
+/kaldi/src/featbin/compute-cmvn-stats ark:data/infer/delta-feats.ark cmvn.scp
+# This file's existence is required for online decoding, though it needs no content
+echo "# dummy file" > ./conf/online_cmvn.conf
+
+# Takes an offline model and creates and online variant
./steps/online/prepare_online_decoding.sh \
+ --cmd "$train_cmd" \
data/train \
data/lang \
- exp/tri \
- exp/tri/final.mdl \
- exp/tri_online
+ exp/tri1 \
+ exp/tri1_online
-/kaldi/src/featbin/compute-cmvn-stats ark:data/infer/delta-feats.ark cmvn.scp
+# Manipulate the wav.scp file in the first (and only) split
+line=$(head -n 1 ./data/infer/spk2utt) && \
+ utt=` echo ${line} | cut -d ' ' -f 2` &&
+ echo "${utt} ./20030518Abui2PieterFrogDogBoy.wav" > ./data/infer/split1/1/wav.scp
-/kaldi/src/online2bin/online2-wav-gmm-latgen-faster \
- --model=exp/tri/final.mdl \
- --global-cmvn-stats=cmvn.scp \
- exp/tri/graph/HCLG.fst \
- ark:data/infer/spk2utt \
- scp:wav.scp \
- ark:data/infer/lattices.ark
\ No newline at end of file
+# Decodes all audio in the wav.scp path specified above
+steps/online/decode.sh \
+ --config conf/decode.config \
+ --cmd "$decode_cmd" \
+ --nj 1 \
+ exp/tri1/graph \
+ data/infer \
+ exp/tri1_online/decode
