如何用iPad录音?
我需要一个在 iPad 上录制语音的好示例或指南。无论我说什么,我都希望能够稍后回放。我该怎么做?
I need a good example or guidelines for recording voice on an iPad. Whatever I say, I want to be able to play back later. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,根本没有例子。这是我的工作代码。用户按下导航栏上的按钮即可触发录制。录音使用 CD 质量(44100 个样本)、立体声(2 通道)线性 PCM。请注意:如果您想使用不同的格式,尤其是编码格式,请确保您完全了解如何设置 AVAudioRecorder 设置(仔细阅读音频类型文档),否则您将永远无法正确初始化它。还有一件事。在代码中,我没有展示如何处理计量数据,但您可以轻松弄清楚。最后,请注意,在撰写本文时,AVAudioRecorder 方法 deleteRecording 会使您的应用程序崩溃。这就是我通过文件管理器删除录制文件的原因。录制完成后,我使用 KVC 将录制的音频保存为当前编辑的对象中的 NSData。
来自这个答案 - 如何使用 AVAudioRecorder 在 iPhone 上录制音频?
Actually, there are no examples at all. Here is my working code. Recording is triggered by the user pressing a button on the navBar. The recording uses cd quality (44100 samples), stereo (2 channels) linear pcm. Beware: if you want to use a different format, especially an encoded one, make sure you fully understand how to set the AVAudioRecorder settings (read carefully the audio types documentation), otherwise you will never be able to initialize it correctly. One more thing. In the code, I am not showing how to handle metering data, but you can figure it out easily. Finally, note that the AVAudioRecorder method deleteRecording as of this writing crashes your application. This is why I am removing the recorded file through the File Manager. When recording is done, I save the recorded audio as NSData in the currently edited object using KVC.
from this answer - How do I record audio on iPhone with AVAudioRecorder?