使用 Java 对带有 XML 的 wav 文件进行分段
我有一堆 wav 文件和相应的包含时间的 XML 文件。
我需要做的是根据 XML 文件内的时间分割 wav 文件。 解析 XML 文件应该不是问题,但我需要知道获取 wav 文件的一部分并将其保存到新的 wav 文件中的最佳方法。
是否有我可以使用的特定库,或者 Java 的声音 API 是最好的使用方法?
我会使用 Audacity 手动完成此操作,但需要一个小时,而且需要很长时间。
I have a bunch of wav files and corresponding XML files which contain times.
What I need to do is split the wav files based on the times inside the XML files.
Parsing the XML files shouldn't be a problem, but I need to know the best way to get a portion of the wav file and save it into a new wav file.
Is there a certain library I can use, or is Java's Sound API the best approach to use?
I'd do it manually using Audacity, but there are a hours of them, and that would take too long.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我做了一些研究,发现 JMF 可以用于执行此操作。 这里是指南,第 5 章6 你应该会感兴趣。
但您还应该注意,最后一个稳定版本是在八年前。维基百科提供了替代方案列表,看看您是否能找到适合您需求的东西。
I did some research and found that JMF could be used to do this. Here is a guide, chapter 5 and 6 should be interesting for you.
But you should also note that the last stable release lays eight years back. Wikipedia provides a list of alternatives, see if you can find something that suites your needs.
为了将来的参考,我将使用 SoX 进行修剪,并且我将通过使用它Java 的 ProcessBuilder。它很有用,因为我刚刚发现我需要能够更改某些文件的采样率。另外,如果我不需要转换任何文件的采样率,我就会选择 WavFile 类 由 Andrew Greensted 博士创建。即使它没有很好的记录,研究它确实帮助我理解 wav 文件规范并查看字节顺序和按位函数。它缺乏转换采样率的能力,这是一个复杂的过程,所以我不得不放弃它。
For future referece, I'm going to use SoX to do the trimming, and I'm going to use it through Java's ProcessBuilder. It's useful, because I just found out I need to be able to change the sample rate of some of the files. Also, if I didn't have to convert the sample rates of any of the files, I would've just gone with a WavFile class created by Dr. Andrew Greensted. Even if it isn't that well documented, studying it really helped me understand the wav file specification and review endianness and bitwise functions. It lacked the ability to convert sample rates, which is a complex process, so I had to drop it.