The sndhdr module

This module can be used to identify different audio file formats, and extract basic information about the file contents.

If successful, the what function returns a 5-tuple, containing the file type, the sampling rate, the number of channels, the number of frames in the file (-1 means unknown), and the number of bits per sample.

Example: Using the sndhdr module
# File: sndhdr-example-1.py

import sndhdr

result = sndhdr.what("samples/sample.wav")

if result:
    print "file format:", result
else:
    print "cannot identify file"

file format: ('wav', 44100, 1, -1, 16)
 

[comment on/vote for this article]

A Django site. this page was rendered by a django application in 0.01s 2008-08-28 02:19:31.771637. hosted by webfaction.