3 Replies - 1372 Views - Last Post: 15 February 2012 - 12:10 AM Rate Topic: -----

#1 roshan.nerd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 04-February 12

Runtime Error - JSAPI HelloWorld Program

Posted 04 February 2012 - 11:03 PM

While running basic HelloWorld program using JSAPI, it is showing error "java.lang.NullPointerException at HelloWorld.main(HelloWorld.java:11)"

Following is the code:
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;

public class HelloWorld {
    public static void main(String args[]) {
    try {
        // Create a synthesizer for English
        Synthesizer synth = Central.createSynthesizer(new SynthesizerModeDesc(Locale.ENGLISH));
        // Get it ready to speak
        synth.allocate();
        synth.resume();
        // Speak the "Hello world" string
        synth.speakPlainText("Hello, world!", null);
        // Wait till speaking is done
        synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
        // Clean up
        synth.deallocate();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
}


I edit my program:
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;

public class HelloWorld {
public static void main(String args[]) {
    try {
        // Create a synthesizer for English
        SynthesizerModeDesc modeDesc = new SynthesizerModeDesc(null,"general",Locale.US,null,null);
        System.out.println(modeDesc);
        Synthesizer synth = Central.createSynthesizer(modeDesc);
        //Synthesizer synth = Central.createSynthesizer(null);
        // Get it ready to speak
        System.out.println(synth);
        synth.allocate();
        synth.resume();
        // Speak the "Hello world" string
        synth.speakPlainText("Hello, world!", null);
        // Wait till speaking is done
            synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
        // Clean up
        synth.deallocate();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
}


and it is giving output:
javax.speech.synthesis.SynthesizerModeDesc@9304b1
null
java.lang.NullPointerException
    at HelloWorld.main(HelloWorld.java:15)


It seems that SynthesizerModeDesc is working fine but it is not detecting any engine as i tried passing null also to the function Central.createSynthesizer (i.e get default engine) but still it is returning null. I checked number of engines it is detecting, but it shows 0.

Please help me !! :(

Is This A Good Question/Topic? 0
  • +

Replies To: Runtime Error - JSAPI HelloWorld Program

#2 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1131
  • View blog
  • Posts: 2,484
  • Joined: 05-May 05

Re: Runtime Error - JSAPI HelloWorld Program

Posted 05 February 2012 - 01:16 AM

You probably need to register a JSAPI implementation and possibly a voice. I was to able to get it up and running no problem with this tutorial. I threw all the jars in the lib folder on the classpath.
Was This Post Helpful? 0
  • +
  • -

#3 Achri  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 52
  • Joined: 18-June 11

Re: Runtime Error - JSAPI HelloWorld Program

Posted 05 February 2012 - 02:36 AM

I was really interested in the TTS idea. So I filled the last hour or so trying to get it to work.

Using FreeTTS I managed to get my Netbeans at the same error you have. To fix this error I had to simply add the .jar files found in freetts-1.2.2-bin\freetts-1.2\lib to my project.

In Netbeans:
1. Right click your package and click properties
2. Click Libraries
3. On the right in the Compile Tab is the button Add JAR/Folder
Using Add JAR/Folder

I was really interested in the TTS idea. So I filled the last hour or so trying to get it to work.

Using FreeTTS I managed to get my Netbeans at the same error you have. To fix this error I had to simply add the .jar files found in freetts-1.2.2-bin\freetts-1.2\lib to my project.

In Netbeans:
1. Right click your package and click properties
2. Click Libraries
3. On the right in the Compile Tab is the button Add JAR/Folder
Using Add JAR/Folder add each JAR

After I did all of this I ran into a new error:
"System property "mbrola.base" is undefined. Will not use MBROLA voices."

The program will say numbers but not any text. Weird eh.

Also, I forgot to mention that you do need to copy speech.properties from freetts-1.2.2-bin\freetts-1.2 into your java's 'home' folder.



And I just learned, is there no edit post button on DIC?
Was This Post Helpful? 0
  • +
  • -

#4 roshan.nerd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 04-February 12

Re: Runtime Error - JSAPI HelloWorld Program

Posted 15 February 2012 - 12:10 AM

View PostAchri, on 05 February 2012 - 02:36 AM, said:

I was really interested in the TTS idea. So I filled the last hour or so trying to get it to work.

Using FreeTTS I managed to get my Netbeans at the same error you have. To fix this error I had to simply add the .jar files found in freetts-1.2.2-bin\freetts-1.2\lib to my project.

In Netbeans:
1. Right click your package and click properties
2. Click Libraries
3. On the right in the Compile Tab is the button Add JAR/Folder
Using Add JAR/Folder

I was really interested in the TTS idea. So I filled the last hour or so trying to get it to work.

Using FreeTTS I managed to get my Netbeans at the same error you have. To fix this error I had to simply add the .jar files found in freetts-1.2.2-bin\freetts-1.2\lib to my project.

In Netbeans:
1. Right click your package and click properties
2. Click Libraries
3. On the right in the Compile Tab is the button Add JAR/Folder
Using Add JAR/Folder add each JAR

After I did all of this I ran into a new error:
"System property "mbrola.base" is undefined. Will not use MBROLA voices."

The program will say numbers but not any text. Weird eh.

Also, I forgot to mention that you do need to copy speech.properties from freetts-1.2.2-bin\freetts-1.2 into your java's 'home' folder.



And I just learned, is there no edit post button on DIC?


I am using sphinx and i have tried all this already. But still it is showing the error.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1