我正在尝试通过 java 运行 festival.exe 。我尝试运行以下代码,但显然无法正常工作。哪里出了问题?
String [] cmdArray= {"C://Festival//festival.exe","(SayText \"Hello\")"};
Runtime rt = Runtime.getRuntime();
rt.exec(cmdArray);
我什至尝试过:
Process process = new ProcessBuilder("C:\\festival\\festival.exe","(SayText \"Hello\")").start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
System.out.printf("Output of running %s is:", Arrays.toString(args));
while ((line = br.readLine()) != null) {
System.out.println(line);
}
这也会产生空白输出,并且不起作用。
答案 0 :(得分:1)
最好在APIs provided by Festival上使用,而不是调用命令行过程。
可以在此处找到示例Java客户端:https://github.com/festvox/festival/blob/master/src/modules/java/cstr/festival/Client.java