ciao a tutti, stavo cercando di imparare a utilizzare le java speech per i miei scopi da programmatore XD il mio problema è che mi da un errore alla riga dove c è scritto synth.allocate(); l errore, è java.lang.NullPointerExtencion ....il punto è che quel metoto ovvero synth.allocate(); so che nn deve contenere parametri xchè è una funzione che ritorna a void....bo ....chissà se qualcuno può aiutarmi , xchè praticamente pochi programmatori le utilizzano queste api...
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();
}
}
}

Rispondi quotando
