Commit 8a2c913b authored by Dan Povey's avatar Dan Povey
Browse files

trunk: add previously missing script get_num_frames.sh

git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@4324 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
parent 9bd10e67
#!/bin/bash
# This script works out the approximate number of frames in a training directory
# this is sometimes needed by higher-level scripts
num_samples=1000
if [ -f path.sh ]; then . ./path.sh; fi
. parse_options.sh || exit 1;
if [ $# -ne 1 ]; then
echo "Usage: $0 <data-dir>"
echo "Prints the number of frames of data in the data-dir, via sampling rather"
echo "than trying to access all the data."
fi
data=$1
if [ ! -f $data/feats.scp ]; then
echo "$0: expected $data/feats.scp to exist"
exit 1;
fi
sample_frames=$(utils/shuffle_list.pl $data/feats.scp | head -n $num_samples | sort | feat-to-len --print-args=false scp:-)
num_files_orig=$(wc -l <$data/feats.scp)
if [ $num_samples -lt $num_files_orig ]; then
num_files_sampled=$num_samples
else
num_files_sampled=$num_files_orig
fi
perl -e "\$n = int(($sample_frames * 1.0 * $num_files_orig) / (1.0 * $num_files_sampled)); print \"\$n\n\";";
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