syntdemo
来自「speech signal process tools」· 代码 · 共 290 行
TXT
290 行
#!/bin/csh -f# 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) 1990-1993 Entropic Research Laboratory, Inc. # All rights reserved"## The copyright notice above does not evidence any actual or intended # publication of this source code. ## @(#)syntdemo 1.6 11/26/96 ERL# # Written by: Derek Lin# Checked by: Alan Parker# Revised by:# # Brief description: Example script for ESPS analysis/synthesis programs# using XIG and Xwaves.#Input data file to be analyzed and synthesizedset USE_ESPS_COMMON = offset ESPS_VERBOSE = 0set in = $1#Directory to where intermediate results are written, change this if desiredset DIR = /usr/tmpxwaves -s &echo " "if ($#argv < 1) then echo "No input files found, for DEMO purpose we will use" echo " $ESPS_BASE/demo/speech.sd" echo " " echo "Or you may want to use your own file:" echo "Usage: ProgName <infile>" echo " infile is a FEA_SD/TIMIT data file" echo " " set in = $DIR/speech.sd rm -f $in cp $ESPS_BASE/demo/speech.sd $inendif#Waves object name, and intermediate file name prefixset s = `basename $in`set obj = $s:r#file to contain log error/warning/debug messagesset tmpfile = /usr/tmp/log$$set noglob# Need to provide special play handling for DEC Alpha# because it does not have internal audioset SYSTEM = `uname -s`set play = "$ESPS_BASE/bin/send_xwaves $obj play file "if ($SYSTEM == OSF1) then set play = "$ESPS_BASE/bin/decplay "endifalias sx send_xwavesalias pau 'echo; echo Hit "CONTINUE" to proceed. ; echo " " ; sx pause;'echo "This is an example script for ESPS speech analysis/synthesis tools."echo "We'll will see how to construct a flexible, versatile, and interactive"echo "speech processing environment from ESPS analysis/synthesis programs,"echo "Xwaves+ signal visualization tool, and XIG interface."pauecho "We'll analyze and resynthesize the signal shown on the screen."sx make name $obj file $in loc_x 0 loc_y 160 width 1000 height 150pauecho "A high pass filter to remove low-frequency background noise and breath"echo " noise is designed by win_filt(1-ESPS) and applied to the signal by"echo " filter2(1-ESPS). This filtered signal will be used to do"echo " subsequent analysis."echo " "set sf = `hditem -i record_freq $in`set sf2 = `echo $sf 2 / p q |dc`set ord = `echo $sf 1000 / 2 + p q |dc`cat > $DIR/param$$ <<EODint nbands = 2: "Number of bands:";float band_edge1 = 0;float band_edge2 = 20;float band1_des = 0: "desired value for band1:";float band2_des = 1: "desired value for band2:";float rej_db = 20: "rejection in dB from one band to another:";float trans_band = 50: "transition bandwidth:";EODset str = "float band_edge3 = $sf2;"echo $str >> $DIR/param$$set str = "float samp_freq = $sf;"echo $str >> $DIR/param$$win_filt -P $DIR/param$$ $DIR/h20.filt >& $tmpfilefilter2 -F $DIR/h20.filt -z $in $DIR/$obj.hpf >>& $tmpfilerm -f $DIR/param$$echo "Done with highpass filtering. Now ready to compute F0, voicing"echo " and RMS estimates using get_f0(1-ESPS) on a fixed frame basis."echo " Here we use XIG interface to change the default settings of"echo " get_f0(1-ESPS), if desired; otherwise, click on 'Done' to proceed."xeparam get_f0 $DIR/$obj.hpf $DIR/$obj.f0 >>& $tmpfileecho "Done with F0, voicing, RMS estimation, ready to plot"pausx make name $obj file $DIR/$obj.f0 loc_x 0 loc_y 310 width 1000 heigth 150pausx kill name $obj file $DIR/$obj.f0echo "Fixed-frame analysis, such as the one we just did for F0, usually"echo " renders good F0 and voicing state estimation; however, it doesn't"echo " give good LPC estimation"echo " "echo "We next proceed to estimate LPCs on a pitch-synchronous manner."echo " "echo "First let's find the pitch epochs, which can be estimated from"echo " speech residual -- one that approximates the derivative of the "echo " glottal flow."echo "We'll inverse-filter the speech signal with its running fixed-frame"echo " LPCs to obtain the speech residual."echo " "echo "Fixed frame LPC coefficients can be obtained by refcof(1-ESPS)"echo " Here we use a default setting of order 18, frame length 0.02 sec,"echo " step size 0.01 sec for LPC estimation. Change such default"echo " settings via XIG interface, if desired; otherwise, click on 'Done'."set nsamp = `hditem -i ndrec $DIR/$obj.hpf`cat > $DIR/param$$ <<EODstring window_type ?= "HANNING": "Window to apply to data": {"RECT", "HAMMING", "TRIANG", "HANNING", "COS4"};string method ?= "AUTOC": "Analysis method":{"AUTOC", "COV", "BURG", "MBURG", "FBURG", "VBURG", "STRCOV", "STRCOV1"};float strcov_test ?= 1e-5: "convergence test value for STRCOV";int strcov_maxiter ?= 20: "maximum number of iterations for STRCOV";EODset ord = `echo $sf 1000 / 2 + p q |dc`set str = "int order ?= $ord : "'"Number of reflection coefficients to compute per frame)";'echo $str >> $DIR/param$$set len = `echo "$sf 100 / 2 * p q" |dc`set str = "int frame_len ?= $len : "'"Number of points per analysis frame; 0 means nan";'echo $str >> $DIR/param$$set st = `echo "$sf 100 / p q" |dc`set str = "int step ?= $st : "'"Number or points between start of successive frames; 0 means frame_len";'echo $str >> $DIR/param$$set str = "float preemphasis ?= 0.98 : "'"Preemphasis";'echo $str >> $DIR/param$$expromptrun -P$DIR/param$$ refcof -p1:$nsamp $DIR/$obj.hpf $DIR/$obj.cof >>& $tmpfileecho " "echo "Now we are ready to do inverse-filtering by get_resid(1-ESPS)."get_resid -a1 $DIR/$obj.hpf $DIR/$obj.cof $DIR/$obj.if >>& $tmpfileecho "Done with inverse_filtering(1-ESPS). Now ready to plot the estimated"echo " glottal flow derivative."pausx make name $obj file $DIR/$obj.if loc_x 0 loc_y 310 width 1000 height 150echo "Now we'll attempt to find the picth-epoch location by epoch(1-ESPS)."echo " We use XIG interface to change default parameter settings, if"echo " change is desired."echo " This might take a while..."xeparam epochs $DIR/$obj.if $DIR/$obj.pe >>& $tmpfileecho "Ready to plot the pitch-epochs"pausx make name $obj file $DIR/$obj.pe loc_x 0 loc_y 460 width 1000 height 150echo "Epochs(1-ESPS) acurately finds pitch eopchs of voiced region, but"echo " frequently mislabels in unvoiced regions which should have no"echo " pitch epochs."echo "We can mask out the mislabelled picth epochs in unvoiced regions by"echo " using mask(1-ESPS) according to the voicing estimates previously"echo " computed from the F0 estimator - get_f0(1-ESPS)"mask $DIR/$obj.f0 $DIR/$obj.pe $DIR/$obj.outecho "Ready to plot the new pitch epochs with unvioced regions masked out."pausx kill name $obj file $DIR/$obj.pesx make name $obj file $DIR/$obj.out loc_x 0 loc_y 460 width 1000 height 150echo "Let's take a closer look at estimated pitch epoch locations against"echo " the approximated glottal waveflow."pausx $obj bracket file $DIR/$obj.if start 1.05 end 1.15sx $obj bracket file $DIR/$obj.out start 1.05 end 1.15echo "Finally, with the speech signal and the estimated pitch epochs, we can"echo " do pitch-synchronous LPC estimation by ps_ana(1-ESPS)."echo " "echo "Ps_ana(1-ESPS) optionally computes F0, voicing state, RMS "echo " pitch-synchronously. Final results of ps_ana(1-ESPS) are"echo " uniformly resampled."echo "Again we use XIG interface to change the default parameter settings."echo " Click on 'Done' if no change is desired."xeparam ps_ana -f $DIR/$obj.f0p $DIR/$obj.hpf $DIR/$obj.out $DIR/$obj.rc >>& $tmpfileecho "Done with ps_ana(1-ESPS)"pausx kill name $obj file $DIR/$obj.ifsx kill name $obj file $DIR/$obj.outecho "Now we are ready to resynthsize our speech waveform"echo " "echo "From past experience, F0 and voicing state estimation from"echo " fixed-frame analysis such as get_f0(1-ESPS) are better than those "echo " from pitch-synchronous analysis like ps_ana(1-ESPS)."echo " Let's merge F0 and voicing state estimates from get_f0(1-ESPS) and"echo " RMS estimate from ps_ana(1-ESPS) in a file and use it as a "echo " parameteric source for our synthesizer. Merging can be done by"echo " mergefea(1-ESPS)."echo " "rm -f $DIR/$obj.f0ppmergefea -f rms $DIR/$obj.f0p $DIR/$obj.f0ppmergefea -a -fprob_voice -fF0 $DIR/$obj.f0 $DIR/$obj.f0ppecho "Done with merging, now ready to synthesize using lp_syn(1-ESPS),"echo " from the pitch-synchronously derived LPC estimates and "echo " RMS values, and fixed-frame analysis results of F0 and"echo " voicing state estimates."echo " "echo "Again we use XIG to change parameter settings if desired."pauxeparam lp_syn $DIR/$obj.rc $DIR/$obj.f0pp $DIR/$obj.syn >>& $tmpfileecho "Done with synthesis, ready to plot"pausx make name $obj file $DIR/$obj.syn loc_x 0 loc_y 310 width 1000 height 150echo "Now let's listen to the original and synthesized signals."echo "Here is the original"pau$play $inecho " "echo "Here is the synthesized version"pau$play $DIR/$obj.synecho "So far we have showed ESPS LP synthesizer program in action"echo "We'll now see ESPS cascaded n-formant synthesizer"pausx kill name $obj file $DIR/$obj.synecho "Computing F0 and formants by formant(1-ESPS)..."formant -i0.005 -O $DIR $inecho "Done with formant computation, ready to resynthesize by formsy(1-ESPS);"echo " formsy(1-ESPS) allows you to change F0 and formant characteristics "echo " globally by its XIG interface. It is also possible to"echo " interactively modify F0 and formant tracks by mouse in xwaves."echo " Formsy(1-ESPS) can then resynthesize from these new F0 and formant"echo " tracks."xeparam formsy $DIR/$obj.f0 $DIR/$obj.fb $DIR/$obj.fsyn >>& $tmpfileecho "Here is the resynthsized signal"pausx make name $obj file $DIR/$obj.fsyn loc_x 0 loc_y 310 width 1000 height 150sleep 2$play $DIR/$obj.fsynecho "This concludes our speech analysis/synthesis example"pausx killsx quitrm -f $tmpfilerm -f $DIR/h20.filt $DIR/param$$ $DIR/$obj.cof $DIR/$obj.ds $DIR/$obj.f0rm -f $DIR/$obj.f0p $DIR/$obj.f0pp $DIR/$obj.fb $DIR/$obj.fb.sig $DIR/$obj.fsynrm -f $DIR/$obj.f0p $DIR/$obj.hp $DIR/$obj.hpf $DIR/$obj.if $DIR/$obj.outrm -f $DIR/$obj.pe $DIR/$obj.pole $DIR/$obj.rc $DIR/$obj.syn $DIR/$obj.outrm -f $DIR/log$$if ($#argv < 1) then rm -f $in endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?