Converting chunk to numpy array
Wei1234c opened this issue · 3 comments
Wei1234c commented
I use the code below and it seems fine.
data = stream.read(CHUNK)
data_np = np.fromstring(data, np.int16) <=== matching "FORMAT = pyaudio.paInt16"
rudrathegreat commented
What's the issue?
rudrathegreat commented
If the issue is that the data is not going in the array, then try the following -
data = stream.read(CHUNK) # Binary Data
data_int = struct.unpack(str(2 * CHUNK) + 'B', data) # Integer Data
data_np = np.array(data_int, dtype='b')[::2] + 128 # Data in Array
Wei1234c commented
Thanks !