#!/usr/bin/env bash # Copyright 2014 Vassil Panayotov # 2017 Daniel Povey # Apache 2.0 if [ $# -ne "3" ]; then echo "Usage: $0 /dev/null | awk '{print $1}' || stat '-f %z' $f) if [[ "$fsize" -eq "$expect_size" ]]; then echo "'$fname' already exists and appears to be complete" return 0 else echo "WARNING: '$fname' exists, but the size is wrong - re-downloading ..." fi fi wget --no-check-certificate -O $dst_dir/$fname $base_url/$fname || { echo "Error while trying to download $fname!" return 1 } f=$dst_dir/$fname # In the following statement, the first version works on linux, and the part after '||' # works on Linux. fsize=$(set -o pipefail; du -b $f 2>/dev/null | awk '{print $1}' || stat '-f %z' $f) [[ "$fsize" -eq "$expect_size" ]] || { echo "$fname: file size mismatch!"; return 1; } return 0 } mkdir -p $dst_dir $local_dir for f in 3-gram.pruned.1e-7.arpa.gz 3-gram.pruned.3e-7.arpa.gz \ librispeech-vocab.txt librispeech-lexicon.txt; do check_and_download $f || exit 1 done dst_dir=$(readlink -f $dst_dir) ln -sf $dst_dir/3-gram.pruned.1e-7.arpa.gz $local_dir/lm_tgmed.arpa.gz ln -sf $dst_dir/3-gram.pruned.3e-7.arpa.gz $local_dir/lm_tgsmall.arpa.gz ln -sf $dst_dir/librispeech-lexicon.txt $local_dir/librispeech-lexicon.txt ln -sf $dst_dir/librispeech-vocab.txt $local_dir/librispeech-vocab.txt exit 0