After going through the documentation of pyaudio and reading some other articles on the web, I am confused if my understanding is correct.
This is the code for audio
sys.getsizeof()
reports the storage space needed by the Python interpreter, which is typically a bit more than the actual size of the raw data.RATE * RECORD_SECONDS
is the number of frames that should be recorded. Since the for
loop is not repeated for each frame but only for each chunk, the number of loops has to be divided by the chunk size CHUNK
. This has nothing to do with samples, so there is no factor of 2
involved.[hex(x) for x in frames[0]]
. If you want to get the actual 2-byte numbers use the format string ' with the struct
module.
You might be interested in my tutorial about reading WAV files with the wave
module, which covers some of your questions in more detail: http://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/audio-files/audio-files-with-wave.ipynb