【发布时间】:2017-02-28 01:28:05
【问题描述】:
我正在尝试从文本转语音接口 (MaryTTS) 获取音频流并将其流式传输到 SIP RTP 会话中(使用 Peers)。
Peers 想要一个SoundSource 来流式传输音频,这是一个定义为的接口
public interface SoundSource {
byte[] readData();
}
MaryTTS 将String 合成为AudioInputStream。我试图简单地读取流并将其缓冲到实现SoundSource 的 Peers 行中
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 以满足这些要求?
【问题讨论】: