我如何以 8 位 8khz 参数对音频文件(例如 .wav )进行采样

发布于 2024-12-05 02:37:28 字数 130 浏览 5 评论 0原文

我不太擅长编程,我需要对通过手机录制的音频文件进行采样,我知道移动设备记录语音,并且有采样率,每个样本都有 8 位或 16 位样本大小。我需要 8khz 的 8 位样本大小。编程环境是 lua,但这并不重要,基本的事情是采样。任何帮助将不胜感激。

i am not that big on programming and i need to sample an audio file that is recorded via a mobile, i understand that the mobile device records the voice, and there are sample rates and each sample has a 8bit or 16 bit sample size. i need 8 bit sample size in 8khz. the programming environment is lua but that doesnt matter really the basic deal is sampling. Any help would be appreciated.

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

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

发布评论

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

评论(2

装迷糊 2024-12-12 02:37:28

您需要在将声音样本录制为 8 位 @ 8 kHz 时设置录音参数,或者,如果您不能,或者无法控制实际的录音过程,那么您将需要重新采样原始录音,将其转换为您需要的格式。您可以使用 SoX 等工具离线执行此操作,或者您可以编写代码这是即时的。如果您在问题中提供更多详细信息,那么我可以在答案中添加更具体的细节。

You need to either set your recording parameters at the time that you record the sound sample to 8 bits @ 8 kHz, or, if you can't, or don't have any control over the actual recording process, then you will need to resample the original recording to get it into the format that you need. You can do this off-line with a tool such as SoX, or you can write code that does this on-the-fly. If you give more detail in your question then I can add more specific detail in my answer.

海风掠过北极光 2024-12-12 02:37:28

我不了解 lua,但正如 Paul R 所建议的,您始终可以使用 SoX 或 ffmpeg 对音频文件进行后处理。在 Linux 上,只需安装 ffmpeg :

sudo apt-get install ffmpeg

然后:

ffmpeg -i trenet.wav -ar 8000 trenet-8k.wav

这将以 8000 Hz 的频率重新采样您的音频。我没有找到如何处理位/样本参数,但您始终可以调整比特率。对于文档:

man ffmpeg

I don't know about lua, but as suggested by Paul R, you can always post-process your audio files using SoX or ffmpeg. On linux, just install ffmpeg :

sudo apt-get install ffmpeg

Then :

ffmpeg -i trenet.wav -ar 8000 trenet-8k.wav

This resamples your audio at 8000 Hz. I did not find how to deal with the bits/sample parameter but you can always tune the bitrate. For documentation :

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