Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
它在文档中说“音频必须是 PCM、单声道、16 位采样,采样率为 8000 Hz 或 16000 Hz。”
假设我想使用 DataClient,我将音频作为字节获取。我怎样才能把它转换成那个?
首先,您要将字节数组转换为 InputStream。然后,您使用 AudioSystem 从该 Inputstream 创建一个 AudioInputStream。一旦你有了音频流,你基本上就有了音频,你可以将它写入文件或做任何你喜欢的事情。
ByteArrayInputStream oInstream = new ByteArrayInputStream(ayAudioData); AudioInputStream oAIS = AudioSystem.getAudioInputStream(oInstream);