I have used a AudioInputStream , i get it from text to speech with MaryTTS . i want to send this audio to the client Angular in this case .How can i do this with http ? I have put the audio to an array of bytes and how can I send it ?
this methode returns an array of bytes .I want to send it to an angular app and play the audio .Any help please ?
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;
}