0
我试图从文本到语音接口(MaryTTS)获取音频流并在SIP RTP会话(使用同行)中对其进行流式传输。将音频流转换为PCM
同行想要一个SoundSource
流音频,其是定义为
public interface SoundSource {
byte[] readData();
}
一个接口和MaryTTS synthesises一个String
到AudioInputStream
。我想简单的读取流和缓冲它同行实施SoundSource
,在
MaryInterface tts = new LocalMaryInterface();
AudioInputStream audio = tts.generateAudio("This is a test.");
SoundSource soundSource = new SoundSource() {
@Override
public byte[] readData() {
try {
byte[] buffer = new byte[1024];
audio.read(buffer);
return buffer;
} catch (IOException e) {
return null;
}
}
};
// issue call with soundSource using Peers
电话铃声响起的线,我听到一个缓慢的,低的,嘈杂的声音,而不是合成语音。我猜这可能与SIP RTP会话期望的音频格式有关,因为Peers文档状态为
声源必须是以下格式的原始音频:线性PCM 8kHz,16位有符号,单声道,小端。
如何转换/读取AudioInputStream
以满足这些要求?我知道