File: linuxtrade.audio

package info (click to toggle)
linuxtrade 3.65-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,880 kB
  • ctags: 1,969
  • sloc: ansic: 30,091; sh: 2,278; perl: 566; makefile: 126
file content (268 lines) | stat: -rwxr-xr-x 5,391 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#!/bin/bash

#
#	Generate audio sentence or alert using a TTS system.
#

usage() {
cat <<EOF
Usage:
	$0 [options] "A complete sentence."

	$0 [options] args ...
		arg1	symbol
		arg2	current price
		arg3	current volume
		arg4	alert variable name (last, high, low, news, etc.)
		arg5	operator (<, =, >)
		arg6	alert trigger value
		arg7	stock comment and/or news headline

Options:
-s SYNTH	Select synthesizer to use:
			festival, viavoice,
			btl, ibm, ibmwatson, speechworks,
			default
		Add "-web" to synth name to prefer scraping it from the web 
		versus local synth (if any).

-v VOICE	Select voice to use.  Accepted values depend on synth.
		btl: man woman child gnat coffee bigman raspy ridiculous
		speechworks: tom mara rick helen sandra tessa luci paulina
		ibmwatson: HOK SMC MCK SMB
EOF
	exit 1
}

#
#	Preferred synthesizer
#
if [ -x /usr/bin/festival ]; then
	SYNTH=festival
elif [ -d /usr/lib/ViaVoiceTTS ]; then
	SYNTH=viavoice
else
	SYNTH=btl
	SYNTH=viavoice
	SYNTH=festival
	SYNTH=speechworks
	SYNTH=ibm
fi

#
#       Process the options
#
DEBUG=0
VOICE=
unset OPTIND
while getopts "s:v:D:h?" opt
do
	case $opt in
	s)	if [ "$OPTARG" != default ]; then
			SYNTH="$OPTARG"
		fi
		;;
	v)	VOICE="$OPTARG";;
	D)	DEBUG="$OPTARG";;
	h|\?)	usage;;
	esac
done
shift `expr $OPTIND - 1`

if [ "$#" = 0 ]; then
	set -- INTC '$33.42' 123456 ask '>' '$34.00'
fi

if [ $DEBUG != 0 ]; then
    TMP=/tmp/lt-audio
else
    TMP=/tmp/lt-audio-$$
fi

#
#	Name the arguments
#
SYM="$1"
PRICE="$2"
VOL="$3"
VARIABLE="$4"
OPERATOR="$5"
TRIG="$6"
COMMENT="$7"

#
#	Insert blanks in symbol for better speech
#
SYM=`echo "$SYM" | sed -e 's/[A-Z]/& /g' -e 's/ *$//' `

case "$VARIABLE" in
news)
	MSG="Alert!  Alert!  $SYM has news."
	if [ "$COMMENT" != "" ]; then
		MSG="$MSG  $COMMENT"
	fi
	;;
*)
	case "$OPERATOR" in
	"<")	sign="is now less than";;
	">")	sign="is now greater than";;
	"=")	sign="is now equal to";;
	esac
	MSG="Alert!  Alert!  $SYM, price is $PRICE, $VARIABLE $sign $TRIG."
	if [ "$COMMENT" != "" ]; then
		MSG="$MSG  $COMMENT"
	fi
	;;
esac

if [ "$#" = 1 ]; then
	MSG="$1"
fi

UA="Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"

#
#	Determine if we need to use web version
#
case "$SYNTH" in
festival)
	if [ ! -x /usr/bin/festival ]; then
		SYNTH=festival-web
	fi
	;;
ibm|ibmwatson)
	# Newer IBM synth, available on web only (that I know of)
	SYNTH=$SYNTH-web
	;;
btl)
	# Dunno how to do local one yet
	SYNTH=btl-web
	;;
speechworks)
	# Dunno how to do local one yet
	SYNTH=speechworks-web
	;;
esac

if [ $DEBUG != 0 ]; then
	echo "$SYNTH: $MSG"
fi

#
#	Run the selected synth
#
case "$SYNTH" in
festival)
	echo "$MSG" | festival --tts
	;;

