从 AVAudioRecorder 录制的音频中去除静音
我正在开发一个允许用户录制一些音频的 iOS 应用程序。音频使用 AVAudioRecorder 录制,然后保存到文件中。
我想去除录制音频开头和结尾的静音。
有什么想法吗?
I'm working on an iOS app that allows a user to record some audio. The audio is recorded using AVAudioRecorder then saved to a file.
I'd like to strip the silence from the beginning and the end of the recorded audio.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我目前没有从事类似的任务。无论如何,这都不是小事。因为沉默不会是一条简单的零线。会有一些波动。
如果保证获得干净的信号,那么在第一个样本上设置绝对值大于 0.001 的标记将是相当简单的。
您可以设置结束标记,而无需向后浏览文件。您所做的就是,每个大于此阈值的样本,您将结束标记设置为该样本。
如果您的输入在正常启动之前可能包含 blips 和 squips,则您将需要更高级的技术。在下面发表评论,我将扩展答案。
I am currently working no a similar task. It isn't trivial by any means. Because silence is not going to be a straightforward line of zeros. there is going to be some fluctuation.
If you're guaranteed a clean signal, it would be fairly trivial to set a marker on the first sample with an absolute value greater than say 0.001.
You can set an end marker without having to walk backwards through the file. all you do is, every sample greater than this threshold, you set the end marker to this sample.
If your input has the possibility of containing blips and squips before it starts properly, you will need a more advanced technique. Post a comment below and I will extend the answer.
当我为 iOS 构建音频应用程序时,音频最终会出现在服务器上。我不知道你的应用程序在这方面是否相似。如果是这样,你可以像我一样:
使用 SoX 在后端对音频进行后处理,使用阈值消除静音。
如果你需要在电话上完成这一切,那就更难了。您应该使用 OpenAL 或 OpenAL 包装库
When I've built audio apps for iOS, the audio eventually ends up on a server. I don't know if your app is similar in that regard. If so, you can do what I did:
use SoX in the backend to post-process the audio, removing silence using a threshold.
If you need to do it all on the phone, it going to be harder. You should build a power level filter using OpenAL or an OpenAL wrapper library