"LINE UNAVAILABLE: Format is ..."
The reason was later found in the KDE desktop: Its configuration panel has options to keep the audio device open for some time after playing beeps or other desktop sounds. The default seemed to be rather high at 60 seconds. But even after changing that to only 2 seconds, the FreeTTS library still needs to compete with some occasional other users of the audio devices.
Turns out there is no Java Exception or other mechanism to detect this error that occurs inside the FreeTTS library. All you get is the message on System.out, so there is no good way to react programatically.
If the audio device is permanently used by another program, there is of course no way to get access. Under Linux, this command will display the ID of the process that is currently holding the audio device, so you can then try to get rid of the offending program:
Workaround: Configure the FreeTTS audio player to attempt accessing the audio device more than once until it succeeds. In this example, a short delay of 0.1 seconds is used to not miss an opportunity to grab the audio device; we keep trying for 30 seconds:
System.setProperty("com.sun.speech.freetts.audio.AudioPlayer.openFailDelayMs", "100");
System.setProperty("com.sun.speech.freetts.audio.AudioPlayer.totalOpenFailDelayMs", "30000");
/sbin/fuser /dev/dsp
Hey can you please mail me a completely working program of FreeTTS in core JAVA...?
ReplyDeleteRegards
(Siddharth Razdan)
FreeTTS includes plain Java examples.
ReplyDeleteAfter you download the original FreeTTS sources,
you can run one of its examples somewhat like this:
unzip freetts-1.2.2-src.zip
freetts-1.2.2/lib
sh jsapi.sh
cd ..
# Build.xml is broken. Change the "src" path to ".":
#
vi build.xml
# Then build it
ant
# ... and run the examples
java -jar bin/HelloWorld.jar
java -jar bin/FreeTTSHelloWorld.jar
# Will complain about missing speech.properties. Copy to home dir...
cp speech.properties ~
# .. then try the *Hello*jar again