使用Python来测量音频的“响度". [英] Using Python to measure audio "loudness"

查看:1020
本文介绍了使用Python来测量音频的“响度".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找使用Python计算音频片段的响度的方法-可能是通过提取音频片段的峰值音量,或者可能使用更精确的度量(RMS?).

I'm looking to calculate the loudness of a piece of audio using Python — probably by extracting the peak volume of a piece of audio, or possibly using a more accurate measure (RMS?).

执行此操作的最佳方法是什么?我看过 pyaudio ,但是那似乎没做什么我想了.看起来不错的是 ruby​​-audio ,因为它似乎已经构建了sound.abs.max进去.

What's the best way to do this? I've had a look at pyaudio, but that didn't seem to do what I wanted. What looked good was ruby-audio, as this seemingly has sound.abs.max built into it.

输入音频将从各种持续时间大约为30s的本地MP3文件中获取.

The input audio will be taken from various local MP3 files that are around 30s in duration.

推荐答案

我认为RMS将是最准确的度量.需要注意的一件事是,我们在不同的频率上对响度的理解不同,因此请以fft将音频转换为频率空间(numpy.fft应该仅在30s的音频上工作良好).现在从中计算出功率谱密度.使用一些响度曲线按频率对PSD加权.尤其是低于10Hz的频率,因为那里会有很多功率(它将在时域中主导RMS计算),但我们听不到.现在,对PSD进行积分并取平方根,这将得出可靠的RMS.

I think that the RMS would be the the most accurate measure. One thing to note is that we percieve loudness differently at different frequencies, so convert the audio to frequency space with an fft (numpy.fft should work great on only 30s of audio). Now compute a power spectral density from this. Weight the PSD by frequency using some loudness curve. Especially frequencies below 10Hz, since there will be a lot of power there (it would dominate the RMS calculation in the time-domain), yet we can't hear it. Now integrate the PSD and take the square root and that will give a percieved RMS.

您还可以将mp3分成多个部分或窗口,并应用此技术在特定部分中提供音量.

You can also break the mp3 into sections or windows and apply this technique to give the volume in particular sections.

这篇关于使用Python来测量音频的“响度".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