Wei1234c
I use the code below and it seems fine. data = stream.read(CHUNK) data_np = np.fromstring(data, np.int16) <=== matching "FORMAT = pyaudio.paInt16"
#4 · closed · 3 comments
I use the code below and it seems fine. data = stream.read(CHUNK) data_np = np.fromstring(data, np.int16) <=== matching "FORMAT = pyaudio.paInt16"
What's the issue?
If the issue is that the data is not going in the array, then try the following - ``` Python 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 ```
Thanks !