Difference between revisions of "FreeTTS"

From HalfgeekKB
Jump to navigation Jump to search
 
Line 11: Line 11:
 
  sox dst.wav -r 44100 -c 1 tmp.wav
 
  sox dst.wav -r 44100 -c 1 tmp.wav
 
  sox tmp.wav -r 44100 -c 2 dst.wav
 
  sox tmp.wav -r 44100 -c 2 dst.wav
 +
 +
I wrote a script called ''voice'' which does this automatically.  It is designed for [[Cygwin]]; changing it for [[Unix]] should be trivial.  The parts involving [[cygpath]] are only required because the versions of [[SoX]] and [[Java]] I am running are the native Windows versions and require Windows filenames.
 +
 +
<nowiki>
 +
#! /bin/sh
 +
 +
TTS=/(insert freetts path here)/lib/freetts.jar
 +
WTTS=$(cygpath -w $TTS)
 +
ONE=/tmp/t-$$-temp1.wav
 +
WONE=$(cygpath -w $ONE)
 +
TWO=/tmp/t-$$-temp2.wav
 +
WTWO=$(cygpath -w $TWO)
 +
 +
echo "Input:  $1"
 +
echo "Output: $2"
 +
java -jar "$WTTS" -voice kevin16 -dumpAudio $WONE -file $( cygpath -w $1 ) &&
 +
sox $WONE -r 44100 -c 1 $WTWO &&
 +
rm $ONE &&
 +
sox $WTWO -r 44100 -c 2 $( cygpath -w $2 ) &&
 +
rm $TWO</nowiki>

Latest revision as of 11:58, 14 November 2005

FreeTTS is a text-to-speech engine written in Java, available from http://freetts.sf.net/.

Reading text into a WAV file

The following command reads src.txt into dst.wav.

java -jar (installdir)/lib/freetts.jar -dumpAudio dst.wav -file src.txt

For decoding purposes, it may be important to note that the produced file (on my system, anyway) is PCM, 16000Hz, mono, 16-bit. Getting it into CD-quality form with SoX isn't hard, but it seems to take two passes (one for samplerate and one for channel) or it will screw up. Try

sox dst.wav -r 44100 -c 1 tmp.wav
sox tmp.wav -r 44100 -c 2 dst.wav

I wrote a script called voice which does this automatically. It is designed for Cygwin; changing it for Unix should be trivial. The parts involving cygpath are only required because the versions of SoX and Java I am running are the native Windows versions and require Windows filenames.

#! /bin/sh

TTS=/(insert freetts path here)/lib/freetts.jar
WTTS=$(cygpath -w $TTS)
ONE=/tmp/t-$$-temp1.wav
WONE=$(cygpath -w $ONE)
TWO=/tmp/t-$$-temp2.wav
WTWO=$(cygpath -w $TWO)

echo "Input:  $1"
echo "Output: $2"
java -jar "$WTTS" -voice kevin16 -dumpAudio $WONE -file $( cygpath -w $1 ) &&
sox $WONE -r 44100 -c 1 $WTWO &&
rm $ONE &&
sox $WTWO -r 44100 -c 2 $( cygpath -w $2 ) &&
rm $TWO