signal processing for audio file in python
Pergunta
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.
Solução
You're in luck! The aifc library seems to do enough to support the solving of your problem.
Outras dicas
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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow