Skip to content

Instantly share code, notes, and snippets.

@talesa
Created February 1, 2020 09:17
Show Gist options
  • Save talesa/f626cc8956a42dbc779c195571e02109 to your computer and use it in GitHub Desktop.
Save talesa/f626cc8956a42dbc779c195571e02109 to your computer and use it in GitHub Desktop.
average_bitrate.py
import audioread as ar
import os
rootdir = '.'
audio_file_formats = ['wav', 'mp3', 'm4a']
for root, subdirs, files in os.walk(rootdir):
for filename in files:
if filename[-3:] in audio_file_formats:
filepath = os.path.join(root, filename)
size = os.stat(filepath).st_size
with ar.audio_open(filepath) as f:
bitrate = round(size*8./1024./f.duration)
if bitrate < 200:
print(f'{bitrate} {filepath}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment