length of wav files
Erik de Castro Lopo
erikd at zip.com.au
Wed Dec 20 02:01:32 EST 2000
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.
Erik
--
+-------------------------------------------------+
Erik de Castro Lopo erikd at zip.com.au
+-------------------------------------------------+
"I love deadlines. I especially like the whooshing sound
they make as they go flying by." -- Douglas Adams
More information about the Python-list
mailing list