bs_dist.tst
来自「speech signal process tools」· TST 代码 · 共 1,159 行 · 第 1/3 页
TST
1,159 行
gv_src_sf="8000" gv_start_time="0.466" for i in \ record_freq src_sf start_time do x=`hditem -i $i out2.fea` eval "pat=\$gv_$i" case "$x" in '') echo "* * * ERROR: header item $i is missing" ;; *) case `echo "scale=20;" \ "if (($pat) >= 0) {" \ " if (($x) < 0.9999 * ($pat)) \"NOT\";" \ " if (($pat) < 0.9999 * ($x)) \"NOT\"};" \ "if (($pat) < 0) {" \ " if (($x) > 0.9999 * ($pat)) \"NOT\";" \ " if (($pat) > 0.9999 * ($x)) \"NOT\"};" \ "\"OK\"" | bc` in OK) : ;; *) echo "* * * ERROR: header item $i is $x; should be $pat" ;; esac ;; esac done x=`hditem -i perceptual_weights out2.fea` y=`echo "1.00051224 1.00148221 1.00308900 1.00554334 1.00918270" \ "1.01454247 1.02248820 1.03447494 1.05309536 1.08335560" \ "1.13603451 1.23807577 1.47220992 2.15881055 3.68948410"` case "$x" in '') echo "* * * ERROR: header item perceptual_weights is missing" ;; *) echo "$y" | testsd -a- tmp.sd echo "$x" \ | testsd -a- - \ | addsd -g-1 tmp.sd - - \ | feafunc -f samples -f- -FABS - dif.sd rm -f tmp.sd `get_esps_base`/bin/select -o tmp.sd -q'samples > 1.0e-4' \ dif.sd 2>/dev/null 1>&2 n=`hditem -i ndrec tmp.sd` if test "$n" -ne 0 then echo "* * * ERROR: header item perceptual_weights is:" echo "$x" echo "should be:" echo "$y" fi esac## --- Data (2)if feaop -f BSD -f BSD \ -f BSD_dif -O SUB out2.fea ref2.fea - \ | feafunc -fBSD_dif -f- -FABS - dif2.feathen rm -f tmp.fea `get_esps_base`/bin/select -o tmp.fea \ -q'max(BSD_dif) > 1.0e-5' dif2.fea 2>/dev/null 1>&2 n=`hditem -i ndrec tmp.fea` if test "$n" -ne 0 then echo "* * * ERROR: BSD disagrees with ref in $n records" fielse echo "* * * ERROR: couldn't form BSD difference " \ "between out2.fea and ref2.fea"fi## RUN PROGRAM (3) --- same as (2), but use -a (and no output filename)echo 'Running command (3):'echo ' ./bs_dist -a -e81000 -mBSD -r2:8 -r3: \ tstA.bark tstB.bark >log3.txt 2>err3.txt'./bs_dist -a -e81000 -mBSD -r2:8 -r3: \ tstA.bark tstB.bark >log3.txt 2>err3.txtgrep -v 'tags mismatch' err3.txt## CHECK OUTPUT (3)## --- STDOUT OUTPUT (3)echo '... checking stdout output'x=`cat log3.txt`pat="0.0437978823269627804894"case "$x" in'') echo "* * * ERROR: no output to stdout";;*) case `echo "scale=20;" \ "if (($x) < 0.9999 * ($pat)) \"NOT\";" \ "if (($pat) < 0.9999 * ($x)) \"NOT\";" \ "\"OK\"" | bc` in OK) : ;; *) echo "* * * ERROR: output distortion is $x; should be $pat" ;; esac;;esac## RUN PROGRAM (4) --- parameter file (non-default weights)## --- MAKE PARAM FILE (4)echo 'Making param file testparam'cat > testparam <<aArDvArKint start = {2, 3};int nan = 7;string distortion_type = "BSD";float threshold = 8.1e4;float perceptual_weights = { 1.000607550366242951819855, 1.001758006620397924595494, 1.003663779788576426690981, 1.006574805820023141166304, 1.010891344359015169714892, 1.017248419079103983758377, 1.026672637140569448031075, 1.040889779505518395102462, 1.062974940421044839783725, 1.098865783019753666090255, 1.161346779304804727821266, 1.282375112927449676974550, 1.560075177063605713651781, 2.374433256110570872003378, 4.189922977476159962080278};aArDvArKecho 'Running command (4):'echo ' ./bs_dist -A -P testparam \ tstA.bark tstB.bark out4.fea >log4.txt 2>err4.txt'./bs_dist -A -P testparam \ tstA.bark tstB.bark out4.fea >log4.txt 2>err4.txtgrep -v 'tags mismatch' err4.txt## CHECK OUTPUT (4)## --- STDOUT OUTPUT (4)echo '... checking stdout output'x=`cat log4.txt`pat="0.0440990096095552297778"case "$x" in'') echo "* * * ERROR: no output to stdout";;*) case `echo "scale=20;" \ "if (($x) < 0.9999 * ($pat)) \"NOT\";" \ "if (($pat) < 0.9999 * ($x)) \"NOT\";" \ "\"OK\"" | bc` in OK) : ;; *) echo "* * * ERROR: output distortion is $x; should be $pat" ;; esac;;esac## --- FEA OUTPUT (4)echo '... making comparison file ref4.fea'esig2fea - ref4.fea <<aArDvArKEsignal 0.0B ASCII 48 14446 -1Tag: LONG <r>BSD: FLOAT <r>nan: LONG 1 <g> [0] 7perceptual_weights: FLOAT 15 <g> [0] 1.000607550 1.001758007 1.003663780 1.006574806 [4] 1.010891344 1.017248419 1.026672637 1.040889780 [8] 1.062974940 1.098865783 1.161346779 1.282375113 [12] 1.560075177 2.374433256 4.189922977src_sf: DOUBLE 1 <g> [0] 8000.000000000000distortion_type: SHORT 1 <g> [0] 1distortion_type.enumStrings: CHAR 3 5 <g> [0][0] "NONE\0" [1][0] "BSD\0\0" [2][0] "MBSD\0"start: LONG 2 <g> [0] 2 3record_freq: DOUBLE 1 <g> [0] 500.0000000000000threshold: DOUBLE 1 <g> [0] 81000.00000000000start_time: DOUBLE 1 <g> [0] 0.4660000000000000recordFreq: DOUBLE <g> 500.0000000000000startTime: DOUBLE 1 <g> [0] 0.4660000000000000[Record 0] [BSD] 0.129398393852935876783138 [Tag] 3697[Record 1] [BSD] 0.764496249400356633897283 [Tag] 3713[Record 2] [BSD] 0.154410894933697592945573 [Tag] 3729[Record 3] [BSD] 0.421274287454009042311889 [Tag] 3745[Record 4] [BSD] 0.169792954154190195343840 [Tag] 3761[Record 5] [BSD] 0.105436918226478077450091 [Tag] 3777[Record 6] [BSD] 0.420087694548040124689940 [Tag] 3793aArDvArK## --- Check FEA output (2)echo '... checking output'## --- Header (4)# tagged?if psps -D out4.fea | grep ' not *tagged' >/dev/nullthen echo "* * * ERROR: file is not tagged; should be tagged"fi# generic string valuesgv_distortion_type="BSD"for i in \ distortion_typedo x=`hditem -i $i out4.fea` eval "pat=\$gv_$i" case "$x" in "$pat") : ;; '') echo "* * * ERROR: header item $i is missing" ;; *) echo "* * * ERROR: header item $i is \"$x\"; should be \"$pat\"" ;; esacdone# generic integer values gv_nan="7" gv_ndrec="7" for i in \ nan ndrec do x=`hditem -i $i out4.fea` eval "pat=\$gv_$i" case "$x" in '') echo "* * * ERROR: header item $i is missing" ;; *) case `echo "if ($x == $pat) \"OK\"" | bc` in OK) : ;; *) echo "* * * ERROR: header item $i is $x; should be $pat" ;; esac ;; esac done x=`hditem -i start out4.fea` start_0=2 start_1=3 case "$x" in '') echo "* * * ERROR: header item start is missing" ;; *) n=0 for i in $x do n=`expr $n + 1` done if test $n -ne 2 then echo "* * * ERROR: header item start has wrong length" else n=0 for i in $x do eval "y=\$start_$n" if test $i -ne $y then echo "* * * ERROR: header item start[$n] is $i;" \ "should be $y" fi n=`expr $n + 1` done fi ;; esac # generic floating-point values gv_record_freq="500" gv_src_sf="8000" gv_start_time="0.466" for i in \ record_freq src_sf start_time do x=`hditem -i $i out4.fea` eval "pat=\$gv_$i" case "$x" in '') echo "* * * ERROR: header item $i is missing" ;; *) case `echo "scale=20;" \ "if (($pat) >= 0) {" \ " if (($x) < 0.9999 * ($pat)) \"NOT\";" \ " if (($pat) < 0.9999 * ($x)) \"NOT\"};" \ "if (($pat) < 0) {" \ " if (($x) > 0.9999 * ($pat)) \"NOT\";" \ " if (($pat) > 0.9999 * ($x)) \"NOT\"};" \ "\"OK\"" | bc` in OK) : ;; *) echo "* * * ERROR: header item $i is $x; should be $pat" ;; esac ;; esac done x=`hditem -i perceptual_weights out4.fea` y=`echo "1.000607550366242951819855 1.001758006620397924595494" \ "1.003663779788576426690981 1.006574805820023141166304" \ "1.010891344359015169714892 1.017248419079103983758377" \ "1.026672637140569448031075 1.040889779505518395102462" \ "1.062974940421044839783725 1.098865783019753666090255" \ "1.161346779304804727821266 1.282375112927449676974550" \ "1.560075177063605713651781 2.374433256110570872003378" \ "4.189922977476159962080278"` case "$x" in '') echo "* * * ERROR: header item perceptual_weights is missing" ;; *) echo "$y" | testsd -a- tmp.sd echo "$x" \ | testsd -a- - \ | addsd -g-1 tmp.sd - - \ | feafunc -f samples -f- -FABS - dif.sd rm -f tmp.sd `get_esps_base`/bin/select -o tmp.sd -q'samples > 1.0e-4' \ dif.sd 2>/dev/null 1>&2 n=`hditem -i ndrec tmp.sd` if test "$n" -ne 0 then echo "* * * ERROR: header item perceptual_weights is:" echo "$x" echo "should be:" echo "$y" fi esac## --- Data (4)if feaop -f BSD -f BSD \ -f BSD_dif -O SUB out4.fea ref4.fea - \ | feafunc -fBSD_dif -f- -FABS - dif4.feathen rm -f tmp.fea `get_esps_base`/bin/select -o tmp.fea \ -q'max(BSD_dif) > 1.0e-5' dif4.fea 2>/dev/null 1>&2 n=`hditem -i ndrec tmp.fea` if test "$n" -ne 0 then echo "* * * ERROR: BSD disagrees with ref in $n records" fielse echo "* * * ERROR: couldn't form BSD difference " \ "between out4.fea and ref4.fea"fi## RUN PROGRAM (5) --- MBSD
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?