8 Replies Latest reply: Jun 2, 2009 5:37 AM by 843802 RSS

    jsapi speehc synthesizer and recognizer

    843802
      Hello friends, Have any one of u done a project on speech synthesizer and recognizer using jsapi and Freetts...???
        • 1. Re: jsapi speehc synthesizer and recognizer
          843802
          yes iam,

          fallow the steps:
          step1:
          see these links
          http://freetts.sourceforge.net/docs/jsapi_setup.html
          http://java.sun.com/products/java-media/speech/
          step2:
          then download freetts from sourceforge.net
          fallow the link http://java.sun.com/products/java-media/speech/reference/codesamples/index.html
          step3:
          after successful download you can find freetts-1.2.1 ( version may change) zip file so, unzip the file.
          u can find jsapi.exe in freetts-1.2.1\lib directory.
          run the jsapi.exe the u get jsapi.jar file
          step4:
          add all jar files to the classpath
          step5:

          find this step in next thread...
          • 2. Re: jsapi speehc synthesizer and recognizer
            843802
            (contd..) to previous thread step5

            //testing
            u can find so many examples in the net though iam giving one below!!

            Class name is Main.java

            code follows
            ---------------------------
            package tts; // my package

            import java.util.Locale;

            import javax.speech.Central;
            import javax.speech.synthesis.Synthesizer;
            import javax.speech.synthesis.SynthesizerModeDesc;
            import javax.speech.synthesis.Voice;
            import java.io.*;
            import java.lang.*;

            /**
            *
            * @author Administrator
            */
            public class Main {

            /**
            * @param args the command line arguments
            */
            public static void main(String[] args) {
            System.out.println("args==" + args.toString());
            String voiceName = (args.length > 0)
            ? args[0]
            : "kevin16";
            voiceName = new String("kevin16");
            System.out.println("Voice Name is :" + voiceName);
            //System.out.println("Using voice: " + voiceName);

            try {
            System.out.println("---1---");
            /* Find a synthesizer that has the general domain voice
            * we are looking for. NOTE: this uses the Central class
            * of JSAPI to find a Synthesizer. The Central class
            * expects to find a speech.properties file in user.home
            * or java.home/lib.
            *
            * If your situation doesn't allow you to set up a
            * speech.properties file, you can circumvent the Central
            * class and do a very non-JSAPI thing by talking to
            * FreeTTSEngineCentral directly. See the WebStartClock
            * demo for an example of how to do this.
            */

            SynthesizerModeDesc desc = new SynthesizerModeDesc(
            null, // engine name
            "general", // mode name
            Locale.US, // locale
            null, // running
            null); // voice
            System.out.println("--2--");
            Synthesizer synthesizer = Central.createSynthesizer(desc);

            /* Just an informational message to guide users that didn't
            * set up their speech.properties file.
            */
            System.out.println("--3--");
            if (synthesizer == null) {
            System.out.println("--3(1)--");
            // System.err.println(noSynthesizerMessage());
            System.exit(1);
            }
            System.out.println("--4--");

            /* Get the synthesizer ready to speak
            */
            synthesizer.allocate();
            synthesizer.resume();

            /* Choose the voice.
            */
            desc = (SynthesizerModeDesc) synthesizer.getEngineModeDesc();
            Voice[] voices = desc.getVoices();
            Voice voice = null;
            System.out.println("Length :" + voices.length);
            for (int i = 0; i < voices.length; i++) {
            if (voices.getName().equals(voiceName)) {
            voice = voices[i];
            System.out.println("voice " + voice);
            break;
            }
            }
            if (voice == null) {
            System.err.println(
            "Synthesizer does not have a voice named " + voiceName + ".");
            System.exit(1);
            }
            synthesizer.getSynthesizerProperties().setVoice(voice);
            System.out.println("going 2 play");

            /* The the synthesizer to speak and wait for it to
            * complete.
            */
            //synthesizer.speakPlainText("Hello world!,iam vijay testing Freetts", null);

            String str = new String("heloo world");





            System.out.println("String is ....: " + str);
            synthesizer.speakPlainText(str, null);
            synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);

            /* Clean up and leave.
            */
            synthesizer.deallocate();
            System.exit(0);

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

            // TODO code application logic here
            }

            @Override
            protected Object clone() throws CloneNotSupportedException {
            return super.clone();
            }

            @Override
            public boolean equals(Object obj) {
            return super.equals(obj);
            }

            @Override
            protected void finalize() throws Throwable {
            super.finalize();
            }

            @Override
            public int hashCode() {
            return super.hashCode();
            }

            @Override
            public String toString() {
            return super.toString();
            }
            }
            --------------------------


            here we are using Kelvin16 as voice type..

            still u have any problem during the running ... let me know
            • 3. Re: jsapi speehc synthesizer and recognizer
              843802
              Can You give any other links through which we can down load the jars...!!

              because I am unable to open the links which you mentioned over there...
              • 4. Re: jsapi speehc synthesizer and recognizer
                843802
                search for google
                • 5. Re: jsapi speehc synthesizer and recognizer
                  843802
                  vijay.katta wrote:
                  yes iam,

                  fallow the steps:
                  step1:
                  see these links
                  http://freetts.sourceforge.net/docs/jsapi_setup.html
                  http://java.sun.com/products/java-media/speech/
                  step2:
                  then download freetts from sourceforge.net
                  fallow the link http://java.sun.com/products/java-media/speech/reference/codesamples/index.html
                  step3:
                  after successful download you can find freetts-1.2.1 ( version may change) zip file so, unzip the file.
                  u can find jsapi.exe in freetts-1.2.1\lib directory.
                  run the jsapi.exe the u get jsapi.jar file
                  step4:
                  add all jar files to the classpath
                  step5:

                  find this step in next thread...Hi Vijay
                  I followed the steps mentioned by you but i am getting NullPointerException. In other thread [t-5349403]You have mentioned that just copying jsapi.jar is not enough. But i am not getting any other jar in lib folder of freetts1.2.2. When i click jsapi.exe. It is extracting jsapi.jar in lib folder.

                  Any pointers, what could be the issue.

                  Thanks,
                  Sandeep
                  • 6. Re: jsapi speehc synthesizer and recognizer
                    843802
                    Hi,

                    I downloaded the bin folder this time. Earlier i had downloaded src folder. In Bin folder, there are other jars also apart from jsapi.jar. Now i copy the all the jars to
                    jre\lib\ext and Speech.properties to jre\lib folder. I am able to run HelloWorld example which is with freetts. The HelloWorld example in Sun tutorials is not working.

                    After running the freetts example. I am getting "System property "mbrola.base" is undefined. Will not use MBROLA voices" in console of eclipse. And i am able to hear Hello World through speakers. What does this signify and where do we set this property.

                    Thanks,
                    Sandeep
                    • 7. Re: jsapi speehc synthesizer and recognizer
                      843802
                      I am having the same problem that seems to be plaguing the rest of the new community. When I call the synthesizer.allocate() method, I receive a NullPointerException. I have tried adding all of the jar files to the classpath in netbeans 6.7.1 to no avail. I have also followed the steps that you provided in the tutorial; however, I am throwing the same exception. Also, I have tried your sample code, but the syntax is so far off, I can't repair it to working order. I would really appreciate any help that can be offered.
                      • 8. Re: jsapi speehc synthesizer and recognizer
                        Darryl Burke
                        deadfade, welcome to the forum. Please don't post in threads that are long dead. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.

                        I'm locking this thread now.

                        db