上一话题

pipes — Shell 管道接口

下一话题
就业培训     下载中心     Wiki     联络
登录   注册

Log
  1. 首页
  2. Python 3.12.4
  3. 索引
  4. 模块
  5. 下一
  6. 上一
  7. Python 标准库
  8. 被取代模块
  9. sndhdr — 确定声音文件类型

sndhdr — 确定声音文件类型 ¶

源代码: Lib/sndhdr.py

Deprecated since version 3.11, will be removed in version 3.13: The sndhdr 模块被弃用 (见 PEP 594 for details and alternatives).


The sndhdr provides utility functions which attempt to determine the type of sound data which is in a file. When these functions are able to determine what type of sound data is stored in a file, they return a namedtuple() , containing five attributes: ( filetype , framerate , nchannels , nframes , sampwidth ). The value for type indicates the data type and will be one of the strings 'aifc' , 'aiff' , 'au' , 'hcom' , 'sndr' , 'sndt' , 'voc' , 'wav' , '8svx' , 'sb' , 'ub' ,或 'ul' 。 sampling_rate will be either the actual value or 0 if unknown or difficult to decode. Similarly, channels will be either the number of channels or 0 if it cannot be determined or if the value is difficult to decode. The value for frames will be either the number of frames or -1 . The last item in the tuple, bits_per_sample , will either be the sample size in bits or 'A' for A-LAW or 'U' for u-LAW.

sndhdr. what ( filename ) ¶

Determines the type of sound data stored in the file filename 使用 whathdr() . If it succeeds, returns a namedtuple as described above, otherwise None 被返回。

3.5 版改变: 将结果从元组更改为命名元组。

sndhdr. whathdr ( filename ) ¶

Determines the type of sound data stored in a file based on the file header. The name of the file is given by filename . This function returns a namedtuple as described above on success, or None .

3.5 版改变: 将结果从元组更改为命名元组。

The following sound header types are recognized, as listed below with the return value from whathdr() :和 what() :

值

Sound header format

'aifc'

Compressed Audio Interchange Files

'aiff'

Audio Interchange Files

'au'

Au Files

'hcom'

HCOM Files

'sndt'

Sndtool Sound Files

'voc'

Creative Labs Audio Files

'wav'

Waveform Audio File Format Files

'8svx'

8-Bit Sampled Voice Files

'sb'

Signed Byte Audio Data Files

'ub'

UB Files

'ul'

uLAW Audio Files
sndhdr. tests ¶

A list of functions performing the individual tests. Each function takes two arguments: the byte-stream and an open file-like object. When what() is called with a byte-stream, the file-like object will be None .

The test function should return a string describing the image type if the test succeeded, or None if it failed.

范例:

>>> import sndhdr
>>> imghdr.what('bass.wav')
'wav'
>>> imghdr.whathdr('bass.wav')
'wav'
										

上一话题

pipes — Shell 管道接口

下一话题

spwd — 影子口令数据库

本页

  • 报告 Bug
  • 展示源

快速搜索

键入搜索术语或模块、类、函数名称。

  1. 首页
  2. Python 3.12.4
  3. 索引
  4. 模块
  5. 下一
  6. 上一
  7. Python 标准库
  8. 被取代模块
  9. sndhdr — 确定声音文件类型

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1