[ create a new paste ] login | about

Link: http://codepad.org/iXpsXSDx    [ raw code | fork ]

diogenese - Plain Text, pasted on Aug 28:
#!/bin/sh

play="/usr/bin/paplay"
fhe="/usr/bin/flite_hts_engine"

voice="awb"
volume="32000"
freq="16000"
frame="80"
thresh="0.5"
allpass="0.42"
pfc="0.0"
gamma=0

usage() {
    cat <<EOF
Usage: ${0} [options] [voice abbr] [input text file]
Where options are:
	-o --output <file>		Save to wave file [def:none]
	-v --volume <0-65536>		Set output volume [def:32000]
	-f --frequency <1-48000>	Set output sample frequency [def:16000]
	-p --period <1-->		Set frame period [def:80]
	-t --threshold <0.0-1.0>	Set voice/unvoice threshold [def:0.5]
	-a --all-pass <0.0-1.0>		Set all pass constant [def:0.42]
	-g --gamma <0-->		Set gamma = -1/i (i==0 => gamma=0)
	-s --say "some text"		Text to say 

	voice abbr: awb bdl clb jmk rms slt
	input text file: Say text file. Replace text if supplied
EOF
}

wave="${TMP-/tmp}/hts_$$.wav"

while [ $# -gt 0 ]; do
    case "$1" in
	-o|--output) # save wave file to
            output="$2"
            shift
            ;;
	-v|--volume) # volume 0-65535
            volume="$2"
	    shift
            if [ $volume -lt 0 -o $volume -gt 65536 ]; then
                echo "Error: Volume out of range! [0-65536]"
                exit 1
            fi
            ;;
	-f|--freq) # frequency 1-48000
            freq="$2"
            shift
            if [ $freq -le 0 -o $freq -gt 48000 ]; then
                echo "Error: Sample frequency out of range! [1-48000]"
                exit 1
            fi
            ;;
	-t|--thresh|--threshold) # voiced/unvoiced threshold [0.0-1.0]
            thresh="$2"
            shift
            ;;
	-a|--all-pass) # all-pass constant [0.0-1.0]
            allpass="$2"
            shift
            ;;
	-g|--gamma) # gamma = -1/i (i=0 => gamma=0) [0--]
            gamma="$2"
            shift
            ;;
	-c|--pfc) # postfilter coefficient [-8.0-8.0]
            pfc="$2"
            shift
            ;;
	-p|--period)
	    frame="$2"
	    shift
	    ;;
	-s|--say)
	    input="${TMP-/tmp}/hts_$$.txt"
	    echo $2 > "${input}"
	    shift
	    ;;
	awb|bdl|clb|jmk|rms|slt)
	    voice="$1"
	    ;;
	-h|--help)
	    usage
	    exit 0
	    ;;
	*)
	    if [ -f $1 ]; then
		input="$1"
	    else
		echo "Uknown paramter: $1"
	    fi
	    ;;
    esac
    shift       # Check next set of parameters.
done

# hts data directory
hts="/usr/share/festival/voices/english/nitech_us_${voice}_arctic_hts/hts"

$fhe -dm1 ${hts}/mgc.win1 -dm2 ${hts}/mgc.win2 -dm3 ${hts}/mgc.win3 \
    -df1 ${hts}/lf0.win1 -df2 ${hts}/lf0.win2 -df3 ${hts}/lf0.win3 \
    -td ${hts}/tree-dur.inf -tm ${hts}/tree-mgc.inf -tf ${hts}/tree-lf0.inf \
    -em ${hts}/tree-gv-mgc.inf -ef ${hts}/tree-gv-lf0.inf -md ${hts}/dur.pdf \
    -mm ${hts}/mgc.pdf -mf ${hts}/lf0.pdf -cm ${hts}/gv-mgc.pdf \
    -cf ${hts}/gv-lf0.pdf -k ${hts}/gv-switch.inf \
    -s ${freq} -p ${frame} -a ${allpass} -u ${thresh} -g ${gamma} -b ${pfc} \
    -o $wave $input


if [ -f "$wave" ]; then 
    $play --volume=${volume} $wave

    if [ "x$output" = "x" ]; then
	rm -f "$wave"
    else
	mv -f "$wave" "$output"
    fi
fi



Create a new paste based on this one


Comments: