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### Prompt and record diphone set ## 36### ## 37########################################################################### 38 39if [ $# = 0 ] 40then 41 echo "prompt and record diphone nonsense words" 42 echo "Usage: prompt_them DATALIST [POSITION] " 43 echo " DATALIST list of utterance prompts e.g. etc/MUMBLE.data" 44 echo " POSITION which utterance to start/restart at, default is 1" 45 exit 1 46fi 47 48if [ ! "$ESTDIR" ] 49then 50 echo "environment variable ESTDIR is unset" 51 echo "set it to your local speech tools directory e.g." 52 echo ' bash$ export ESTDIR=/home/awb/projects/speech_tools/' 53 echo or 54 echo ' csh% setenv ESTDIR /home/awb/projects/speech_tools/' 55 exit 1 56fi 57 58if [ ! -d prompt-wav ] 59then 60 echo "can't find prompt-wav/ directory." 61 echo "are you in the right directory?" 62 exit 1 63fi 64 65POSITION=1 66if [ $# = 2 ] 67then 68 POSITION=$2 69fi 70 71cat $1 | grep "^ *(.*) *$" | 72awk '{if (NR >= '$POSITION') print $0}' | 73while read lll 74do 75 echo 24 | awk '{for(i=1; i<=$1; i++) 76 printf("\n");}' 77 echo "--------------------------------------------------------------" 78 echo -n $POSITION " " 79 echo $lll | awk '{print $2}' 80 echo 81 echo $lll | tr -d '"' | 82 awk '{ l=0; 83 printf(" "); 84 for(i=3; i<NF; i++) 85 { 86 if (l > 64) 87 { 88 printf("\n "); 89 l = 0; 90 } 91 printf("%s ",$i); 92 l += length($i)+1; 93 } 94 printf("\n")}' 95 echo 96 f=`echo $lll | awk '{print $2}'` 97 98 # Take duration from the prompt-wav 99 duration=`$ESTDIR/bin/ch_wave -info prompt-wav/$f.wav | awk '{if ($1 == "Duration:") printf("%d\n",$2+1.5)}'` 100 # Take duration from number of words (when no prompt-wavs are available 101# duration=`echo $lll | awk '{printf("%d\n",4.5+(NF/2.5))}'` 102 103 # If you don't want to hear the prompt comment out the following line 104 $ESTDIR/bin/na_play prompt-wav/$f.wav 105 106# echo press retrun to start recording 107# read x </dev/tty 108 109 echo start recording for $duration seconds ... 110 $ESTDIR/bin/na_record -f 16000 -time $duration -o wav/$f.wav 111 echo ... end recording 112 113 POSITION=$[$POSITION+1] 114 115 # If you don't want to hear the review comment out the following lines 116# echo Review $f 117# $ESTDIR/bin/na_play prompt-wav/$f.wav 118# $ESTDIR/bin/na_play wav/$f.wav 119 120done 121 122