Skip to content

Instantly share code, notes, and snippets.

Created April 13, 2013 18:00
Show Gist options
  • Select an option

  • Save anonymous/5379406 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/5379406 to your computer and use it in GitHub Desktop.
test
# wave_test.py
import wave
filename = "snipped.wav"
# py3
#with wave.open(filename, 'r') as f:
# frate = f.getframerate()
# nframes = f.getnframes()
# print(frate, nframes)
f = open('snipped_info')
clean = lambda i: i.replace('\n', '').split('\t')[:2]
sample_markers = [clean(i) for i in f.readlines()]
f.close()
print(sample_markers)
mark_start, mark_end = sample_markers[0]
#print(mark_start)
#print(mark_end)
# py2
f = wave.open(filename)
frate = f.getframerate()
nframes = f.getnframes()
duration_seconds = float(nframes)/float(frate)
print(frate, nframes, duration_seconds)
wpos = f.tell()
print(wpos)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment