本文整理匯總了Python中sunau.AUDIO_FILE_ENCODING_MULAW_8屬性的典型用法代碼示例。如果您正苦於以下問題:Python sunau.AUDIO_FILE_ENCODING_MULAW_8屬性的具體用法?Python sunau.AUDIO_FILE_ENCODING_MULAW_8怎麽用?Python sunau.AUDIO_FILE_ENCODING_MULAW_8使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類sunau
的用法示例。
在下文中一共展示了sunau.AUDIO_FILE_ENCODING_MULAW_8屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: read_sound_file
# 需要導入模塊: import sunau [as 別名]
# 或者: from sunau import AUDIO_FILE_ENCODING_MULAW_8 [as 別名]
def read_sound_file(path):
with open(path, 'rb') as fp:
au = sunau.open(fp)
rate = au.getframerate()
nchannels = au.getnchannels()
encoding = au._encoding
fp.seek(0)
data = fp.read()
if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
raise RuntimeError("Expect .au file with 8-bit mu-law samples")
# Convert the data to 16-bit signed.
data = audioop.ulaw2lin(data, 2)
return (data, rate, 16, nchannels)