I am trying the SpeechSynthesis program in the book with iCommand-0.6-preview and is having the following error:
Exception in thread "main" java.lang.NullPointerException
at icommand.nxt.comm.NXTCommand.openWrite(Unknown Source)
at icommand.nxt.FileSystem.upload(Unknown Source)
at SpeechSynthesis.say(SpeechSynthesis.java:27)
at SpeechSynthesis.main(SpeechSynthesis.java:43)
Please help
*******************************************
The SpeechSynthesis.java is listed below:
import icommand.nxt.*;
import icommand.nxt.comm.*;
import java.io.*;
public class SpeechSynthesis {
static File freettsdir = new File("C:/Lejos/freetts-1.2.1-bin/freetts-1.2.1");
static File converttool = new File("C:/Lejos/wavrsocvt/wavrsocvt.exe");
static String WAVNAME = "temp.wav";
static String RSONAME = "temp.rso";
public static void say(String sentence) {
String execString = "java -jar lib/freetts.jar -dumpAudio " + WAVNAME + " -text ";
try {
Process p = Runtime.getRuntime().exec(execString + sentence,null,freettsdir);
p.waitFor();
p = Runtime.getRuntime().exec(converttool + " " + WAVNAME + " -O=" + freettsdir,null,freettsdir);
p.waitFor();
} catch (Exception e) {
System.out.println("Exceptioon: " + e);
}
System.out.println("rsoFile is " + freettsdir + "\\" + RSONAME);
File rsoFile = new File(freettsdir + "\\" + RSONAME);
if (rsoFile == null)
System.out.println("RSO file not found");
byte status = FileSystem.upload(rsoFile);
if(status == 0)
System.out.println("File successfully uploaded");
else {
System.out.println("Error uploading " + rsoFile.getName() + ": " + Integer.toHexString(status));
return;
}
rsoFile.delete();
Sound.playSoundFile(rsoFile.getName());
NXTCommand.setVerify(true);
do {} while(FileSystem.delete(rsoFile.getName())!=0);
}
public static void main(String[] args) {
// NXTCommand.open();
System.out.println("Program started");
SpeechSynthesis.say("PLEASE PUT DOWN YOUR WEAPON");
SpeechSynthesis.say("YOU HAVE 20 SECONDS TO COMPLY");
SpeechSynthesis.say("YOU NOW HAVE 15 SECONDS TO COMPLY");
NXTCommand.close();
}
}
