使用 .NET Framework 捕获麦克风音频流
- 作者: 长长de我
- 来源: 51数据库
- 2022-12-15
问题描述
我需要从我的应用程序中的麦克风捕获输入流,该应用程序是用 VB.NET 编写的.我需要能够将此数据流式传输到文件或通过 HTTP 并可能使用 LAME MP3 对其进行编码.有人可以帮我开始吗?
I need to capture the input stream from a microphone in my application, which is written in VB.NET. I need to be able to stream this data to a file or over HTTP and possibly encode it using LAME MP3. Can anybody help me get started with this?
谢谢!
推荐答案
如果你想要一个 .NET 解决方案,你可以查看 NAudio 这是一个开源音频库.查看WaveInStream 类(或最新代码中的WaveIn).这将让您打开麦克风,并接收包含最新捕获字节的事件.这将很容易传递给流.
If you want a .NET solution, you can check out NAudio which is an open source audio library. Look at the WaveInStream class (or WaveIn in the latest code). This will let you open a microphone, and receive events containing the latest captured bytes. This would be quite easy then to pass on to a stream.
至于使用 LAME 编码 MP3,我见过的一种方法是通过 stdin 将音频传递给 lame.exe,然后从 stdout 读取 mp3.我认为这比获取 LAME DLL 并为其编写互操作包装更容易.
As for encoding MP3 using LAME, one approach I have seen used is to pass the audio to lame.exe via stdin and read the mp3 from stdout. This is I think easier than getting hold of a LAME DLL and writing interop wrappers for it.
更新:我创建了一个示例项目,该项目使用 NAudio 从麦克风录音,并在 http://voicerecorder.codeplex.com.请参阅我在 Coding4Fun 上的文章此处.
Update: I have created an example project that uses NAudio to record from the microphone, and LAME to save as MP3 at http://voicerecorder.codeplex.com. See my article at Coding4Fun here.
- C#通过fleck实现wss协议的WebSocket多人Web实时聊天(附源码)
- 团队城市未满足要求:MSBuildTools12.0_x86_Path 存在
- 使用 MSBuild.exe 在发布模式下构建 C# 解决方案
- 当我发布 Web 应用程序时,AfterPublish 脚本不运行
- 构建时 T4 转换的产品仅在下一个构建中使用
- ASP.NET Core Application (.NET Framework) for Windows x64 only error in project.assets.json
- 新的 .csproj 格式 - 如何将整个目录指定为“链接文件"到子目录?
- 如何将条件编译符号(DefineConstants)传递给 msbuild
- MSBuild 支持 Visual Studio 2017 RTM 中的 T4 模板
- NuGet 包还原找不到包,没有源
