import com.sun.speech.freetts.*;
import java.util.*;
public class Demofreetts
{
private String speaktext;
public void doSpeak(String speak, String voice)
{
speaktext = speak;
try
{
VoiceManager voiceManager = VoiceManager.getInstance();
Voice voices = voiceManager.getVoice(voice);
Voice sp = null;
if(voices != null)
sp = voices;
else
System.out.println("No Voice Available");
sp.allocate();
sp.speak(speaktext);
sp.deallocate();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[]args)
{
Demofreetts obj = new Demofreetts();
obj.doSpeak(args[0],"Kelvin16");
}
}
The above code causes the following error:
System property "mbrola.base" is undefined. Will not use MBROLA voices No Voice Available java.lang.NullPointerException at Demofreetts.doSpeak(Demofreetts.java:24) at Demofreetts.main(Demofreetts.java:39)