Skip to content

Instantly share code, notes, and snippets.

@piraka9011
Created December 22, 2019 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piraka9011/e333325fc630f92b2808a16777e538b8 to your computer and use it in GitHub Desktop.
Save piraka9011/e333325fc630f92b2808a16777e538b8 to your computer and use it in GitHub Desktop.
Check if file can be read with python wave module
import os
import wave
if __name__ == '__main__':
directory = '/Users/allabana/tarteel_ws/tarteel-recordings/media'
(_, _, filenames) = next(os.walk(directory))
bad_files = []
for filename in filenames:
wave_filename = os.path.join(directory, filename)
try:
with wave.open(wave_filename, 'r') as file:
print("Parameters: ", file.getparams())
except wave.Error as e:
bad_file_tuple = (filename, e)
bad_files.append(bad_file_tuple)
print("Found {} bad files".format(len(bad_files)))
print(bad_files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment