问题
I want get the details of the wave such as its frames into a array of integers. Using fname.getframes we can ge the properties of the frame and save in list or anything for writing into another wav or anything,but fname.getframes gives information not in integers some thing like a "/xt/x4/0w' etc..
But i want them in integer so that would be helpful for manupation and smoothening join of 2 wav files
回答1:
I don't know what library you're using, but it looks like it's probably returning a string of bytes. To get it into a list of integers, you could do something like this:
data = [ord(character) for character in data]
To convert it back, you could do something like this:
data = ''.join(chr(character) for character in data)
回答2:
If you need to convert the frame data into integers, you can create an array.array('h') (array of signed 16-bit words) and load it from the frame data using its .fromstring or .fromfile methods.
However, I'm almost sure that you can keep the frame data as they are, and manipulate them using functions in the audioop module.
回答3:
NumPy can load the data into arrays for easy manipulation. Or SciPy. I forget which.
来源:https://stackoverflow.com/questions/3021046/wav-file-manupalation