Skip to content

Instantly share code, notes, and snippets.

@kosugi
Last active December 11, 2015 03:49
Show Gist options
  • Select an option

  • Save kosugi/4540903 to your computer and use it in GitHub Desktop.

Select an option

Save kosugi/4540903 to your computer and use it in GitHub Desktop.
# -*- 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