我用过一个AudioInputStream,我用MaryTTS把它从文本转换成语音。我想把这个音频发送给客户机角,在这种情况下,.How我可以做到这一点与http?我已经把音频放到了一个字节数组中,我如何发送它?
这个方法返回一个字节数组,想要将它发送到angular应用程序并播放音频.Any帮助吗?
public byte[] generateVoice( ) {
LocalMaryInterface maryInterface = null;
try {
maryInterface = new LocalMaryInterface();
} catch (MaryConfigurationException e) {
System.err.println("Could not initialize MaryTTS interface: " + e.getMessage());
e.printStackTrace();
}
try {
if (maryInterface != null) audio = maryInterface.generateAudio("this is the first audio");
} catch (SynthesisException e) {
System.err.println("Synthesis failed: " + e.getMessage());
}
byte[] buffer = new byte[0];
try {
buffer = new byte[audio.available()];
while ((audio.read(buffer)) != -1) {
System.out.println("the buffer is being filled");
}
} catch (IOException e) {
e.printStackTrace();
}
return buffer;
}发布于 2018-03-27 05:08:14
你得做一条流。看一下:npm stream-buffer
https://stackoverflow.com/questions/49499959
复制相似问题