KBNLresearch / iromlab

Loader software for automated imaging of optical media with Nimbie disc robot
Apache License 2.0
33 stars 5 forks source link

Verify created audio files for completeness #22

Closed bitsgalore closed 7 years ago

bitsgalore commented 7 years ago

Either use external tool:

http://openpreservation.org/blog/2017/01/04/breaking-waves-and-some-flacs/

Or maybe this (needs testing):

https://docs.python.org/3.6/library/wave.html

Or (supports FLAC!):

http://audiotools.sourceforge.net/

Especially:

http://audiotools.sourceforge.net/programming/audiotools.html#audiotools.AudioFile.verify

Verifies the track for correctness. Returns True if verification is successful. Raises an InvalidFile subclass if some problem is detected. If the file has built-in checksums or other error detection capabilities, this method checks those values to ensure it has not been damaged in some way.

Audiotools installation fail under Windows! Other possibilities (?):

Libav binaries link in Pudub doc is outdated; new link:

http://builds.libav.org/windows/

bitsgalore commented 7 years ago

Update:

Pydub

audioFile = os.path.normpath("E:/detectDamagedAudio/data/frogs-01-last-byte-missing.wav")
audio = AudioSegment.from_file(audioFile, "wave")
print(audio.channels)
print(audio.frame_rate)
print(audio.sample_width*8) # sample width = bit depth in bytes!

This does not result in any error message or warnings, so pydub not suitable for detecting broken audio (results same for FLAC). Pydub could be used for extracting no. of channels, bit depth and sampling rate.

Pysoundfile

Installation: ignore conda instructions on http://pysoundfile.readthedocs.io/en/0.9.0/, and just use pip:

pip install CFFI
pip install NumPy
pip install pysoundfile

Appears to detect broken FLACs but doesn't detect broken WAV files!

bitsgalore commented 7 years ago

Done (using wrapper functions for shntool and flac): https://github.com/KBNLresearch/iromlab/commit/a0e01e20f70c5c79f160caa5843d1dafd1e64e35