forked from len0rd/rockbox
Remove deprecated shellscripts
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15647 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1b2561b0d9
commit
a16ad96b1b
3 changed files with 0 additions and 606 deletions
|
@ -1,152 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# __________ __ ___.
|
|
||||||
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
||||||
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
||||||
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
||||||
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
||||||
# \/ \/ \/ \/ \/
|
|
||||||
# $Id$
|
|
||||||
#
|
|
||||||
# Copyright (c) 2004 Daniel Gudlat
|
|
||||||
# - http://www.rockbox.org/tracker/task/2131
|
|
||||||
# Copyright (c) 2006 Jonas Häggqvist
|
|
||||||
# - This version, only dirwalk and the following comments remains
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
# Note: You may wish to change some of the settings below.
|
|
||||||
#
|
|
||||||
# A script to automatically generate audio clips containing the names of all
|
|
||||||
# folders in a directory tree for use with the "Talkbox" feature available to
|
|
||||||
# users of the Rockbox open source firmware for Archos MP3 players and
|
|
||||||
# recorders as well as several other devices. Talkbox permits the device to
|
|
||||||
# speak the names of the folders as one navigates the directory structure on
|
|
||||||
# the device, thus permitting "eyes-free" use for those for whom the usual
|
|
||||||
# visual navigation is difficult or simply inadvisable.
|
|
||||||
#
|
|
||||||
# Audio clips are captured and stored in wave format, then converted into MP3
|
|
||||||
# format by a third party application (lame). If you execute the script,
|
|
||||||
# passing it the top level of your music file hierarchy as an argument while
|
|
||||||
# your device is connected to your PC, then the resulting audio clips will be
|
|
||||||
# generated and stored in the correct location for use with the Talkbox
|
|
||||||
# feature. Alternatively, if you mirror your music folder structure from your
|
|
||||||
# PC to your Archos device, you can just run the script on the PC and then
|
|
||||||
# update the files on your Archos with your usual synchronization routine.
|
|
||||||
#
|
|
||||||
# NOTE: If you don't already have them installed, you may obtain the Festival
|
|
||||||
# text to speech system and several voices at:
|
|
||||||
#
|
|
||||||
# http://www.cstr.ed.ac.uk/projects/festival.html
|
|
||||||
# http://festvox.org/festival/
|
|
||||||
#
|
|
||||||
# The most pleasant freely available Festival voice I know of is the slt_arctic
|
|
||||||
# voice from HST at http://hts.ics.nitech.ac.jp/
|
|
||||||
#
|
|
||||||
# Known bugs
|
|
||||||
# - This script generates talk clips for all files, Rockbox only uses talk clips
|
|
||||||
# for music files it seems.
|
|
||||||
|
|
||||||
# Include voicecommon.sh from the same dir as this script
|
|
||||||
# Any settings from voicecommon can be overridden if added below the following
|
|
||||||
# line.
|
|
||||||
source `dirname $0`'/voicecommon.sh'
|
|
||||||
|
|
||||||
####################
|
|
||||||
# General settings #
|
|
||||||
####################
|
|
||||||
|
|
||||||
# which TTS engine to use. Available: festival, flite, espeak
|
|
||||||
TTS_ENGINE=festival
|
|
||||||
# which encoder to use, available: lame, speex, vorbis (only lame will produce
|
|
||||||
# functional voice clips)
|
|
||||||
ENCODER=lame
|
|
||||||
# whether to overwrite existing mp3 files or only create missing ones (Y/N)
|
|
||||||
OVERWRITE_TALK=N
|
|
||||||
# whether, when overwriting mp3 files, also to regenerate all the wav files
|
|
||||||
OVERWRITE_WAV=N
|
|
||||||
# whether to remove the intermediary wav files after creating the mp3 files
|
|
||||||
REMOVE_WAV=Y
|
|
||||||
# whether to recurse into subdirectories
|
|
||||||
RECURSIVE=Y
|
|
||||||
# whether to strip extensions from filenames
|
|
||||||
STRIP_EXTENSIONS=Y
|
|
||||||
|
|
||||||
###################
|
|
||||||
# End of settings #
|
|
||||||
###################
|
|
||||||
|
|
||||||
strip_extension() {
|
|
||||||
TO_SPEAK=$1
|
|
||||||
# XXX: add any that needs adding
|
|
||||||
for ext in mp3 ogg flac mpc sid; do
|
|
||||||
TO_SPEAK=`echo "$TO_SPEAK" |sed "s/\.$ext//i"`
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Walk directory $1, creating talk files if necessary, descend into
|
|
||||||
# subdirecotries if specified
|
|
||||||
dirwalk() {
|
|
||||||
if [ -d "$1" ]; then
|
|
||||||
for i in "$1"/*; do
|
|
||||||
# Do not generate talk clip for talk(.wav) files
|
|
||||||
if [ `echo "$i" | grep -c "\.talk$"` -ne 0 ] || \
|
|
||||||
[ `echo "$i" | grep -c "\.talk\.wav$"` -ne 0 ]; then
|
|
||||||
echo "Notice: Skipping file \"$i\""
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
TO_SPEAK=`basename "$i"`
|
|
||||||
if [ X$STRIP_EXTENSIONS = XY ]; then
|
|
||||||
strip_extension "$TO_SPEAK"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d "$i" ]; then
|
|
||||||
# $i is a dir:
|
|
||||||
SAVE_AS="$i"/_dirname.talk
|
|
||||||
WAV_FILE="$SAVE_AS".wav
|
|
||||||
|
|
||||||
# If a talk clip already exists, only generate a new one if
|
|
||||||
# specified
|
|
||||||
if [ ! -f "$SAVE_AS" ] || [ X$OVERWRITE_TALK = XY ]; then
|
|
||||||
voice "$TO_SPEAK" "$WAV_FILE"
|
|
||||||
encode "$WAV_FILE" "$SAVE_AS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Need to be done lastly, or all variables will be dirty
|
|
||||||
if [ X$RECURSIVE = XY ]; then
|
|
||||||
dirwalk "$i"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# $i is a file:
|
|
||||||
SAVE_AS="$i".talk
|
|
||||||
WAV_FILE="$SAVE_AS".wav
|
|
||||||
|
|
||||||
# If a talk clip already exists, only generate a new one if
|
|
||||||
# specified
|
|
||||||
if [ ! -f "$i.talk" ] || [ X$OVERWRITE_TALK != XY ]; then
|
|
||||||
voice "$TO_SPEAK" "$WAV_FILE"
|
|
||||||
encode "$WAV_FILE" "$SAVE_AS"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Remove wav file if specified
|
|
||||||
if [ X$REMOVEWAV = XY ]; then
|
|
||||||
rm -f "$WAV_FILE"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "Warning: $1 is not a directory"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
init_tts
|
|
||||||
init_encoder
|
|
||||||
if [ $# -gt 0 ]; then
|
|
||||||
dirwalk "$*"
|
|
||||||
else
|
|
||||||
dirwalk .
|
|
||||||
fi
|
|
||||||
stop_tts
|
|
|
@ -1,153 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# __________ __ ___.
|
|
||||||
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
||||||
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
||||||
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
||||||
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
||||||
# \/ \/ \/ \/ \/
|
|
||||||
# $Id$
|
|
||||||
#
|
|
||||||
# Copyright 2006 Jonas Häggqvist, some parts Copyright 2004 Daniel Gudlat
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Include voicecommon.sh from the same dir as this script
|
|
||||||
# Any settings from voicecommon can be overridden if added below the following
|
|
||||||
# line.
|
|
||||||
source `dirname $0`'/voicecommon.sh'
|
|
||||||
|
|
||||||
####################
|
|
||||||
# General settings #
|
|
||||||
####################
|
|
||||||
|
|
||||||
# These settings can be overridden by passing a file with definitions as
|
|
||||||
# the fourth parameter to this script
|
|
||||||
|
|
||||||
# which TTS engine to use. Available: festival, flite, espeak
|
|
||||||
TTS_ENGINE=festival
|
|
||||||
# which encoder to use, available: lame, speex, vorbis (only lame will produce
|
|
||||||
# functional voice clips at this point)
|
|
||||||
ENCODER=lame
|
|
||||||
# Where to save temporary files
|
|
||||||
TEMPDIR=/tmp
|
|
||||||
# List of IDs to send to voicefont
|
|
||||||
VOICEFONTIDS=voicefontids
|
|
||||||
|
|
||||||
###################
|
|
||||||
# End of settings #
|
|
||||||
###################
|
|
||||||
|
|
||||||
TARGET_ID="$4"
|
|
||||||
createvoicefile() {
|
|
||||||
RLANG="$1"
|
|
||||||
$GENLANG -e=$ENGLISH -o -t=$TARGET $LANG_FILE > $VOICEFONTIDS
|
|
||||||
$VOICEFONT "$VOICEFONTIDS" "$TARGET_ID" "$TEMPDIR/" "./$RLANG.voice"
|
|
||||||
rm -f $VIOCEFONTIDS
|
|
||||||
}
|
|
||||||
|
|
||||||
deletefiles() {
|
|
||||||
# XXX: might be unsafe depending on the value of TEMPDIR
|
|
||||||
rm -f "${TEMPDIR}"/LANG_*
|
|
||||||
rm -f "${TEMPDIR}"/VOICE_*
|
|
||||||
rm -f "${TEMPDIR}"/NOT_USED_*
|
|
||||||
}
|
|
||||||
|
|
||||||
generateclips() {
|
|
||||||
ROCKBOX_DIR="$1"
|
|
||||||
RLANG="$2"
|
|
||||||
TARGET="$3"
|
|
||||||
GENLANG="$ROCKBOX_DIR"/tools/genlang
|
|
||||||
ENGLISH="$ROCKBOX_DIR"/apps/lang/english.lang
|
|
||||||
LANG_FILE="$ROCKBOX_DIR"/apps/lang/$RLANG.lang
|
|
||||||
|
|
||||||
$GENLANG -e=$ENGLISH -o -t=$TARGET $LANG_FILE |(
|
|
||||||
i=0
|
|
||||||
while read line; do
|
|
||||||
case `expr $i % 3` in
|
|
||||||
0)
|
|
||||||
# String ID no.
|
|
||||||
NUMBER=`echo $line |cut -b 2-`
|
|
||||||
;;
|
|
||||||
1)
|
|
||||||
# String ID
|
|
||||||
ID=`echo $line |cut -b 5-`
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
# String
|
|
||||||
STRING=`echo $line |cut -b 8-`
|
|
||||||
# xxx: Should the hash include encoder/tts options?
|
|
||||||
POOL_FILE=${POOL}/`echo "$STRING" |md5sum|cut -b-32`-${RLANG}.mp3
|
|
||||||
|
|
||||||
if [ -n "$POOL" ]; then
|
|
||||||
# we have a common pool of snippets, check that first
|
|
||||||
# for available mp3 sounds, and if it is available copy
|
|
||||||
# (symlink!) it over
|
|
||||||
if [ -f "$POOL_FILE" ]; then
|
|
||||||
echo "Re-using $ID from pool (${POOL_FILE})"
|
|
||||||
if [ ! -e "$TEMPDIR/$ID".mp3 ]; then
|
|
||||||
# only do this if not present
|
|
||||||
cp -f "$POOL_FILE" "$TEMPDIR/$ID".mp3
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# only make an mp3 if not already present
|
|
||||||
if [ ! -e "$TEMPDIR/$ID".mp3 ]; then
|
|
||||||
# Now generate the file
|
|
||||||
voice "$STRING" "$TEMPDIR/$ID".wav
|
|
||||||
if [ -n "$POOL" ]; then
|
|
||||||
# create it in the pool, symlink it back
|
|
||||||
encode "$TEMPDIR/$ID".wav "$POOL_FILE"
|
|
||||||
cp -f "$POOL_FILE" "$TEMPDIR/$ID".mp3
|
|
||||||
else
|
|
||||||
encode "$TEMPDIR/$ID".wav "$TEMPDIR/$ID".mp3
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -z "$4" ]; then
|
|
||||||
echo "Usage: $0 rockboxdirectory language target targetid [settingsfile]";
|
|
||||||
exit 32
|
|
||||||
else
|
|
||||||
if [ ! -d "$1" ] || [ ! -f "$1/tools/genlang" ]; then
|
|
||||||
echo "Error: $1 is not a Rockbox directory"
|
|
||||||
exit 33
|
|
||||||
fi
|
|
||||||
# Check for valid language
|
|
||||||
if [ ! -f "$1/apps/lang/$2.lang" ]; then
|
|
||||||
echo "Error: $2 is not a valid language"
|
|
||||||
exit 34
|
|
||||||
fi
|
|
||||||
if [ ! -z "$5" ]; then
|
|
||||||
if [ -f "$5" ]; then
|
|
||||||
# Read settings from file
|
|
||||||
. "$5"
|
|
||||||
else
|
|
||||||
echo "Error: $5 does not exist"
|
|
||||||
exit 36
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# XXX: check for valid $TARGET?
|
|
||||||
fi
|
|
||||||
|
|
||||||
VOICEFONT=`dirname $0`/voicefont
|
|
||||||
if [ ! -x $VOICEFONT ]; then
|
|
||||||
echo "Error: $VOICEFONT does not exist or is not executable"
|
|
||||||
exit 35
|
|
||||||
fi
|
|
||||||
|
|
||||||
init_tts
|
|
||||||
init_encoder
|
|
||||||
generateclips "$1" "$2" "$3"
|
|
||||||
stop_tts
|
|
||||||
createvoicefile "$2"
|
|
||||||
deletefiles
|
|
|
@ -1,301 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# __________ __ ___.
|
|
||||||
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
||||||
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
||||||
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
||||||
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
||||||
# \/ \/ \/ \/ \/
|
|
||||||
# $Id$
|
|
||||||
#
|
|
||||||
# Copyright (c) 2006 Jonas Häggqvist
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
# A selection of functions common to creating voicefiles for Rockbox.
|
|
||||||
#
|
|
||||||
# You may wish to change some of the settings below.
|
|
||||||
|
|
||||||
#####################
|
|
||||||
# Program locations #
|
|
||||||
#####################
|
|
||||||
|
|
||||||
# Leave any you're not using untouched, enter full path if the program is
|
|
||||||
# not found
|
|
||||||
|
|
||||||
# the festival main executable
|
|
||||||
FESTIVAL_BIN=festival
|
|
||||||
# the festival_client binary
|
|
||||||
FESTIVAL_CLIENT=festival_client
|
|
||||||
|
|
||||||
# The flite executable
|
|
||||||
FLITE_BIN=flite
|
|
||||||
|
|
||||||
# The eSpeak executable
|
|
||||||
ESPEAK_BIN=espeak
|
|
||||||
|
|
||||||
# The lame executable
|
|
||||||
LAME_BIN=lame
|
|
||||||
|
|
||||||
# The speexenc executable
|
|
||||||
SPEEX_BIN=speexenc
|
|
||||||
|
|
||||||
# The oggenc executable
|
|
||||||
VORBIS_BIN=oggenc
|
|
||||||
|
|
||||||
# Tools directory
|
|
||||||
TOOLSDIR=`dirname $0`
|
|
||||||
|
|
||||||
# The wavtrim executable
|
|
||||||
WAVTRIM=$TOOLSDIR/wavtrim
|
|
||||||
|
|
||||||
# The SAPI5 script directory
|
|
||||||
if [ -f "`which cygpath`" ]; then
|
|
||||||
SAPI5DIR=`cygpath $TOOLSDIR -a -w`
|
|
||||||
fi
|
|
||||||
|
|
||||||
#####################
|
|
||||||
# Festival settings #
|
|
||||||
#####################
|
|
||||||
|
|
||||||
# If you're not using festival, leave untouched
|
|
||||||
|
|
||||||
# whether to start the Festival server locally (Y/N)
|
|
||||||
FESTIVAL_START=Y
|
|
||||||
# the host of the Festival server
|
|
||||||
# this is set to localhost automatically when FESTIVAL_START is Y
|
|
||||||
FESTIVAL_HOST=localhost
|
|
||||||
# the port of the Festival server
|
|
||||||
FESTIVAL_PORT=1314
|
|
||||||
# where to log the Festival client output
|
|
||||||
FESTIVAL_LOG=/dev/null
|
|
||||||
# other options to the festival server
|
|
||||||
FESTIVAL_OPTS=""
|
|
||||||
|
|
||||||
##################
|
|
||||||
# Flite settings #
|
|
||||||
##################
|
|
||||||
|
|
||||||
# If you're not using flite, leave untouched
|
|
||||||
FLITE_OPTS=""
|
|
||||||
|
|
||||||
###################
|
|
||||||
# eSpeak settings #
|
|
||||||
###################
|
|
||||||
|
|
||||||
# If you're not using eSpeak, leave untouched
|
|
||||||
ESPEAK_OPTS=""
|
|
||||||
|
|
||||||
####################
|
|
||||||
# Wavtrim settings #
|
|
||||||
####################
|
|
||||||
|
|
||||||
# The maximum sample value that will be treated as silence by the wavtrim tool.
|
|
||||||
# The value is expressed as an absolute 16 bit integer sample value (0 dB equals
|
|
||||||
# 32767).
|
|
||||||
#
|
|
||||||
# 500 is a good guess - at least for Festival
|
|
||||||
|
|
||||||
NOISEFLOOR='500'
|
|
||||||
|
|
||||||
#####################
|
|
||||||
# Encoding settings #
|
|
||||||
#####################
|
|
||||||
# where to log the encoder output
|
|
||||||
ENC_LOG=/dev/null
|
|
||||||
|
|
||||||
# Suggested: --vbr-new -t --nores -S
|
|
||||||
# VBR, independent frames, silent mode
|
|
||||||
LAME_OPTS="--vbr-new -t --nores -S"
|
|
||||||
|
|
||||||
# Suggested:
|
|
||||||
# XXX: suggest a default
|
|
||||||
SPEEX_OPTS=""
|
|
||||||
|
|
||||||
# Suggested: -q0 --downmix
|
|
||||||
# Low quality, mono
|
|
||||||
VORBIS_OPTS="-q0 --downmix"
|
|
||||||
|
|
||||||
###################
|
|
||||||
# End of settings #
|
|
||||||
###################
|
|
||||||
|
|
||||||
# Check if executables exist and perform any necessary initialisation
|
|
||||||
init_tts() {
|
|
||||||
case $TTS_ENGINE in
|
|
||||||
festival)
|
|
||||||
# Check for festival_client
|
|
||||||
if [ ! -f "`which $FESTIVAL_CLIENT`" ]; then
|
|
||||||
echo "Error: $FESTIVAL_CLIENT not found"
|
|
||||||
exit 4
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for, and start festival server if specified
|
|
||||||
if [ X$FESTIVAL_START = XY ]; then
|
|
||||||
if [ ! -f "`which $FESTIVAL_BIN`" ]; then
|
|
||||||
echo "Error: $FESTIVAL_BIN not found"
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
FESTIVAL_HOST='localhost'
|
|
||||||
$FESTIVAL_BIN $FESTIVAL_OPTS --server 2>&1 > /dev/null &
|
|
||||||
FESTIVAL_SERVER_PID=$!
|
|
||||||
sleep 3
|
|
||||||
if [ `ps | grep -c "^\ *$FESTIVAL_SERVER_PID"` -ne 1 ]; then
|
|
||||||
echo "Error: Festival not started"
|
|
||||||
exit 9
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Test connection to festival server
|
|
||||||
output=`echo -E "Rockbox" | $FESTIVAL_CLIENT --server \
|
|
||||||
$FESTIVAL_HOST --otype riff --ttw --output \
|
|
||||||
/dev/null 2>&1`
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Error: Couldn't connect to festival server at" \
|
|
||||||
"$FESTIVAL_HOST ($output)"
|
|
||||||
exit 8
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
flite)
|
|
||||||
# Check for flite
|
|
||||||
if [ ! -f "`which $FLITE_BIN`" ]; then
|
|
||||||
echo "Error: $FLITE_BIN not found"
|
|
||||||
exit 5
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
espeak)
|
|
||||||
# Check for espeak
|
|
||||||
if [ ! -f "`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
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if [ ! -x $WAVTRIM ]; then
|
|
||||||
echo "Error: $WAVTRIM is not available"
|
|
||||||
exit 11
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Perform any necessary shutdown for TTS engine
|
|
||||||
stop_tts() {
|
|
||||||
case $TTS_ENGINE in
|
|
||||||
festival)
|
|
||||||
if [ X$FESTIVAL_START = XY ]; then
|
|
||||||
# XXX: This is probably possible to do using festival_client
|
|
||||||
kill $FESTIVAL_SERVER_PID > /dev/null 2>&1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if executables exist and perform any necessary initialisation
|
|
||||||
init_encoder() {
|
|
||||||
case $ENCODER in
|
|
||||||
lame)
|
|
||||||
# Check for lame binary
|
|
||||||
if [ ! -f "`which $LAME_BIN`" ]; then
|
|
||||||
echo "Error: $LAME_BIN not found"
|
|
||||||
exit 6
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
speex)
|
|
||||||
# Check for speexenc binary
|
|
||||||
if [ ! -f "`which $SPEEX_BIN`" ]; then
|
|
||||||
echo "Error: $SPEEX_BIN not found"
|
|
||||||
exit 7
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
vorbis)
|
|
||||||
# Check for vorbis encoder binary
|
|
||||||
if [ ! -f "`which $VORBIS_BIN`" ]; then
|
|
||||||
echo "Error: $VORBIS_BIN not found"
|
|
||||||
exit 10
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: no valid encoder selected: $ENCODER"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# Encode file $1 with ENCODER and save the result in $2, delete $1 if specified
|
|
||||||
encode() {
|
|
||||||
INPUT=$1
|
|
||||||
OUTPUT=$2
|
|
||||||
|
|
||||||
if [ ! -f "$INPUT" ]; then
|
|
||||||
echo "Warning: missing input file: \"$INPUT\""
|
|
||||||
else
|
|
||||||
echo "Action: Encode $OUTPUT with $ENCODER"
|
|
||||||
case $ENCODER in
|
|
||||||
lame)
|
|
||||||
$LAME_BIN $LAME_OPTS "$WAV_FILE" "$OUTPUT" >>$ENC_LOG 2>&1
|
|
||||||
;;
|
|
||||||
speex)
|
|
||||||
$SPEEX_BIN $SPEEX_OPTS "$WAV_FILE" "$OUTPUT" >>$ENC_LOG 2>&1
|
|
||||||
;;
|
|
||||||
vorbis)
|
|
||||||
$VORBIS_BIN $VORBIS_OPTS "$WAV_FILE" -o "$OUTPUT" >>$ENC_LOG 2>&1
|
|
||||||
esac
|
|
||||||
if [ ! -f "$OUTPUT" ]; then
|
|
||||||
echo "Warning: missing output file \"$OUTPUT\""
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Generate file $2 containing $1 spoken by TTS_ENGINE, trim silence
|
|
||||||
voice() {
|
|
||||||
TO_SPEAK=$1
|
|
||||||
WAV_FILE=$2
|
|
||||||
if [ ! -f "$WAV_FILE" ] || [ X$OVERWRITE_WAV = XY ]; then
|
|
||||||
if [ "${TO_SPEAK}" = "" ]; then
|
|
||||||
touch "$WAV_FILE"
|
|
||||||
else
|
|
||||||
case $TTS_ENGINE in
|
|
||||||
festival)
|
|
||||||
echo "Action: Generate $WAV_FILE with festival"
|
|
||||||
echo -E "$TO_SPEAK" | $FESTIVAL_CLIENT \
|
|
||||||
--server $FESTIVAL_HOST \
|
|
||||||
--otype riff --ttw --output "$WAV_FILE" 2>"$WAV_FILE"
|
|
||||||
;;
|
|
||||||
espeak)
|
|
||||||
echo "Action: Generate $WAV_FILE with eSpeak"
|
|
||||||
echo $ESPEAK_BIN $ESPEAK_OPTS -w "$WAV_FILE"
|
|
||||||
echo -E "$TO_SPEAK" | $ESPEAK_BIN $ESPEAK_OPTS -w "$WAV_FILE"
|
|
||||||
;;
|
|
||||||
flite)
|
|
||||||
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
|
|
||||||
trim "$WAV_FILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Trim wavefile $1
|
|
||||||
trim() {
|
|
||||||
WAVEFILE="$1"
|
|
||||||
echo "Action: Trim $WAV_FILE"
|
|
||||||
$WAVTRIM "$WAVEFILE" $NOISEFLOOR
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue