Python:将WAV文件写入numpy浮点数组 [英] Python: write a wav file into numpy float array
本文介绍了Python:将WAV文件写入numpy浮点数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ifile = wave.open("input.wav")
我现在如何将该文件写入numpy浮点数组?
how can I write this file into a numpy float array now?
推荐答案
>>> from scipy.io.wavfile import read
>>> a = read("adios.wav")
>>> numpy.array(a[1],dtype=float)
array([ 128., 128., 128., ..., 128., 128., 128.])
通常是字节,然后是整数...这里我们只是将其转换为浮点型
typically it would be bytes which are then ints... here we just convert it to float type
您可以在此处阅读有关的内容 https://docs.scipy.org/doc/scipy/reference/tutorial/io.html#module-scipy.io.wavfile
you can read about read here https://docs.scipy.org/doc/scipy/reference/tutorial/io.html#module-scipy.io.wavfile
这篇关于Python:将WAV文件写入numpy浮点数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文