pydoc > sndhdr

๐Ÿ“› NAME

sndhdr - Routines to help recognizing sound files.

๐Ÿš€ Quick Reference

Use CaseCommandDescription
๐Ÿ”ฌ Recognize sound headerimport sndhdr; info = sndhdr.whathdr('file.wav')Returns a tuple (type, rate, channels, frames, bits) or None
๐Ÿ” Guess sound typesndhdr.what('file.au')Convenience wrapper around whathdr()
๐Ÿงช Test all files in a directorypython -m sndhdr or sndhdr.test()Runs what() on all files in current directory
๐Ÿ“ Recursive testsndhdr.test('-r')Recurse into subdirectories

๐Ÿ“š MODULE REFERENCE

https://docs.python.org/3.10/library/sndhdr.html

The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.

๐Ÿ“– DESCRIPTION

Function whathdr() recognizes various types of sound file headers. It understands almost all headers that SOX can decode.

The return tuple contains the following items, in this order:

If the file doesn't have a recognizable type, it returns None. If the file can't be opened, OSError is raised.

To compute the total time, divide the number of frames by the sampling rate (a frame contains a sample for each channel).

Function what() calls whathdr(). (It used to also use some heuristics for raw data, but this doesn't work very well.)

Finally, the function test() is a simple main program that calls what() for all files mentioned on the argument list. For directory arguments it calls what() for all files in that directory. Default argument is "." (testing all files in the current directory). The option -r tells it to recurse down directories found inside explicitly given directories.

๐Ÿ”ง FUNCTIONS

๐Ÿ” what(filename)

Guess the type of a sound file.

๐Ÿ”ฌ whathdr(filename)

Recognize sound headers.

๐Ÿ“ฆ DATA

__all__ = ['what', 'whathdr']

๐Ÿ“ FILE

/usr/lib/python3.10/sndhdr.py

sndhdr
๐Ÿ“› NAME ๐Ÿš€ Quick Reference ๐Ÿ“š MODULE REFERENCE ๐Ÿ“– DESCRIPTION ๐Ÿ”ง FUNCTIONS
๐Ÿ” what(filename) ๐Ÿ”ฌ whathdr(filename)
๐Ÿ“ฆ DATA ๐Ÿ“ FILE

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 13:23 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format