I am making a program and I started at the first example for sphinx 4. I can't even run the program becouse I get an error:new ConfigurationManager(args [0]) so I can't even run the program. Please help. Here is my code:

import java.net.URL;

import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;

import edu.cmu.sphinx.frontend.util.Microphone;
import edu.cmu.sphinx.recognizer.Recognizer;
import edu.cmu.sphinx.result.Result;
import edu.cmu.sphinx.util.props.ConfigurationManager;

public class HelloWorld {
    // Default voice is Kevin16
    private static final String VOICENAME = "kevin16";
    private static final String VOICENAME2 = "kevin";
    static String resultText;
    public static String[] som;

    public static void main(String[] args) {

    public static void ISpeak(){
        ConfigurationManager cm;

        if (som.length > 0) {
            cm = new ConfigurationManager(som [0]);
        } else {
            cm = new ConfigurationManager(HelloWorld.class.getResource("helloworld.config.xml"));

        Recognizer recognizer = (Recognizer) cm.lookup("recognizer");

        // start the microphone or exit if the programm if this is not possible
        Microphone microphone = (Microphone) cm.lookup("microphone");
        if (!microphone.startRecording()) {
            System.out.println("Cannot start microphone.");

        System.out.println("Say: (Good morning | Hello) ( Bhiksha | Evandro | Paul | Philip | Rita | Will | JARVIS )");

        // loop the recognition until the programm exits.
        while (true) {
            System.out.println("Start speaking. Press Ctrl-C to quit.\n");

            Result result = recognizer.recognize();

            if (result != null) {
                resultText = result.getBestFinalResultNoFiller();
                System.out.println("You said: " + resultText + '\n');
            } else {
                System.out.println("I can't hear what you said.\n");

    public static void JSpeak(){
        Voice voice;
        // Taking instance of voice from VoiceManager factory.
        VoiceManager voiceManager = VoiceManager.getInstance();
        voice = voiceManager.getVoice(VOICENAME);
        // Allocating voice
        // word per minute

        // Read and speak
        voice.speak("Hello sir. What do you want to do?");

You declare the array variable som but you don't initialise it, so som is still null, it doesn't refer to an array yet, the array doesn't exist, it has no members, so you can't use som[0]

This article has been dead for over six months. Start a new discussion instead.