Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将输入发送到stdin并在Java-Festival TTS中获得完整输出_Java_Linux_Terminal_Text To Speech_Festival - Fatal编程技术网

将输入发送到stdin并在Java-Festival TTS中获得完整输出

将输入发送到stdin并在Java-Festival TTS中获得完整输出,java,linux,terminal,text-to-speech,festival,Java,Linux,Terminal,Text To Speech,Festival,我试图使用Java Runtime.getRuntime().exec(String)命令来运行Festival,然后使用OutputStreamWriter将一些命令写入进程的outpustream 这非常有效,我可以做这样的事情: Process p = Runtime.getRuntime().exec("festival"); Writer w = new OutputStreamWriter(p.getOutputStream()); w.append("(SayText \"Hell

我试图使用Java Runtime.getRuntime().exec(String)命令来运行Festival,然后使用OutputStreamWriter将一些命令写入进程的outpustream

这非常有效,我可以做这样的事情:

Process p = Runtime.getRuntime().exec("festival");
Writer w = new OutputStreamWriter(p.getOutputStream());
w.append("(SayText \"Hello World\")");
w.flush();
很明显,我能告诉你这是怎么回事,它是通过说话人说的

我现在很难从终端中看到的内容中获取文本输出。我正在尝试运行一些其他命令(例如(voice.list)),这些命令输出文本,可能是到stdout

例如,我曾尝试以以下方式使用BufferedReader:

BufferedReader reader = new BufferedReader (new InputStreamReader(p.getInputStream()));
w.append("(voice.list)");
w.flush();

String output = "";
String line = reader.readLine();
System.out.println(line);

while ((line = reader.readLine()) != null)
{
  System.out.println("Reading: " + line);
  output += line;
}
(System.out.println只是为了调试,如果我能让它工作的话,我会以一种更干净的方式完成整个过程。)

无论我尝试什么代码,我都无法从Festival获得任何输出。我可以从其他命令获得输出。例如,我也尝试过这段代码,它可以与许多其他命令(如
ls
)一起使用,但不能与Festival一起使用

有没有人知道我怎样才能让它工作


谢谢。

节日可能会将其文本输出到stderr而不是stdout上。试着替换

p.getInputStream()

p.getErrorStream()