fftcep.t

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

T
340
字号
# test script for fftcep @(#)fftcep.t	1.5 1/22/97 ERL#! /bin/csh -x## test script for fftcepset PROG = fftcepsetenv USE_ESPS_COMMON offalias vecho 'if $VERBOSE echo'alias ndrec 'hditem -i ndrec'alias errex 'exit(1)'alias passex 'exit(0)'\rm params >& /dev/null# test script parameters# ----------------------# if test script finds an error, it exits with errex# if program passes the test, test scripts exits with passex# VERBOSE: 0 script works silently#          1 script actual and correct test results are echoedset VERBOSE = 1## VISUAL: 0 script produces no plots#         1 script plots program output and described how it should appearset VISUAL = 0# -----# start# -----vecho "$PROG test script: `date`"testsd -p2000 test.sdd >& /dev/nulltestsd -p2000 -Tgauss -l 2 noiseaddsd test.sdd noise test.sd# test program I/0# ----------------vecho "Checking I/O"set OPT = "-r1:512"set CMD = "$PROG $OPT test.sd test.cep"vecho $CMDif { $CMD >& /dev/null } then	vecho "Command passed."else	vecho "Command failed."	errexendifset CMD = "$PROG $OPT - test.cep"vecho "$CMD < test.sd"($CMD < test.sd) >& /dev/nullif (-e test.cep && ! -z test.cep) then	vecho "Command passed."else	vecho "Command failed."	errexendifset CMD = "$PROG $OPT test.sd -"vecho "$CMD > test.cep"($CMD > test.cep) >& /dev/nullif (-e test.cep && ! -z test.cep) then	vecho "Command passed."else	vecho "Command failed."	errexendif# check Common processing# -----------------------vecho "Checking common processing."unsetenv USE_ESPS_COMMONsetenv ESPSCOM fft_cep_comm.tsetrange -p513:1024 test.sd >& /dev/null$PROG -R -l 512 test.sd test.cep >& /dev/nullif (`hditem -i start test.cep` == 513 && `hditem -i nan test.cep` == 512) then	vecho "Common processing ok."else	vecho "Common processing failed."	errexendif	\rm fft_cep_comm.t >& /dev/nullsetenv USE_ESPS_COMMON offunsetenv ESPSCOM# test parameters# -P -r -l -S -w -o -F -R -e -z # -----------------------------vecho "testing -P option."echo "int    start  =   513;" > fft_cep_param.techo "int    nan    =   512;" >> fft_cep_param.t$PROG -P fft_cep_param.t -R test.sd test.cep >& /dev/nullif (`hditem -i start test.cep` == 513 && `hditem -i nan test.cep` == 512) then	vecho "-P option ok."else	vecho "-P option failed."	errexendif	\rm fft_cep_param.t >& /dev/nullvecho "testing range."$PROG -R -r 513:1024 test.sd test.cep >& /dev/nullset l1 = `hditem -i start test.cep`set l2 = `hditem -i nan test.cep`echo "int    start  =   513;" > paramsecho "int    nan    =   512;" >> params$PROG -R test.sd test.cep >& /dev/nullset l3 = `hditem -i start test.cep`set l4 = `hditem -i nan test.cep`if ( $l1 == 513 && $l3 == 513 && $l2 == 512 && $l4 == 512) then	vecho "range ok."else	vecho "range failed."	errexendif\rm params >& /dev/nullvecho "testing frame_len."set CMD = "$PROG -R -r 513:1024"$CMD -l 0 test.sd test.cep >& /dev/nullset l1 = `hditem -i frmlen test.cep`$CMD -l 128 test.sd test.cep >& /dev/nullset l2 = `hditem -i frmlen test.cep`echo "int  frame_len  = 128;" > params$CMD -l 128 test.sd test.cep >& /dev/nullset l3 = `hditem -i frmlen test.cep`if ( $l1 == 1024 && $l2 == 128 && $l3 == 128 ) then	vecho "frame length ok."else	vecho "frame length failed."	errexendif\rm params >& /dev/nullvecho "testing step size."set CMD = "$PROG -R -r 513:1024 -l128"$CMD test.sd test.cep >& /dev/nullset l1 = `hditem -i step test.cep`$CMD -S 0 test.sd test.cep >& /dev/nullset l2 = `hditem -i step test.cep`$CMD -S 128 test.sd test.cep >& /dev/nullset l3 = `hditem -i step test.cep`echo "int  step  =  128;" > params$CMD test.sd test.cep >& /dev/nullset l4 = `hditem -i step test.cep`if ($l1 == 128 && $l2 == 128 && $l3 == 128 && $l4 == 128) then	vecho "step ok."else	vecho "step failed."	errexendif\rm params >& /dev/nullvecho "testing window type."set CMD = "$PROG -R -r 513:1024 -l128"$CMD test.sd test.cep >& /dev/nullset l1 = `hditem -i window_type test.cep`$CMD -w TRIANG test.sd test.cep >& /dev/nullset l2 = `hditem -i window_type test.cep`echo 'string  window_type = "HAMMING";' > params$CMD test.sd test.cep >& /dev/nullset l3 = `hditem -i window_type test.cep`if ($l1 == "WT_RECT" && $l2 == "WT_TRIANG" && $l3 == "WT_HAMMING") then	vecho "window_type ok."else	vecho "window_type failed."	errexendif\rm params >& /dev/nullvecho "testing order."set CMD = "$PROG -R -r 513:1024 -l128"$CMD test.sd test.cep >& /dev/nullset l1 = `hditem -i order test.cep`$CMD -o 8 test.sd test.cep >& /dev/nullset l2 = `hditem -i order test.cep`echo "int order = 8;" > params$CMD test.sd test.cep >& /dev/nullset l3 = `hditem -i order test.cep`if ($l1 == 10 && $l2 == 8 && $l3 == 8) then	vecho "order ok."else	vecho "order failed."	errexendif\rm params >& /dev/nullvecho "testing float option."set CMD = "$PROG -r513:1024 -l128"$CMD test.sd test.cep >& /dev/nullset l1 = `hditem -i data_type test.cep`set CMD = "$PROG -r513:1024 -l128 -F"$CMD test.sd test.cep >& /dev/nullset l2 = `hditem -i data_type test.cep`set CMD = "$PROG -r513:1024 -l128" echo 'string data_type = "FLOAT";' > params$CMD test.sd test.cep >& /dev/nullset l3 = `hditem -i data_type test.cep`if ($l1 == "FLOAT_CPLX" && $l2 == "FLOAT" && $l3 == "FLOAT") then	vecho "float ok."else	vecho "float failed."	errexendif\rm params >& /dev/nullvecho "testing method option."set CMD = "$PROG -r513:1024 -l128"$CMD test.sd test.cep >& /dev/nullset l1 = `hditem -i cplx_cepstrum test.cep`set CMD = "$PROG -r513:1024 -l128 -R"$CMD test.sd test.cep >& /dev/nullset l2 = `hditem -i cplx_cepstrum test.cep`set CMD = "$PROG -r513:1024 -l128"echo 'string  method = "CEPSTRUM";' > params$CMD test.sd test.cep >& /dev/nullset l3 = `hditem -i cplx_cepstrum test.cep`if ($l1 == "YES" && $l2 == "NO" && $l3 == "NO") then	vecho "method ok."else	vecho "method failed."	errexendif\rm params >& /dev/nullvecho "testing extraction option."set CMD = "$PROG -r513:1024 -l128"$CMD test.sd test.cep >& /dev/nullset l1 = `hditem -i element_range test.cep`set CMD = "$PROG -r513:1024 -l128 -e0:10,20"$CMD test.sd test.cep >& /dev/nullset l2 = `hditem -i element_range test.cep`set CMD = "$PROG -r513:1024 -l128"echo 'string element_range = "0:10,20";' > params$CMD test.sd test.cep >& /dev/nullset l3 = `hditem -i element_range test.cep`if ($l1 == "0:1023" && $l2 == "0:10,20" && $l3 == "0:10,20") then	vecho "extraction ok."else	vecho "extraction failed."	errexendif\rm params >& /dev/nullvecho "testing zeroing option."set CMD = "$PROG -r513:1024 -l128 -z0:10,20"$CMD test.sd test.cep >& /dev/nullset l1 = `hditem -i zeroing_range test.cep`set CMD = "$PROG -r513:1024 -l128"echo 'string zeroing_range = "0:10,20";' > params$CMD test.sd test.cep >& /dev/nullset l2 = `hditem -i zeroing_range test.cep`if ($l1 == "0:10,20" && $l2 == "0:10,20") then	vecho "zeroing ok."else	vecho "zeroing failed."	errexendif\rm params >& /dev/nullvecho "testing multichannel input data."set CMD = "$PROG -r513:1024"mux test.sd test.sd test.mcsd >& /dev/null$CMD test.mcsd test.cep  >& /dev/null(pplain -f cepstrum_0 test.cep > ccep0 ) >& /dev/null(pplain -f cepstrum_1 test.cep > ccep1 ) >& /dev/nullif ( ! -z ccep0 && ! -z ccep1 ) then	vecho "multichannel input ok."else	vecho "multichannel input failed."	errexendif\rm ccep0 ccep1 test.mcsd >& /dev/nullvecho "Checking timing."testsd -r 1024 test.sd >& /dev/null$PROG -r513:+1023 test.sd test.cep >& /dev/nullif (`hditem -i start_time test.cep` == 1) then	vecho "start_time ok."else	vecho "start_time failed."	errexendif$PROG -R -r512:1023 -l512 test.sd test.cep >& /dev/nullif (`hditem -i record_freq test.cep` == 2) then	vecho "record_freq ok."else	vecho "record_freq failed."	errexendif# check functionality# -------------------vecho "Checking fftcep: cepstrum."testsd -f 500 -p 512 test.sd >& /dev/null$PROG -F -R -l512 -r1:512 -o9 -w HAMMING test.sd test.cep >& /dev/nullmake_sd -f cepstrum_0 -S 8000 test.cep test.cepsd >& /dev/nullfft -o9 -l512 -r1:512 test.cepsd test.cspec >& /dev/nullpsps -H test.cspec | awk '{if (NR>4) { if (NR==5) {max=$2; freq=$1} \if (max<=$2) {max=$2;freq=$1}}} END {printf "%d\n", freq}' > test.resset l1 = `cat test.res`if ($l1 == 500) then	vecho "cepstrum computed ok."else	vecho "error in computing cepstrum."	vecho "expecting max value at 500 Hz; actual max at $l1 Hz"	errexendif\rm test.sd test.cep test.cepsd test.cspec test.res >& /dev/nullvecho "Checking fftcep: complex cepstrum."testsd -f 500 -p 512 test.sd >& /dev/null$PROG -F -l512 -r1:512 -o9 -w HAMMING test.sd test.cep >& /dev/nullmake_sd -f cepstrum_0 -S 8000 test.cep test.cepsd >& /dev/nullfft -c -o9 -l512 -r1:512 test.cepsd test.cspec >& /dev/nullpsps -H test.cspec | awk '{if (NR>4) { if (NR==5) {max=$2; freq=$1} \if (max<=$2) {max=$2;freq=$1}}} END {printf "%d\n", freq}' > test.resset l1 = `cat test.res`if ($l1 == 500) then	vecho "complex cepstrum computed ok."else	vecho "error in computing complex cepstrum."	vecho "expecting max value at 500 Hz; actual max at $l1 Hz"	errexendif\rm test.sd test.cep test.cepsd test.cspec test.res >& /dev/nullif ($VISUAL == 1) then	echo "Visual Test: removing glottal pulse from voiced speech."	if ( ! -e /usr/esps/demo/speech.sd ) then 		echo "Sorry, can't find speech file."	else		vecho "plot1: log magnitude of fft spectrum."	endifendif# finished test# -------------# \rm param test.cep test.sd params >& /dev/null\rm test.sdd noisevecho "$PROG test script passed: `date`"passex

⌨️ 快捷键说明

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