Created
February 1, 2020 09:17
-
-
Save talesa/f626cc8956a42dbc779c195571e02109 to your computer and use it in GitHub Desktop.
average_bitrate.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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