summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteve Bavin <pondlife@pondlife.me>2007-08-09 12:07:42 +0000
committerSteve Bavin <pondlife@pondlife.me>2007-08-09 12:07:42 +0000
commit6bc7da7c1f686096efe1fdd44c53fff59f60c96f (patch)
tree2e595baa94d02c22981060acd0c4514fc1d2cd0e /tools
parentc8c80a5391d028e0ee40432568f0a40eb623b249 (diff)
downloadrockbox-6bc7da7c1f686096efe1fdd44c53fff59f60c96f.tar.gz
rockbox-6bc7da7c1f686096efe1fdd44c53fff59f60c96f.zip
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
Diffstat (limited to 'tools')
-rwxr-xr-xtools/configure28
-rwxr-xr-xtools/sapi5_init_tts.vbs29
-rwxr-xr-xtools/sapi5_stop_tts.vbs18
-rwxr-xr-xtools/sapi5_voice.vbs68
-rw-r--r--tools/voicecommon.sh21
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 () {
fi
if [ `which festival` ]; then
FESTIVAL="(F)estival "
- FESTIVAL_OPTS="FLITE_OPTS=\"\""
+ FESTIVAL_OPTS="FESTIVAL_OPTS=\"\""
DEFAULT_TTS="festival"
DEFAULT_TTS_OPTS=$FESTIVAL_OPTS
DEFAULT_NOISEFLOOR="500"
DEFAULT_CHOICE="F"
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
- echo "You need Festival, eSpeak or Flite in your path to build voice files"
+ if [ "$FESTIVAL" = "$FLITE" ] && [ "$FLITE" = "$ESPEAK" ] && [ "$ESPEAK" = "$SAPI5" ]; then
+ echo "You need Festival, eSpeak or Flite in your path, or SAPI5 available to build voice files"
exit
fi
- echo "TTS engine to use: ${FLITE}${FESTIVAL}${ESPEAK}(${DEFAULT_CHOICE})?"
+ echo "TTS engine to use: ${FLITE}${FESTIVAL}${ESPEAK}${SAPI5}(${DEFAULT_CHOICE})?"
option=`input`
case "$option" in
[Ll])
@@ -356,6 +365,11 @@ voiceconfig () {
NOISEFLOOR="500"
TTS_OPTS=$FESTIVAL_OPTS
;;
+ [Ss])
+ TTS_ENGINE="sapi5"
+ NOISEFLOOR="500"
+ TTS_OPTS=$SAPI5_OPTS
+ ;;
*)
TTS_ENGINE=$DEFAULT_TTS
TTS_OPTS=$DEFAULT_TTS_OPTS
@@ -413,11 +427,15 @@ voiceconfig () {
# ENC_OPTS=$DEFAULT_ENC_OPTS
# esac
echo "Using $ENCODER for encoding voice clips"
+ TEMPDIR="${pwd}"
+ if [ `which cygpath` ]; then
+ TEMPDIR=`cygpath . -a -w`
+ fi
cat > voicesettings.sh <<EOF
TTS_ENGINE="${TTS_ENGINE}"
ENCODER="${ENCODER}"
-TEMPDIR="${pwd}"
+TEMPDIR="$TEMPDIR"
NOISEFLOOR="${NOISEFLOOR}"
${TTS_OPTS}
${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 @@
+'***************************************************************************
+' __________ __ ___.
+' 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
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 @@
+'***************************************************************************
+' __________ __ ___.
+' 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.
+'
+'***************************************************************************
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 @@
+'***************************************************************************
+' __________ __ ___.
+' 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
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
# The oggenc executable
VORBIS_BIN=oggenc
+# Tools directory
+TOOLSDIR=`dirname $0`
+
# The wavtrim executable
-WAVTRIM=`dirname $0`/wavtrim
+WAVTRIM=$TOOLSDIR/wavtrim
+
+# The SAPI5 script directory
+SAPI5DIR=`cygpath $TOOLSDIR -a -w`
#####################
# Festival settings #
@@ -158,12 +164,20 @@ init_tts() {
fi
;;
espeak)
- # Check for flite
+ # Check for espeak
if [ ! `which $ESPEAK_BIN` ]; then
echo "Error: $ESPEAK_BIN not found"
exit 5
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"
exit 2
@@ -268,6 +282,9 @@ voice() {
echo "Action: Generate $WAV_FILE with flite"
echo -E "$TO_SPEAK" | $FLITE_BIN $FLITE_OPTS -o "$WAV_FILE"
;;
+ sapi5)
+ cscript /B "$SAPI5DIR\sapi5_voice.vbs" ""$TO_SPEAK"" "$WAV_FILE"
+ ;;
esac
fi
fi