1#!/bin/sh 2####################################################-*-mode:shell-script-*- 3## ## 4## Carnegie Mellon University ## 5## Copyright (c) 2005 ## 6## All Rights Reserved. ## 7## ## 8## Permission is hereby granted, free of charge, to use and distribute ## 9## this software and its documentation without restriction, including ## 10## without limitation the rights to use, copy, modify, merge, publish, ## 11## distribute, sublicense, and/or sell copies of this work, and to ## 12## permit persons to whom this work is furnished to do so, subject to ## 13## the following conditions: ## 14## 1. The code must retain the above copyright notice, this list of ## 15## conditions and the following disclaimer. ## 16## 2. Any modifications must be clearly marked as such. ## 17## 3. Original authors' names are not deleted. ## 18## 4. The authors' names are not used to endorse or promote products ## 19## derived from this software without specific prior written ## 20## permission. ## 21## ## 22## CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK ## 23## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ## 24## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ## 25## SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE ## 26## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ## 27## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ## 28## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ## 29## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ## 30## THIS SOFTWARE. ## 31## ## 32########################################################################### 33## ## 34## Find F0 mean/std min (mean-3*std) max (mean+3*std) from upto 100 ## 35## files sampled from the promptlist ## 36## ## 37########################################################################### 38 39if [ ! "$ESTDIR" ] 40then 41 echo "environment variable ESTDIR is unset" 42 echo "set it to your local speech tools directory e.g." 43 echo ' bash$ export ESTDIR=/home/awb/projects/speech_tools/' 44 echo or 45 echo ' csh% setenv ESTDIR /home/awb/projects/speech_tools/' 46 exit 1 47fi 48 49if [ ! "$FESTVOXDIR" ] 50then 51 echo "environment variable FESTVOXDIR is unset" 52 echo "set it to your local festvox directory e.g." 53 echo ' bash$ export FESTVOXDIR=/home/awb/projects/festvox/' 54 echo or 55 echo ' csh% setenv FESTVOXDIR /home/awb/projects/festvox/' 56 exit 1 57fi 58 59PROMPTFILE=etc/txt.done.data 60if [ $# = 1 ] 61then 62 PROMPTFILE=$1 63fi 64 65SILENCE=pau 66 67F0MIN=50 68F0MAX=400 69 70NUMPROMPTS=`cat $PROMPTFILE | wc -l | awk '{print $1}'` 71 72cat $PROMPTFILE | 73awk 'BEGIN { NP='$NUMPROMPTS'; 74 ENOUGH=100.0 75 if (NP/ENOUGH > 2) 76 { 77 f=int(NP/ENOUGH) 78 } 79 else 80 f = 1; 81 } 82 { if (NR%f == 0) 83 print $2 84 }' | 85while read i 86do 87 $ESTDIR/bin/ch_wave -scaleN 0.9 wav/$i.wav -F 16000 | 88 $ESTDIR/bin/pda -otype ascii -fmin $F0MIN -fmax $F0MAX 89done | 90awk '{ 91 if ($1 > 0.0) 92 { 93 count += 1 94 sum += $1 95 sumsq += $1*$1 96 } 97 } 98 function std (sum, sumx, n) 99 { 100 if (n==1) n=2; 101 return sqrt(((n*sumx)-(sum*sum)) / (n*(n-1))) 102 } 103 function mean (sum,n) 104 { 105 return sum/n; 106 } 107 END { m=mean(sum,count); 108 s=std(sum,sumsq,count); 109 printf("F0MEAN=%d\n",m); 110 printf("F0STD=%d\n",s); 111 printf("F0MAX=%d\n",m+(3*s)); 112 if (m-(3*s) < 50) 113 printf("F0MIN=%d\n",50); 114 else 115 printf("F0MIN=%d\n",m-(3*s)); 116 }' >etc/f0.params 117 118 119 120 121 122