Created
December 22, 2019 14:11
-
-
Save piraka9011/e333325fc630f92b2808a16777e538b8 to your computer and use it in GitHub Desktop.
Check if file can be read with python wave module
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 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