signal processing for audio file in python
Question
I am tying to do silence detection in uncompressed AIFF audio files. I prefer to do it in Python, but would consider other options if this is super inefficient. The uncompressed files I am dealing with are expected to be 20 MB (maximum size).
I can understand basics of signal processing, but am not an expert in it.
Solution
You're in luck! The aifc library seems to do enough to support the solving of your problem.
OTHER TIPS
Language-agnostic pseudo code:
- for each time window (e.g. 10 ms)
- calculate RMS power in time window
- silence = RMS power < silence threshold
To calculate RMS power:
- sum_sq = 0
- for each sample in N sample window
- sum_sq += sample^2
- RMS power = sqrt(sum_sq / N)
You probably also want to add a further layer of detection, e.g. decide that silence = M consecutive silent windows, where M determines how long a silence needs to be before it counts as an actual silence.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow