views:

456

answers:

3

I am trying to run a program using freetts. I am able to compile the program however I am not able to use kevin or mbrola voices I get the follwing o/p msgs at the end

System property "mbrola.base" is undefined. Will not use MBROLA voices. LINE UNAVAILABLE: Format is pcm_signed 16000.0 Hz 16 bits 1 channel big endian

import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.*;

class freetts {

    public static void main(String[] args) {
            try{ 
                Calendar calendar = new GregorianCalendar();
                String sayTime = "It is " + calendar.get(Calendar.HOUR) + " " + calendar.get(Calendar.MINUTE) + " " + (calendar.get(Calendar.AM_PM)==0 ? "AM":"PM");
                Synthesizer synth = Central.createSynthesizer(null);
                synth.allocate();
                synth.resume();
                synth.speakPlainText(sayTime, null);
                synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
                synth.deallocate();

            }
            catch(Exception e){
                e.printStackTrace();
            }

    }

}
A: 

It seems that "To enable FreeTTS support for MBROLA, merely copy mbrola/mbrola.jar to lib/mbrola.jar. Then, whenever you run any FreeTTS application, specify the "mbrola.base" directory as a system property:

  java -Dmbrola.base=/home/jim/mbrola -jar bin/FreeTTSHelloWorld.jar mbrola_us1"

I found this at:

http://freetts.sourceforge.net/mbrola/README.html

John
A: 

The second phrase has nothing to do with mbrola, but with a horrendous java linux sound bug that is still not fixed. Check the third post here: http://forums.sun.com/thread.jspa?threadID=5189363

That is happening because freetts "trusts" the sourcedataline, instead of doing the workaround on that post. The bug is in the jdk, but can be worked around by finding where in freetts that is happening and inserting the workaround & recompiling.

Here is a testcase

package util.speech;

import java.util.Iterator;
import java.util.Locale;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.SourceDataLine;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

public class VoiceTest {



    public VoiceTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {

    }

    @After
    public void tearDown() {
    }

    @Test
    public void testDataLineAvailableAndBuggyInJDK() throws LineUnavailableException {
        boolean failedSimpleGetLine = false;
        AudioFormat format = new AudioFormat(44100, 16, 2, true, false);
        SourceDataLine line = null;
        DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
        try {
            line = (SourceDataLine) AudioSystem.getLine(info);
        } catch (LineUnavailableException e) {
            //ok, at least it says so
            throw e;
        }
        try {
            //if this fails the jdk is very buggy, since it just told us
            //the line was available
            line.open(format);
        } catch (LineUnavailableException e) {
            failedSimpleGetLine = true;
        } finally {
            if (line.isOpen()) {
                line.close();
            }
        }



        //now if this is true, test if it's possible to get a valid sourcedataline
        //or the only bug is adquiring a sourcedataline doesn't throw a lineunavailable
        //exception before open
        Assume.assumeTrue(failedSimpleGetLine);
        line = getSourceDataLine(format);
        if (line == null) {
            return;
        }

        try {
            line.open(format);
        } catch (LineUnavailableException e) {
            //ok then it is consistent, and there is only one bug
            fail("Line Unavailable after being adquired");
        } finally {
            if (line.isOpen()) {
                line.close();
            }
        }
        fail("line available after first test not managing to adquire it");
    }


    private SourceDataLine getSourceDataLine(AudioFormat format) {
        try {
            DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
            for (Mixer.Info mi : AudioSystem.getMixerInfo()) {
                SourceDataLine dataline = null;
                try {
                    Mixer mixer = AudioSystem.getMixer(mi);
                    dataline = (SourceDataLine) mixer.getLine(info);
                    dataline.open(format);
                    dataline.start();
                    return dataline;
                } catch (Exception e) {
                }
                if (dataline != null) {
                    try {
                        dataline.close();
                    } catch (Exception e) {
                    }
                }
            }
        } catch (Exception e) {
        }
        return null;
    }
}
i30817
A: 

but it merely helps.

copy paste of mbrola/mbrola.jar to lib/mbrola.jar doesn't helps in anyways.

katrina