Allow Cygwin users to generate voice files using SAPI 5. Slow, and missing some of the details from the old MakeVoices.vbs method, but better than nothing.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14252 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Steve Bavin 2007-08-09 12:07:42 +00:00
parent c8c80a5391
commit 6bc7da7c1f
5 changed files with 157 additions and 7 deletions

28
tools/configure vendored
View file

@ -326,19 +326,28 @@ voiceconfig () {
fi fi
if [ `which festival` ]; then if [ `which festival` ]; then
FESTIVAL="(F)estival " FESTIVAL="(F)estival "
FESTIVAL_OPTS="FLITE_OPTS=\"\"" FESTIVAL_OPTS="FESTIVAL_OPTS=\"\""
DEFAULT_TTS="festival" DEFAULT_TTS="festival"
DEFAULT_TTS_OPTS=$FESTIVAL_OPTS DEFAULT_TTS_OPTS=$FESTIVAL_OPTS
DEFAULT_NOISEFLOOR="500" DEFAULT_NOISEFLOOR="500"
DEFAULT_CHOICE="F" DEFAULT_CHOICE="F"
fi fi
# Allow SAPI if Windows is in use
if [ `which winver` ]; then
SAPI5="(S)API5 "
SAPI5_OPTS="SAPI5_OPTS=\"\""
DEFAULT_TTS="sapi5"
DEFAULT_TTS_OPTS=$SAPI5_OPTS
DEFAULT_NOISEFLOOR="500"
DEFAULT_CHOICE="S"
fi
if [ "$FESTIVAL" = "$FLITE" ] && [ "$FLITE" = "$ESPEAK" ]; then if [ "$FESTIVAL" = "$FLITE" ] && [ "$FLITE" = "$ESPEAK" ] && [ "$ESPEAK" = "$SAPI5" ]; then
echo "You need Festival, eSpeak or Flite in your path to build voice files" echo "You need Festival, eSpeak or Flite in your path, or SAPI5 available to build voice files"
exit exit
fi fi
echo "TTS engine to use: ${FLITE}${FESTIVAL}${ESPEAK}(${DEFAULT_CHOICE})?" echo "TTS engine to use: ${FLITE}${FESTIVAL}${ESPEAK}${SAPI5}(${DEFAULT_CHOICE})?"
option=`input` option=`input`
case "$option" in case "$option" in
[Ll]) [Ll])
@ -356,6 +365,11 @@ voiceconfig () {
NOISEFLOOR="500" NOISEFLOOR="500"
TTS_OPTS=$FESTIVAL_OPTS TTS_OPTS=$FESTIVAL_OPTS
;; ;;
[Ss])
TTS_ENGINE="sapi5"
NOISEFLOOR="500"
TTS_OPTS=$SAPI5_OPTS
;;
*) *)
TTS_ENGINE=$DEFAULT_TTS TTS_ENGINE=$DEFAULT_TTS
TTS_OPTS=$DEFAULT_TTS_OPTS TTS_OPTS=$DEFAULT_TTS_OPTS
@ -413,11 +427,15 @@ voiceconfig () {
# ENC_OPTS=$DEFAULT_ENC_OPTS # ENC_OPTS=$DEFAULT_ENC_OPTS
# esac # esac
echo "Using $ENCODER for encoding voice clips" echo "Using $ENCODER for encoding voice clips"
TEMPDIR="${pwd}"
if [ `which cygpath` ]; then
TEMPDIR=`cygpath . -a -w`
fi
cat > voicesettings.sh <<EOF cat > voicesettings.sh <<EOF
TTS_ENGINE="${TTS_ENGINE}" TTS_ENGINE="${TTS_ENGINE}"
ENCODER="${ENCODER}" ENCODER="${ENCODER}"
TEMPDIR="${pwd}" TEMPDIR="$TEMPDIR"
NOISEFLOOR="${NOISEFLOOR}" NOISEFLOOR="${NOISEFLOOR}"
${TTS_OPTS} ${TTS_OPTS}
${ENC_OPTS} ${ENC_OPTS}

29
tools/sapi5_init_tts.vbs Executable file
View file

@ -0,0 +1,29 @@
'***************************************************************************
' __________ __ ___.
' Open \______ \ ____ ____ | | _\_ |__ _______ ___
' Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
' Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
' Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
' \/ \/ \/ \/ \/
' $Id: sapi5_init_tts.vbs$
'
' Copyright (C) 2007 Steve Bavin, Jens Arnold, Mesar Hameed
'
' All files in this archive are subject to the GNU General Public License.
' See the file COPYING in the source tree root for full license agreement.
'
' This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
' KIND, either express or implied.
'
'***************************************************************************
Dim oSpVoice, sVoice
Set oSpVoice = CreateObject("SAPI.SpVoice")
If Err.Number <> 0 Then
WScript.Echo "Error - could not get SpVoice object. " & _
"SAPI 5 not installed?"
Err.Clear
WScript.Quit 1
End If
WScript.Quit 0

18
tools/sapi5_stop_tts.vbs Executable file
View file

@ -0,0 +1,18 @@
'***************************************************************************
' __________ __ ___.
' Open \______ \ ____ ____ | | _\_ |__ _______ ___
' Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
' Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
' Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
' \/ \/ \/ \/ \/
' $Id: sapi5_stop_tts.vbs$
'
' Copyright (C) 2007 Steve Bavin, Jens Arnold, Mesar Hameed
'
' All files in this archive are subject to the GNU General Public License.
' See the file COPYING in the source tree root for full license agreement.
'
' This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
' KIND, either express or implied.
'
'***************************************************************************

68
tools/sapi5_voice.vbs Executable file
View file

@ -0,0 +1,68 @@
'***************************************************************************
' __________ __ ___.
' Open \______ \ ____ ____ | | _\_ |__ _______ ___
' Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
' Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
' Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
' \/ \/ \/ \/ \/
' $Id: sapi5_voice.vbs$
'
' Copyright (C) 2007 Steve Bavin, Jens Arnold, Mesar Hameed
'
' All files in this archive are subject to the GNU General Public License.
' See the file COPYING in the source tree root for full license agreement.
'
' This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
' KIND, either express or implied.
'
'***************************************************************************
' Purpose: Make a voice clip file for the given text
' Parameters: $0 - text to convert
' $1 - file to write spoken text into (WAV format)
'To be done:
' - Somehow, persist oSpVoice across multiple clips to increase speed
' - Allow user to override voice, speed and/or format (currently uses Control Panel defaults for voice/speed)
' - Voice specific replacements/corrections for pronounciation (this should be at a higher level really)
Const SSFMCreateForWrite = 3
Const SPSF_8kHz16BitMono = 6
Const SPSF_11kHz16BitMono = 10
Const SPSF_12kHz16BitMono = 14
Const SPSF_16kHz16BitMono = 18
Const SPSF_22kHz16BitMono = 22
Const SPSF_24kHz16BitMono = 26
Const SPSF_32kHz16BitMono = 30
Const SPSF_44kHz16BitMono = 34
Const SPSF_48kHz16BitMono = 38
Dim oSpVoice, oSpFS, nAudioFormat, sText, sOutputFile
sText = Replace(WScript.Arguments(0), "\", "")
sOutputFile = WScript.Arguments(1)
nAudioFormat = SPSF_22kHz16BitMono 'Audio format to use, recommended settings:
'- for AT&T natural voices, use SPSF_32kHz16BitMono
'- for MS voices, use SPSF_22kHz16BitMono
Set oSpVoice = CreateObject("SAPI.SpVoice")
If Err.Number <> 0 Then
WScript.Echo "Error - could not get SpVoice object. " & _
"SAPI 5 not installed?"
Err.Clear
WScript.Quit 1
End If
Set oSpFS = CreateObject("SAPI.SpFileStream")
oSpFS.Format.Type = nAudioFormat
oSpFS.Open sOutputFile, SSFMCreateForWrite, False
Set oSpVoice.AudioOutputStream = oSpFS
oSpVoice.Speak sText
oSpFS.Close
Set oSpFS = Nothing
Set oSpVoice = Nothing
Set oArgs = Nothing
WScript.Quit 0

View file

@ -46,8 +46,14 @@ SPEEX_BIN=speexenc
# The oggenc executable # The oggenc executable
VORBIS_BIN=oggenc VORBIS_BIN=oggenc
# Tools directory
TOOLSDIR=`dirname $0`
# The wavtrim executable # The wavtrim executable
WAVTRIM=`dirname $0`/wavtrim WAVTRIM=$TOOLSDIR/wavtrim
# The SAPI5 script directory
SAPI5DIR=`cygpath $TOOLSDIR -a -w`
##################### #####################
# Festival settings # # Festival settings #
@ -158,12 +164,20 @@ init_tts() {
fi fi
;; ;;
espeak) espeak)
# Check for flite # Check for espeak
if [ ! `which $ESPEAK_BIN` ]; then if [ ! `which $ESPEAK_BIN` ]; then
echo "Error: $ESPEAK_BIN not found" echo "Error: $ESPEAK_BIN not found"
exit 5 exit 5
fi fi
;; ;;
sapi5)
# Check for SAPI5
cscript /B $SAPI5DIR/sapi5_init_tts.vbs
if [ $? -ne 0 ]; then
echo "Error: SAPI 5 not available"
exit 5
fi
;;
*) *)
echo "Error: no valid TTS engine selected: $TTS_ENGINE" echo "Error: no valid TTS engine selected: $TTS_ENGINE"
exit 2 exit 2
@ -268,6 +282,9 @@ voice() {
echo "Action: Generate $WAV_FILE with flite" echo "Action: Generate $WAV_FILE with flite"
echo -E "$TO_SPEAK" | $FLITE_BIN $FLITE_OPTS -o "$WAV_FILE" echo -E "$TO_SPEAK" | $FLITE_BIN $FLITE_OPTS -o "$WAV_FILE"
;; ;;
sapi5)
cscript /B "$SAPI5DIR\sapi5_voice.vbs" ""$TO_SPEAK"" "$WAV_FILE"
;;
esac esac
fi fi
fi fi