festival-web)
	if [ "$VOICE" = "" ]; then
		VOICE="kal+(American+Male)"
	fi
	UMSG=`echo "$MSG" | tr ' ' '+' `
	URL="http://www.festvox.org/cgi-bin/gen_fest.wav"
	URL="$URL?format=wav&voice=$VOICE&text=$UMSG"
	if [ $DEBUG != 0 ]; then
		echo "$SYNTH: $URL"
	fi
	curl -s -A "$UA" "$URL" > $TMP.wav
	(xmms $TMP.wav; rm -f $TMP.wav) &
	;;

viavoice)
	#
	# IBM ViaVoice Runtime Kit.  Get it here:
	#
	#	http://www-4.ibm.com/software/speech/dev/ttssdk_linux.html
	#
	# Or maybe from here:
	#
	#	http://www.ecn.purdue.edu/~laird/Linux/ViaVoice/
	#
	# Or maybe from Suse 7.0 pro or the Mandrake 9 tools.
	#
	VIA=/usr/lib/ViaVoiceTTS
	export ECIINI=$VIA/eci.ini
	TTSDIR=$VIA/samples
	CLSDIR=$TTSDIR/cmdlinespeak
	$CLSDIR/cmdlinespeak "$MSG" > /dev/null
	;;

ibm-web)
	#
	# IBM's low-CPU web synth
	#
	UMSG=`echo "$MSG" | tr ' ' '+' `
	SITE="http://wassample.dfw.ibm.com/tts"
	URL="$SITE/servlet/TTSServlet?sr=0&fileToDelete=&l=00010000"
	URL="$URL&vh=50&vg=0&vf=30&vb=65&vy=0&vv=92&v=1"
	URL="$URL&text=$UMSG&vs=50&vr=0"
	FILE=`curl -s -A "$UA" "$URL" | grep au`
	if [ "$FILE" != "" ]; then
	    curl -s -A "$UA" "$SITE/$FILE" > $TMP.au
	    (play $TMP.au; rm -f $TMP.au) &
	fi
	;;

ibmwatson-web)
	#
	# IBM research's web synth
	#
	if [ "$VOICE" = "" ]; then
		VOICE=SMC
	fi
	UMSG=`echo "$MSG" | tr ' ' '+' `
	URL="http://webtts.watson.ibm.com/cgi-bin/ttsclient30"
	URL="$URL?text=$UMSG&voice=$VOICE&nsfile=ttsclient30.wav"
	curl -s -A "$UA" "$URL" > $TMP.wav
	(xmms $TMP.wav; rm -f $TMP.wav) &
	;;

btl-web)
	if [ "$VOICE" = "" ]; then
		VOICE=man
		# also woman, child, gnat, coffee, bigman, raspy, ridiculous
	fi
	UMSG=`echo "$MSG" | tr ' ' '+' `
	URL="http://www.bell-labs.com/cgi-user/tts/voicestts-nj"
	# Avoid page redirect...
	URL="http://wwwtts.research.bell-labs.com/cgi-user/tts/voicestts-nj"
	URL="$URL?voice=$VOICE&text=$UMSG&audio=.wav&submit=Synthesize"
	if [ $DEBUG != 0 ]; then
		echo "$SYNTH: $URL"
	fi
	# curl -s -A "$UA" "$URL" > $TMP.wav
	# retrieves faster for some reason...
	wget -q -O- "$URL" > $TMP.wav
	(xmms $TMP.wav; rm -f $TMP.wav) &
	;;

speechworks-web)
	#
	# This is the best so far...
	#
	if [ "$VOICE" = "" ]; then
		VOICE=tom
		# also voices mara, rick, helen, sandra, tessa, luci, paulina
	fi
	UMSG=`echo "$MSG" | tr ' ' '+' `
	BASEURL=http://www.speechworks.com
	URL="$BASEURL/cgi-bin/interactivedemo-tts-form"
	URL="$URL?speechtext=$UMSG"
	URL="$URL&combovoice=$VOICE&sample_rate=16&submit=+Submit"

	FILE=`curl -s -A "$UA" "$URL" |
		grep '<BR><A HREF="/playback' |
		sed 's/.*"\([^"]*\)".*/\1/' `

	if [ $DEBUG != 0 ]; then
		echo "$SYNTH: $BASEURL$FILE"
	fi
	curl -s -A "$UA" "$BASEURL$FILE" > $TMP.wav
	(xmms $TMP.wav; rm -f $TMP.wav) &
	;;
*)
	echo "$SYNTH: don't know how to use that synth yet"
	;;
esac