有谁知道如何修改“在这里说话”示例代码来录制流音频?

发布于 2024-09-15 07:23:46 字数 330 浏览 1 评论 0原文

有谁知道如何修改Apple的代码在这里说话。我需要修改它以使用 Matt Gallagher 录制流音频AudioStreamer 类,但不知何故我找不到如何选择录音源...

你能帮忙吗?

Does anyone know how to modify the code Speak Here from Apple. I need to modify it to record streaming audio using Matt Gallagher AudioStreamer classes but somehow I can't find how to select the recording source...

Could you help?

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

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

发布评论

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

评论(1

面犯桃花 2024-09-22 07:23:46

我还没有这样做,但我已经使用过 Matt 的 AudioStreamer 类相当多了,这​​确实是您想要扩展的项目 - 而不是 SpeakHere。 (流音频部分是其中最复杂的部分)。

您要做的就是首先设置要写入的文件,然后在 AudioStreamer.m 中有两个位置将网络数据缓冲区复制到音频队列缓冲区 - 两者都用此 // 将数据复制到音频队列缓冲区进行注释。在这些行之后添加写入文件的逻辑(使用 AudioFileWritePackets)。我猜想文件写入速度足够快,可以立即在此处执行此操作。如果没有(如果音频播放跳过或中断),那么您需要为文件写入设置一个循环缓冲区,复制字节并从后台线程调用 AudioFileWritePackets。

I haven't done this but I have used Matt's AudioStreamer class quite a bit and that's really project you want to extend - not SpeakHere. (The streaming audio part is the most complex part of this).

What you would do is first setup your file for writing and then in AudioStreamer.m there are two places where the network data buffer is copied to the audio queue buffer - both are noted with this // copy data to the audio queue buffer. After those lines add the logic to write to the file (using AudioFileWritePackets). I would guess that the file write is fast enough to do this right here, immediately. If not (if the audio playback skips or breaks up) then you'd want to set up a circular buffer for file writing, copy the bytes and call the AudioFileWritePackets from a background thread.

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