Closed. This question needs to be more focused。它当前不接受答案。
想改善这个问题吗?更新问题,使其仅关注editing this post的一个问题。
3年前关闭。
Improve this question
我怎么能够:
读取我的音频文件 存储在二进制文件 中
有人可以给我示例在python中实现编码器和解码器吗?
想改善这个问题吗?更新问题,使其仅关注editing this post的一个问题。
3年前关闭。
Improve this question
我怎么能够:
有人可以给我示例在python中实现编码器和解码器吗?
最佳答案
您可以使用scipy.wave读取和写入wav文件。要存储数据,可以使用numpy。
如果音频文件有效地以每个样本16位进行编码,则您无需执行任何操作,这应该类似于:
from scipy.io.wavfile import read as wavread
from scipy.io.wavfile import write as wavwrite
import numpy as np
sr, sig = wavread(audioFileName) #read the audio file (samplig rate, signal)
sig_int8 = np.uint8(sig) # cast the data in uint8
np.savez(out_file, sig = sig_int8) # store the data
npzfile = np.load(out_file + '.npz') #load the data
sig = npzfile['sig']
wavwrite(audioFileName2, sr, sig) #write data in wav file
关于python - python/从wav到bin的编码器和解码器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46791742/