length of wav files

Bob van der Poel bvdpoel at uniserve.com
Wed Dec 20 11:51:47 EST 2000


Erik de Castro Lopo wrote:
> 
> Bob van der Poel wrote:
> >
> >
> > I am looking at the docs for the wave library and can't seem to find the
> > one bit of information I want to extract: the running time of a wav
> > file. So, before I have to relearn my math, has someone some code which
> > will deterime the time in seconds of a wav sound file?
> 
> import wave
> 
> wfile = wave.open ("somefile.wav", "r")
> time = (1.0 * wfile.getnframes ()) / wfile.getframerate ()
> 
> The `1.0' above to to force the calculation to use floating point
> arithmetic.

Many thanks. Missed the framerate() stuff.

-- 
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bvdpoel at uniserve.com
WWW:   http://users.uniserve.com/~bvdpoel




More information about the Python-list mailing list