diff options
-rwxr-xr-x | tools/configure | 28 | ||||
-rwxr-xr-x | tools/sapi5_init_tts.vbs | 29 | ||||
-rwxr-xr-x | tools/sapi5_stop_tts.vbs | 18 | ||||
-rwxr-xr-x | tools/sapi5_voice.vbs | 68 | ||||
-rw-r--r-- | tools/voicecommon.sh | 21 |
5 files changed, 157 insertions, 7 deletions
diff --git a/tools/configure b/tools/configure index b2d2be2508..e01230c390 100755 --- a/tools/configure +++ b/tools/configure | |||
@@ -326,19 +326,28 @@ voiceconfig () { | |||
326 | fi | 326 | fi |
327 | if [ `which festival` ]; then | 327 | if [ `which festival` ]; then |
328 | FESTIVAL="(F)estival " | 328 | FESTIVAL="(F)estival " |
329 | FESTIVAL_OPTS="FLITE_OPTS=\"\"" | 329 | FESTIVAL_OPTS="FESTIVAL_OPTS=\"\"" |
330 | DEFAULT_TTS="festival" | 330 | DEFAULT_TTS="festival" |
331 | DEFAULT_TTS_OPTS=$FESTIVAL_OPTS | 331 | DEFAULT_TTS_OPTS=$FESTIVAL_OPTS |
332 | DEFAULT_NOISEFLOOR="500" | 332 | DEFAULT_NOISEFLOOR="500" |
333 | DEFAULT_CHOICE="F" | 333 | DEFAULT_CHOICE="F" |
334 | fi | 334 | fi |
335 | # Allow SAPI if Windows is in use | ||
336 | if [ `which winver` ]; then | ||
337 | SAPI5="(S)API5 " | ||
338 | SAPI5_OPTS="SAPI5_OPTS=\"\"" | ||
339 | DEFAULT_TTS="sapi5" | ||
340 | DEFAULT_TTS_OPTS=$SAPI5_OPTS | ||
341 | DEFAULT_NOISEFLOOR="500" | ||
342 | DEFAULT_CHOICE="S" | ||
343 | fi | ||
335 | 344 | ||
336 | if [ "$FESTIVAL" = "$FLITE" ] && [ "$FLITE" = "$ESPEAK" ]; then | 345 | if [ "$FESTIVAL" = "$FLITE" ] && [ "$FLITE" = "$ESPEAK" ] && [ "$ESPEAK" = "$SAPI5" ]; then |
337 | echo "You need Festival, eSpeak or Flite in your path to build voice files" | 346 | echo "You need Festival, eSpeak or Flite in your path, or SAPI5 available to build voice files" |
338 | exit | 347 | exit |
339 | fi | 348 | fi |
340 | 349 | ||
341 | echo "TTS engine to use: ${FLITE}${FESTIVAL}${ESPEAK}(${DEFAULT_CHOICE})?" | 350 | echo "TTS engine to use: ${FLITE}${FESTIVAL}${ESPEAK}${SAPI5}(${DEFAULT_CHOICE})?" |
342 | option=`input` | 351 | option=`input` |
343 | case "$option" in | 352 | case "$option" in |
344 | [Ll]) | 353 | [Ll]) |
@@ -356,6 +365,11 @@ voiceconfig () { | |||
356 | NOISEFLOOR="500" | 365 | NOISEFLOOR="500" |
357 | TTS_OPTS=$FESTIVAL_OPTS | 366 | TTS_OPTS=$FESTIVAL_OPTS |
358 | ;; | 367 | ;; |
368 | [Ss]) | ||
369 | TTS_ENGINE="sapi5" | ||
370 | NOISEFLOOR="500" | ||
371 | TTS_OPTS=$SAPI5_OPTS | ||
372 | ;; | ||
359 | *) | 373 | *) |
360 | TTS_ENGINE=$DEFAULT_TTS | 374 | TTS_ENGINE=$DEFAULT_TTS |
361 | TTS_OPTS=$DEFAULT_TTS_OPTS | 375 | TTS_OPTS=$DEFAULT_TTS_OPTS |
@@ -413,11 +427,15 @@ voiceconfig () { | |||
413 | # ENC_OPTS=$DEFAULT_ENC_OPTS | 427 | # ENC_OPTS=$DEFAULT_ENC_OPTS |
414 | # esac | 428 | # esac |
415 | echo "Using $ENCODER for encoding voice clips" | 429 | echo "Using $ENCODER for encoding voice clips" |
430 | TEMPDIR="${pwd}" | ||
431 | if [ `which cygpath` ]; then | ||
432 | TEMPDIR=`cygpath . -a -w` | ||
433 | fi | ||
416 | 434 | ||
417 | cat > voicesettings.sh <<EOF | 435 | cat > voicesettings.sh <<EOF |
418 | TTS_ENGINE="${TTS_ENGINE}" | 436 | TTS_ENGINE="${TTS_ENGINE}" |
419 | ENCODER="${ENCODER}" | 437 | ENCODER="${ENCODER}" |
420 | TEMPDIR="${pwd}" | 438 | TEMPDIR="$TEMPDIR" |
421 | NOISEFLOOR="${NOISEFLOOR}" | 439 | NOISEFLOOR="${NOISEFLOOR}" |
422 | ${TTS_OPTS} | 440 | ${TTS_OPTS} |
423 | ${ENC_OPTS} | 441 | ${ENC_OPTS} |
diff --git a/tools/sapi5_init_tts.vbs b/tools/sapi5_init_tts.vbs new file mode 100755 index 0000000000..466ee5ce71 --- /dev/null +++ b/tools/sapi5_init_tts.vbs | |||
@@ -0,0 +1,29 @@ | |||
1 | '*************************************************************************** | ||
2 | ' __________ __ ___. | ||
3 | ' Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | ' Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | ' Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | ' Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | ' \/ \/ \/ \/ \/ | ||
8 | ' $Id: sapi5_init_tts.vbs$ | ||
9 | ' | ||
10 | ' Copyright (C) 2007 Steve Bavin, Jens Arnold, Mesar Hameed | ||
11 | ' | ||
12 | ' All files in this archive are subject to the GNU General Public License. | ||
13 | ' See the file COPYING in the source tree root for full license agreement. | ||
14 | ' | ||
15 | ' This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | ' KIND, either express or implied. | ||
17 | ' | ||
18 | '*************************************************************************** | ||
19 | Dim oSpVoice, sVoice | ||
20 | |||
21 | Set oSpVoice = CreateObject("SAPI.SpVoice") | ||
22 | If Err.Number <> 0 Then | ||
23 | WScript.Echo "Error - could not get SpVoice object. " & _ | ||
24 | "SAPI 5 not installed?" | ||
25 | Err.Clear | ||
26 | WScript.Quit 1 | ||
27 | End If | ||
28 | |||
29 | WScript.Quit 0 | ||
diff --git a/tools/sapi5_stop_tts.vbs b/tools/sapi5_stop_tts.vbs new file mode 100755 index 0000000000..eee149bf08 --- /dev/null +++ b/tools/sapi5_stop_tts.vbs | |||
@@ -0,0 +1,18 @@ | |||
1 | '*************************************************************************** | ||
2 | ' __________ __ ___. | ||
3 | ' Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | ' Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | ' Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | ' Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | ' \/ \/ \/ \/ \/ | ||
8 | ' $Id: sapi5_stop_tts.vbs$ | ||
9 | ' | ||
10 | ' Copyright (C) 2007 Steve Bavin, Jens Arnold, Mesar Hameed | ||
11 | ' | ||
12 | ' All files in this archive are subject to the GNU General Public License. | ||
13 | ' See the file COPYING in the source tree root for full license agreement. | ||
14 | ' | ||
15 | ' This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | ' KIND, either express or implied. | ||
17 | ' | ||
18 | '*************************************************************************** | ||
diff --git a/tools/sapi5_voice.vbs b/tools/sapi5_voice.vbs new file mode 100755 index 0000000000..c37836afb4 --- /dev/null +++ b/tools/sapi5_voice.vbs | |||
@@ -0,0 +1,68 @@ | |||
1 | '*************************************************************************** | ||
2 | ' __________ __ ___. | ||
3 | ' Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | ' Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | ' Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | ' Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | ' \/ \/ \/ \/ \/ | ||
8 | ' $Id: sapi5_voice.vbs$ | ||
9 | ' | ||
10 | ' Copyright (C) 2007 Steve Bavin, Jens Arnold, Mesar Hameed | ||
11 | ' | ||
12 | ' All files in this archive are subject to the GNU General Public License. | ||
13 | ' See the file COPYING in the source tree root for full license agreement. | ||
14 | ' | ||
15 | ' This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | ' KIND, either express or implied. | ||
17 | ' | ||
18 | '*************************************************************************** | ||
19 | ' Purpose: Make a voice clip file for the given text | ||
20 | ' Parameters: $0 - text to convert | ||
21 | ' $1 - file to write spoken text into (WAV format) | ||
22 | |||
23 | |||
24 | |||
25 | 'To be done: | ||
26 | ' - Somehow, persist oSpVoice across multiple clips to increase speed | ||
27 | ' - Allow user to override voice, speed and/or format (currently uses Control Panel defaults for voice/speed) | ||
28 | ' - Voice specific replacements/corrections for pronounciation (this should be at a higher level really) | ||
29 | |||
30 | Const SSFMCreateForWrite = 3 | ||
31 | |||
32 | Const SPSF_8kHz16BitMono = 6 | ||
33 | Const SPSF_11kHz16BitMono = 10 | ||
34 | Const SPSF_12kHz16BitMono = 14 | ||
35 | Const SPSF_16kHz16BitMono = 18 | ||
36 | Const SPSF_22kHz16BitMono = 22 | ||
37 | Const SPSF_24kHz16BitMono = 26 | ||
38 | Const SPSF_32kHz16BitMono = 30 | ||
39 | Const SPSF_44kHz16BitMono = 34 | ||
40 | Const SPSF_48kHz16BitMono = 38 | ||
41 | |||
42 | Dim oSpVoice, oSpFS, nAudioFormat, sText, sOutputFile | ||
43 | |||
44 | sText = Replace(WScript.Arguments(0), "\", "") | ||
45 | sOutputFile = WScript.Arguments(1) | ||
46 | nAudioFormat = SPSF_22kHz16BitMono 'Audio format to use, recommended settings: | ||
47 | '- for AT&T natural voices, use SPSF_32kHz16BitMono | ||
48 | '- for MS voices, use SPSF_22kHz16BitMono | ||
49 | |||
50 | Set oSpVoice = CreateObject("SAPI.SpVoice") | ||
51 | If Err.Number <> 0 Then | ||
52 | WScript.Echo "Error - could not get SpVoice object. " & _ | ||
53 | "SAPI 5 not installed?" | ||
54 | Err.Clear | ||
55 | WScript.Quit 1 | ||
56 | End If | ||
57 | |||
58 | Set oSpFS = CreateObject("SAPI.SpFileStream") | ||
59 | oSpFS.Format.Type = nAudioFormat | ||
60 | oSpFS.Open sOutputFile, SSFMCreateForWrite, False | ||
61 | Set oSpVoice.AudioOutputStream = oSpFS | ||
62 | oSpVoice.Speak sText | ||
63 | oSpFS.Close | ||
64 | |||
65 | Set oSpFS = Nothing | ||
66 | Set oSpVoice = Nothing | ||
67 | Set oArgs = Nothing | ||
68 | WScript.Quit 0 | ||
diff --git a/tools/voicecommon.sh b/tools/voicecommon.sh index 13df3e9739..138ff59a9e 100644 --- a/tools/voicecommon.sh +++ b/tools/voicecommon.sh | |||
@@ -46,8 +46,14 @@ SPEEX_BIN=speexenc | |||
46 | # The oggenc executable | 46 | # The oggenc executable |
47 | VORBIS_BIN=oggenc | 47 | VORBIS_BIN=oggenc |
48 | 48 | ||
49 | # Tools directory | ||
50 | TOOLSDIR=`dirname $0` | ||
51 | |||
49 | # The wavtrim executable | 52 | # The wavtrim executable |
50 | WAVTRIM=`dirname $0`/wavtrim | 53 | WAVTRIM=$TOOLSDIR/wavtrim |
54 | |||
55 | # The SAPI5 script directory | ||
56 | SAPI5DIR=`cygpath $TOOLSDIR -a -w` | ||
51 | 57 | ||
52 | ##################### | 58 | ##################### |
53 | # Festival settings # | 59 | # Festival settings # |
@@ -158,12 +164,20 @@ init_tts() { | |||
158 | fi | 164 | fi |
159 | ;; | 165 | ;; |
160 | espeak) | 166 | espeak) |
161 | # Check for flite | 167 | # Check for espeak |
162 | if [ ! `which $ESPEAK_BIN` ]; then | 168 | if [ ! `which $ESPEAK_BIN` ]; then |
163 | echo "Error: $ESPEAK_BIN not found" | 169 | echo "Error: $ESPEAK_BIN not found" |
164 | exit 5 | 170 | exit 5 |
165 | fi | 171 | fi |
166 | ;; | 172 | ;; |
173 | sapi5) | ||
174 | # Check for SAPI5 | ||
175 | cscript /B $SAPI5DIR/sapi5_init_tts.vbs | ||
176 | if [ $? -ne 0 ]; then | ||
177 | echo "Error: SAPI 5 not available" | ||
178 | exit 5 | ||
179 | fi | ||
180 | ;; | ||
167 | *) | 181 | *) |
168 | echo "Error: no valid TTS engine selected: $TTS_ENGINE" | 182 | echo "Error: no valid TTS engine selected: $TTS_ENGINE" |
169 | exit 2 | 183 | exit 2 |
@@ -268,6 +282,9 @@ voice() { | |||
268 | echo "Action: Generate $WAV_FILE with flite" | 282 | echo "Action: Generate $WAV_FILE with flite" |
269 | echo -E "$TO_SPEAK" | $FLITE_BIN $FLITE_OPTS -o "$WAV_FILE" | 283 | echo -E "$TO_SPEAK" | $FLITE_BIN $FLITE_OPTS -o "$WAV_FILE" |
270 | ;; | 284 | ;; |
285 | sapi5) | ||
286 | cscript /B "$SAPI5DIR\sapi5_voice.vbs" ""$TO_SPEAK"" "$WAV_FILE" | ||
287 | ;; | ||
271 | esac | 288 | esac |
272 | fi | 289 | fi |
273 | fi | 290 | fi |