Last active
December 11, 2015 03:49
-
-
Save kosugi/4540903 to your computer and use it in GitHub Desktop.
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
| # -*- coding: utf-8 -*- | |
| from struct import unpack | |
| def do(f): | |
| (tag1, size, tag2) = unpack('<4sI4s', f.read(12)) | |
| if not (tag1 == 'RIFF' and tag2 == 'WAVE'): | |
| print 'not wave file.' | |
| return | |
| eof = size + 8 | |
| while f.tell() < eof: | |
| (tag, size) = unpack('<4sI', f.read(8)) | |
| print '%s\t%d' % (tag, size) | |
| f.read(size) | |
| if __name__ == '__main__': | |
| import sys | |
| do(sys.stdin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment