Commit a43c9a77 authored by Gaurav Kumar's avatar Gaurav Kumar
Browse files

Added scripts for lattice and oracle generation and processing

git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@4240 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
parent eefb92b7
...@@ -10,7 +10,8 @@ if [ $# -lt 3 ]; then ...@@ -10,7 +10,8 @@ if [ $# -lt 3 ]; then
exit 1 exit 1
fi fi
prunebeam=2 prunebeam=50
maxProcesses=10
latdir=$1 latdir=$1
decode_dir=$2 decode_dir=$2
...@@ -33,6 +34,7 @@ then ...@@ -33,6 +34,7 @@ then
mkdir -p $latdir/$compiledLatDir mkdir -p $latdir/$compiledLatDir
mkdir -p $latdir/$preplfLatDir mkdir -p $latdir/$preplfLatDir
runningProcesses=0
for l in $decode_dir/lat.*.gz for l in $decode_dir/lat.*.gz
do do
( (
...@@ -69,11 +71,19 @@ then ...@@ -69,11 +71,19 @@ then
continue continue
fi fi
# Replace laugh, unk, oov, noise with eps # Replace laugh, unk, oov, noise with eps
echo "$line" | awk '{if ($3 == 2038 || $3 == 2039 || $3 == 2040) {$3 = 0; $4 = 0} print}' >> "$latdir/$rawLatDir/$fileName.lat" echo "$line" | awk '{if ($3 == 1157 || $3 == 5327 || $3 == 5328 || $3 == 5329 || $3 ==5326) {$3 = 0; $4 = 0} print}' >> "$latdir/$rawLatDir/$fileName.lat"
done < $bname.ark.fst done < $bname.ark.fst
echo "Done isolating lattices" echo "Done isolating lattices"
fi fi
) & ) &
runningProcesses=$((runningProcesses+1))
echo "#### Processes running = " $runningProcesses " ####"
if [ $runningProcesses -eq $maxProcesses ]; then
echo "#### Waiting for slot ####"
wait
runningProcesses=0
echo "#### Done waiting ####"
fi
done done
wait wait
rm $latdir/*.bin rm $latdir/*.bin
...@@ -82,6 +92,7 @@ then ...@@ -82,6 +92,7 @@ then
if [ $stage -le 2 ]; then if [ $stage -le 2 ]; then
#Compile lattices #Compile lattices
runningProcesses=0
for l in $latdir/$rawLatDir/*.lat for l in $latdir/$rawLatDir/*.lat
do do
( (
...@@ -89,6 +100,14 @@ then ...@@ -89,6 +100,14 @@ then
bname=${l##*/} bname=${l##*/}
fstcompile --arc_type=log $latdir/$rawLatDir/$bname $latdir/$compiledLatDir/$bname fstcompile --arc_type=log $latdir/$rawLatDir/$bname $latdir/$compiledLatDir/$bname
) & ) &
runningProcesses=$((runningProcesses+1))
echo "#### Processes running = " $runningProcesses " ####"
if [ $runningProcesses -eq $maxProcesses ]; then
echo "#### Waiting for slot ####"
wait
runningProcesses=0
echo "#### Done waiting ####"
fi
done done
wait wait
echo "Done compiling lattices." echo "Done compiling lattices."
...@@ -99,6 +118,7 @@ then ...@@ -99,6 +118,7 @@ then
# Create a dummy FST with one state and no arcs first # Create a dummy FST with one state and no arcs first
echo 0 | fstcompile --arc_type=log - $latdir/$preplfLatDir/dummy.fst echo 0 | fstcompile --arc_type=log - $latdir/$preplfLatDir/dummy.fst
# Push Lattice weights towards initial state # Push Lattice weights towards initial state
runningProcesses=0
for l in $latdir/$compiledLatDir/*.lat for l in $latdir/$compiledLatDir/*.lat
do do
( (
...@@ -112,6 +132,14 @@ then ...@@ -112,6 +132,14 @@ then
fstrmepsilon - | \ fstrmepsilon - | \
fstreverse - $latdir/$preplfLatDir/$bname fstreverse - $latdir/$preplfLatDir/$bname
) & ) &
runningProcesses=$((runningProcesses+1))
echo "#### Processes running = " $runningProcesses " ####"
if [ $runningProcesses -eq $maxProcesses ]; then
echo "#### Waiting for slot ####"
wait
runningProcesses=0
echo "#### Done waiting ####"
fi
done done
wait wait
# Let's take a moment to thank the dummy FST for playing its # Let's take a moment to thank the dummy FST for playing its
......
#!/usr/bin/env bash
outDir=exp/lat
mkdir -p $outDir
stage=1
if [ $stage -lt 1 ]; then
# First convert all lattices into the pruned, minimized version
decodeDir=exp/tri5a/decode_dev
acousticScale=0.8333
local/latconvert.sh $outDir $decodeDir $acousticScale
decodeDir=exp/tri5a/decode_test
acousticScale=0.8333
local/latconvert.sh $outDir $decodeDir $acousticScale
fi
if [ $stage -lt 2 ]; then
# Get oracles
latticeDir=exp/tri5a/decode_dev
textFile=data/dev/text
symTable=exp/tri5a/graph/words.txt
local/get_oracle.sh $latticeDir $symTable $textFile
latticeDir=exp/tri5a/decode_test
textFile=data/test/text
symTable=exp/tri5a/graph/words.txt
local/get_oracle.sh $latticeDir $symTable $textFile
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment