me_sgram

来自「speech signal process tools」· 代码 · 共 527 行

TXT
527
字号
#! /bin/sh# This material contains unpublished, proprietary software of # Entropic Research Laboratory, Inc. Any reproduction, distribution, # or publication of this work must be authorized in writing by Entropic # Research Laboratory, Inc., and must bear the notice: ##    "Copyright (c) 1986-1990  Entropic Speech, Inc. #    "Copyright (c) 1990-1991  Entropic Research Laboratory, Inc. #                   All rights reserved"## The copyright notice above does not evidence any actual or intended # publication of this source code.     ## @(#)me_sgram.sh	1.17	3/16/92	ESI/ERL# # Written by:  David Burton# Checked by:# Revised by:  John Shoren# # Brief description:#						#  script to compute maximum-entropy-based FSPEC files for viewing as  #  speech spectrograms - see also plotspgm.sh for plotting 		##  This command file runs the C programs filter, refcof and me_spec.    |#									|#-----------------------------------------------------------------------+#set -x# Check syntaxcase $# in0|1)	echo "Usage: me_sgram [-{pr} range] [-s range] [-P param_file] [-m method]"	echo "     [-a analysis_mthd] [-E pre-emphasis] [-S step_size] [-o analysis_order] "	echo "     [-w window_length] [-d data_window] -D input.SD output.FSPEC" 1>&2	exit 1 ;;esac# initialize variablesLIBDIR=`get_esps_base`/libBINDIR=`get_esps_base`/binprgm=`get_esps_base`/bin/me_sgrammethod=pre_emp= step_size= window_len=data_win=analysis_order=analysis_mthd=infilename=outfilename=-sf=num_points=start_p=nan=range=Dflag=0conv_test=max_iter=S=noP=NOparamfile=# Get command-line optionsletter_opt=for i in $*do	case $letter_opt in	-s)		range=$i		S=yes		letter_opt= ;;	-p)		range=$i		P=yes		letter_opt= ;;	-r)		range=$i		P=yes		letter_opt= ;;	-m)		method=$i		letter_opt= ;;	-P)		paramfile=$i		letter_opt= ;;	-a)		analysis_mthd=$i		letter_opt= ;;	-c)		conv_test=$i		letter_opt= ;;	-i)		max_iter=$i		letter_opt= ;;	-E)		pre_emp=$i		letter_opt= ;;	-S)		step_size=$i		letter_opt= ;;	-w)		window_len=$i		letter_opt= ;;	-d)		data_win=$i		letter_opt= ;;	-o)		analysis_order=$i		letter_opt= ;;	"")		case $i in		-s)			letter_opt=-s ;;		-s*)			range=`echo $i | awk '{print substr($0, 3)}'` 			S=yes			letter_opt= ;;		-p)			letter_opt=-p ;;		-p*)			range=`echo $i | awk '{print substr($0, 3)}'` 			P=yes			letter_opt= ;;		-r)			letter_opt=-r ;;		-r*)			range=`echo $i | awk '{print substr($0, 3)}'` 			P=yes			letter_opt= ;;		-m)			letter_opt=-m ;;		-m*)			method=`echo $i | awk '{print substr($0, 3)}'` 			letter_opt= ;;		-P)			letter_opt=-P ;;		-P*)			paramfile=`echo $i | awk '{print substr($0, 3)}'` 			letter_opt= ;;		-a)			letter_opt=-a ;;		-a*)			analysis_mthd=`echo $i | awk '{print substr($0, 3)}'` 			letter_opt= ;;		-E)			letter_opt=-E ;;		-E*)			pre_emp=`echo $i | awk '{print substr($0, 3)}'`			letter_opt= ;;		-S)			letter_opt=-S ;;		-S*)			step_size=`echo $i | awk '{print substr($0, 3)}'`			letter_opt= ;;		-c)			letter_opt=-c ;;		-c*)			conv_test=`echo $i | awk '{print substr($0, 3)}'`			letter_opt= ;;		-i)			letter_opt=-i ;;		-i*)			max_iter=`echo $i | awk '{print substr($0, 3)}'`			letter_opt= ;;		-w)			letter_opt=-w ;;		-w*)			window_len=`echo $i | awk '{print substr($0, 3)}'`			letter_opt= ;;		-d)			letter_opt=-d ;;		-d*)			data_win=`echo $i | awk '{print substr($0, 3)}'`			letter_opt= ;;		-o)			letter_opt=-o ;;		-o*)			analysis_order=`echo $i | awk '{print substr($0, 3)}'`			letter_opt= ;;		-D)			Dflag=1			letter_opt= ;;		*)			# first is input, last is output			if test $infilename			then				outfilename=$i 			else				infilename=$i			fi ;;		esac	esacdone# check for silly inputcase $letter_opt in-m)	echo $prgm: -m requires argument. 1>&2	exit 1 ;;-a)	echo $prgm: -a requires argument. 1>&2	exit 1 ;;-p)	echo $prgm: -p requires argument. 1>&2	exit 1 ;;-P)	echo $prgm: -P requires argument. 1>&2	exit 1 ;;-s)	echo $prgm: -s requires argument. 1>&2	exit 1 ;;-w)	echo $prgm: -w requires argument. 1>&2	exit 1 ;;-d)	echo $prgm: -d requires argument. 1>&2	exit 1;;-o)	echo $prgm: -o requires argument. 1>&2	exit 1;;-c)	echo $prgm: -c requires argument. 1>&2	exit 1;;-i)	echo $prgm: -i requires argument. 1>&2	exit 1;;esac# Check to see if both -s and -p were usedif test $S = $Pthen	echo "$prgm: -s and -p options cannot both be used" 1>&2	exit 1fi# Check if input file is readableif test ! -r $infilename then	if test $infilename != "-"	then	    echo "$prgm: \"$infilename\" is not a readable file" 1>&2	    exit 1	fifi#create -P optionPoption=if test ! -z "$paramfile"then   Poption="-P $paramfile"fiif test -z "$range"then   P=yes   start_p=`getparam -p start $Poption -c $infilename -z`   if test -z "$start_p"   then     start_p=1   fi   nan=`getparam -p nan $Poption -c $infilename -z`   if test -z "$nan"   then     range=$start_p:   else      if test $nan = "0"     then        range=$start_p:     else	nan=`echo $nan -1 | bc -l`        range=$start_p:+$nan     fi   fifi# if -m not used, set method (including default) if test -z "$method"then  method=`getparam -p method $Poption -c $infilename -z`  if test -z "$method"  then	method=wb  fifi#echo check method for WB NB wb and nbif test "$method" != "wb" then if test "$method" != "nb"  then  if test "$method" != "WB"   then   if test "$method" != "NB"   then    if test "$method" != "other"    then	echo "invalid spectrogram type: $method" 1>&2	exit 1    fi   fi  fi fifi# set parameters for commands#echo set wb and nb parametersif test "$method" = "wb" then# initialize for wide band spectrogramp_e=.94s_s=2w_l=8d_w=RECTa_o=10a_m=fburgfiif test "$method" = "nb"then# initialize for narrow band spectrogramp_e=.94s_s=2w_l=40d_w=RECTa_o=10a_m=fburgfiif test "$method" = "WB"then# initialize for wide band spectrogramp_e=.94s_s=2w_l=8d_w=RECTa_o=10a_m=fburgfiif test "$method" = "NB"then# initialize for narrow band spectrogramp_e=.94s_s=2w_l=40d_w=RECTa_o=10a_m=fburgfiif test "$method" = "other"then# initialize for other spectrogramp_e=.94s_s=2w_l=8d_w=RECTa_o=10a_m=fburgfi# Over ride defaults by command line options#echo Over riding defaultsif test -z "$pre_emp"then  pre_emp=`getparam -p pre_emphasis $Poption -c $infilename -z`  if test -z "$pre_emp"  then	pre_emp=$p_e  fi	fiif test -z "$step_size"then  step_size=`getparam -p step_size $Poption -c $infilename -z`  if test -z "$step_size"  then	step_size=$s_s  fi	fiif test -z "$window_len"then  window_len=`getparam -p window_len $Poption -c $infilename -z`  if test -z "$window_len"  then	window_len=$w_l  fi	fiif test -z "$data_win"then  data_win=`getparam -p window_type $Poption -c $infilename -z`  if test -z "$data_win"  then	data_win=$d_w  fi	fiif test -z "$analysis_order"then  analysis_order=`getparam -p order $Poption -c $infilename -z`  if test -z "$analysis_order"  then	analysis_order=$a_o  fi	fiif test -z "$analysis_mthd"then  analysis_mthd=`getparam -p lpc_method $Poption -c $infilename -z`  if test -z "$analysis_mthd"  then	analysis_mthd=$a_m  fi	fiif test -z "$conv_test"then  conv_test=`getparam -p conv_test $Poption -c $infilename -z`  if test -z "$conv_test"  then	conv_test=1e-5  fi	fiif test -z "$max_iter"then  max_iter=`getparam -p max_iter $Poption -c $infilename -z`  if test -z "$max_iter"  then	max_iter=20  fi	fi#use special common location for passing range option now that paramters#have been obtained as usual; turn verbosity offif test -z "$HOME"then  priv_common=.me_sgram_comelse  priv_common=$HOME/.me_sgram_comfirm -f $priv_commonESPSCOM=$priv_common; export ESPSCOMUSE_ESPS_COMMON=yes; export USE_ESPS_COMMONESPS_VERBOSE=0; export ESPS_VERBOSE# Set range in points in COMMONif test $S = yesthensetrange -z -s$range $infilenameelsesetrange -z -p$range $infilenamefi# Getting sampling frequency#echo Getting sampling frequencysf=`hditem -irecord_freq $infilename`# Computing step and window size#echo Computing step and window sizeif test $step_size -le 0then	echo "$prgm: step_size ($step_size) <= 0" 1>&2	exit 1fistep_size=`echo $step_size*$sf/1000 | bc -l`if test $window_len -le 0then	echo "$prgm: window_len ($window_len) <= 0" 1>&2	exit 1fiwindow_len=`echo $window_len*$sf/1000 | bc -l`# Build pre-emphasis filtercat > /tmp/num$$ <<EOD21 -$pre_empEOD$BINDIR/atofilt -cpre-emphasis  /tmp/num$$ /tmp/pre$$# filter data and compute power spectrums#echo "step_size = $step_size, win_len = $window_len, analysis_order = $analysis_order, data_win = $data_win"if test $Dflag -eq 0then	$BINDIR/filter -F/tmp/pre$$ $infilename - | $BINDIR/refcof -p1:2147483646 -S$step_size -l$window_len -w$data_win -m$analysis_mthd -o$analysis_order -c$conv_test -i$max_iter -z - - | $BINDIR/me_spec -n257 - $outfilename 2>/dev/nullelse	$BINDIR/filter -F/tmp/pre$$ $infilename - | $BINDIR/refcof -p1:2147483646 -S$step_size -l$window_len -w$data_win -m$analysis_mthd -o$analysis_order -c$conv_test -i$max_iter -z - - | $BINDIR/me_spec -n257 - - | $BINDIR/dither - $outfilename 2>/dev/nullfi# clean up any left oversrm /tmp/pre$$ /tmp/num$$ 2>/dev/null

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?