| 1 |
#!/bin/sh |
| 2 |
#####################################################-*-mode:shell-script-*- |
| 3 |
## ## |
| 4 |
## Carnegie Mellon University and ## |
| 5 |
## Alan W Black and Kevin A. Lenzo ## |
| 6 |
## Copyright (c) 1998-2000 ## |
| 7 |
## All Rights Reserved. ## |
| 8 |
## ## |
| 9 |
## Permission is hereby granted, free of charge, to use and distribute ## |
| 10 |
## this software and its documentation without restriction, including ## |
| 11 |
## without limitation the rights to use, copy, modify, merge, publish, ## |
| 12 |
## distribute, sublicense, and/or sell copies of this work, and to ## |
| 13 |
## permit persons to whom this work is furnished to do so, subject to ## |
| 14 |
## the following conditions: ## |
| 15 |
## 1. The code must retain the above copyright notice, this list of ## |
| 16 |
## conditions and the following disclaimer. ## |
| 17 |
## 2. Any modifications must be clearly marked as such. ## |
| 18 |
## 3. Original authors' names are not deleted. ## |
| 19 |
## 4. The authors' names are not used to endorse or promote products ## |
| 20 |
## derived from this software without specific prior written ## |
| 21 |
## permission. ## |
| 22 |
## ## |
| 23 |
## CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK ## |
| 24 |
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ## |
| 25 |
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ## |
| 26 |
## SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE ## |
| 27 |
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ## |
| 28 |
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ## |
| 29 |
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ## |
| 30 |
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ## |
| 31 |
## THIS SOFTWARE. ## |
| 32 |
## ## |
| 33 |
########################################################################### |
| 34 |
### ## |
| 35 |
### Generate LPC coefficients and residual for diphones (or otherwise) ## |
| 36 |
### ## |
| 37 |
############################################################################ |
| 38 |
|
| 39 |
if [ $# = 0 ] |
| 40 |
then |
| 41 |
echo "Extract lpc coefficients and residuals" |
| 42 |
echo "Usage: bin/make_lpc wav/*.wav" |
| 43 |
echo "Expects pm/*.pm to exist, and creates lpc/*.lpc and lpc/*.res" |
| 44 |
echo "If etc/powfacts exists, waveform will be power normalized" |
| 45 |
echo "for LPC and residual extraction, wav/*.wav will be unchanged though." |
| 46 |
exit 1 |
| 47 |
fi |
| 48 |
|
| 49 |
if [ ! "$ESTDIR" ] |
| 50 |
then |
| 51 |
echo "environment variable ESTDIR is unset" |
| 52 |
echo "set it to your local speech tools directory e.g." |
| 53 |
echo ' bash$ export ESTDIR=/home/awb/projects/speech_tools/' |
| 54 |
echo or |
| 55 |
echo ' csh% setenv ESTDIR /home/awb/projects/speech_tools/' |
| 56 |
exit 1 |
| 57 |
fi |
| 58 |
|
| 59 |
# Modification by Milan Zamazal <[email protected]>: Ensure locales don't break number printing. |
| 60 |
unset LC_ALL |
| 61 |
export LC_NUMERIC=C |
| 62 |
|
| 63 |
for i in $* |
| 64 |
do |
| 65 |
fname=`basename $i .wav` |
| 66 |
echo $i LPC |
| 67 |
|
| 68 |
# Potentially normalise the power (if powfact is there) |
| 69 |
# Change by Milan Zamazal <[email protected]>: If the corresponding etc/pf/* |
| 70 |
# file exists, use it instead of etc/powfacts: |
| 71 |
if [ -f etc/pf/$fname ]; then |
| 72 |
powfact=`cat etc/pf/$fname` |
| 73 |
$ESTDIR/bin/ch_wave -scale $powfact $i -o /tmp/tmp$$.wav |
| 74 |
elif [ -f etc/powfacts ] |
| 75 |
then |
| 76 |
powfact=`awk '{if ($1 == "'$fname'") print $2}' etc/powfacts` |
| 77 |
if [ ! "$powfact" ] |
| 78 |
then |
| 79 |
powfact=1.0 |
| 80 |
fi |
| 81 |
$ESTDIR/bin/ch_wave -scale $powfact $i -o /tmp/tmp$$.wav |
| 82 |
else |
| 83 |
cat $i >/tmp/tmp$$.wav |
| 84 |
fi |
| 85 |
# Change the overall volume too, of the normalised file |
| 86 |
# $ESTDIR/bin/ch_wave -scaleN 0.65 -o /tmp/tmp$$.wav /tmp/tmp$$.wav |
| 87 |
|
| 88 |
# and if you want to resample, now is the time (can be combine with above) |
| 89 |
#$ESTDIR/bin/ch_wave -F 11025 -o /tmp/tmp$$.wav /tmp/tmp$$.wav |
| 90 |
|
| 91 |
# Extract the LPC coefficients |
| 92 |
# Modification by Milan Zamazal <[email protected]>: -lpc_order value |
| 93 |
# increased to 46 |
| 94 |
$ESTDIR/bin/sig2fv /tmp/tmp$$.wav -o lpc/$fname.lpc -otype est_binary -lpc_order 46 -coefs "lpc" -pm pm/$fname.pm -preemph 0.95 -factor 3 -window_type hamming |
| 95 |
# Extract the residual |
| 96 |
$ESTDIR/bin/sigfilter /tmp/tmp$$.wav -o lpc/$fname.res -otype nist -lpcfilter lpc/$fname.lpc -inv_filter |
| 97 |
|
| 98 |
rm /tmp/tmp$$.wav |
| 99 |
done |