I am trying to sort through a bunch of audio samples where some of them are fully blank. Can someone help me figure out the best way to detect if a file is blank (silent) for its duration? I've found a bunch of ways of reading wav files, but thus far nothing on how to determine if a file is blank.
The code I have thus far:
import soundfile as sf
path = '/Users/InNov8/Desktop/Elektron_Octotrack_Chain_Maker_v2/Bar 25 -- High 303/'
file1 = 'Bar 25 --- [tr] --- 4-Kick 2.aif' # blank
file2 = 'Bar 25 --- [tr] --- 10 Shaker.aif' # not blank
file3 = 'Bar 25 --- [tr] --- 14 HARD SNARE.aif' # blank
f1 = path + file1
x, fs = sf.read(f1)
print x
print fs
f2 = path + file2
x, fs = sf.read(f2)
print x
print fs
If I understand correctly, you have bunch of audio files and some of them are below a certain threshold that are causing issue. If you are open to using external libraries, you can use pydub to detect if given
audio_segment
is above/below given threshold.First of all , you can install
pydub
on windows usingNext you can load audio file (example is for
wav
, but you can find methods to load other types of files in the link).Per website:
Load file and find out its loudness
You can load multiple files and compare loudness as above.
Alternately, if you are looking for loudness for certain portion of a file, then you will need to split audio segment in chunks and then check loudness for each chunk. Again, you can find details on the site.