将原始字节转换为音频声音

发布于 2024-08-31 11:18:30 字数 290 浏览 2 评论 0原文

在我的应用程序中,我从 freeTTS 包继承了 javastreamingaudio 类,然后绕过将字节数组发送到 SourceDataLine 进行音频处理的 write 方法。我没有写入数据行,而是将此字节数组和后续字节数组写入缓冲区,然后将其带入类中并尝试处理为声音。我的应用程序将声音处理为浮点数组,因此我转换为浮点并尝试处理,但总是得到静态声音。

我确信这是要走的路,但一路上我错过了一些东西。我知道声音被作为帧处理,每个帧都是一组字节,因此在我的应用程序中,我必须以某种方式将字节处理为帧。我看待这个问题的方式正确吗?提前感谢您的帮助。

In my application I inherit a javastreamingaudio class from the freeTTS package then bypass the write method which sends an array of bytes to the SourceDataLine for audio processing. Instead of writing to the data line, I write this and subsequent byte arrays into a buffer which I then bring into my class and try to process into sound. My application processes sound as arrays of floats so I convert to float and try to process but always get static sound back.

I am sure this is the way to go but am missing something along the way. I know that sound is processed as frames and each frame is a group of bytes so in my application I have to process the bytes into frames somehow. Am I looking at this the right way? Thanx in advance for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪也成诗 2024-09-07 11:18:30

首先,您想要将字节数组转换为 InputStream。然后,您使用 AudioSystem 从该输入流创建一个 AudioInputStream。一旦你有了音频流,你基本上就拥有了音频,你可以将其写入文件或做任何你喜欢的事情。

ByteArrayInputStream oInstream = new ByteArrayInputStream(ayAudioData);
AudioInputStream oAIS = AudioSystem.getAudioInputStream(oInstream);

First, you want to convert your byte array to an InputStream. Then, you create an AudioInputStream from that Inputstream using your AudioSystem. Once you have your audio stream, you essentially have audio and you can write it to file or do whatever you like.

ByteArrayInputStream oInstream = new ByteArrayInputStream(ayAudioData);
AudioInputStream oAIS = AudioSystem.getAudioInputStream(oInstream);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文