Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Java Speech API

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Speech API

    Simple Java Speech API program always gives a null pointer exception on synthesizer.allocate()...why?? how can i use system voice in my java program using JSAPI ?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java Speech API

    Can you post a small program that compiles, execute and shows the problems.
    Also copy the full text of the error messages and post it here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Speech API

    Quote Originally Posted by Norm View Post
    Can you post a small program that compiles, execute and shows the problems.
    Also copy the full text of the error messages and post it here.
    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();
    }

    }

    }



    error.....

    java.lang.NullPointerException
    at HelloWorld.main(HelloWorld.java:22)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java Speech API

    Where did you get the javax.speech package you are using?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jan 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Speech API

    https://www.assembla.com/code/sonido...mat=raw&rev=13

Similar Threads

  1. jsapi_To write a program using netbean ide for java speech api.
    By jackdoc in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 23rd, 2012, 09:38 AM
  2. Java Speech API and web.. problem getting ideas
    By yugeshshrestha in forum Java Theory & Questions
    Replies: 0
    Last Post: July 7th, 2012, 02:27 AM
  3. Java Speech API problem very beginner
    By yugeshshrestha in forum Java Theory & Questions
    Replies: 3
    Last Post: July 4th, 2012, 12:52 PM
  4. java sun speech api
    By zulqar in forum AWT / Java Swing
    Replies: 1
    Last Post: November 2nd, 2010, 01:35 AM
  5. Difference between Speech API and Sound API
    By zeeshanmirza in forum Java SE APIs
    Replies: 1
    Last Post: October 22nd, 2009, 12:22 AM