What are Chunks when recording a voice signal I am having trouble understanding the example program for audio recording , 
it comes with PyAudio module.

I am using an external Audio Card to record the sound , obviously, the voice should be converted into the digital form to be presented to the computer. But i do not understand how this code converts the input Analog Voice into Digital Form and then saving it.

Here is the code,

import pyaudio
import wave
import sys

CHUNK = 1024
# What is CHUNKS here ?
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "test.wav"

p = pyaudio.PyAudio()

stream = p.open(format=FORMAT,
                channels=CHANNELS,
                rate=RATE,
                input=True,
                frames_per_buffer=CHUNK)
print("start....")

frames = []

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
    data = stream.read(CHUNK)
    frames.append(data)

print("done...")


stream.stop_stream()
stream.close()
p.terminate()

wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()


When the code is executed it record the sounds for 5seconds using an external audio card with a mic.

What I understood from the code is,

The Rate is 44Kbps, which means that 44 kilo bytes are generated from the Analog Audio signals per second.

Then an empty frame is generated frame[] where all the recorded data will be stored.

The next thing is for loop,

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
    data = stream.read(CHUNK)


the answer to RATE/CHUNK*RECORD_SECONDS is 215.33 which means there will be 215 iterations.

I don't understand why the RATE is divided by CHUNKS and then multiplied by RECORD_SECONDS for the recording of 5 seconds. (RECORD_SECONDS = 5)

Also, What exactly is CHUNK ?
So essentially, @porten pointed out what chunks of sound are. 

Let's look at your code:

CHUNK = 1024
# What is CHUNKS here ?


The chunk is like a buffer, so therefore each buffer will contain 1024 samples, which you can then either keep or throw away. We use CHUNKS of data, instead of a continuous amount of audio because of processing power. (Let's assume this was a continuous flow of data being received from a Microphone and is being recorded and saved) then it would just eat up the processor, thus causing potential crashes. In terms of Raspberry Pi / Arduino development (Where the RAM is very small) CHUNKING the data like this makes the stream flow easier and thus prevents memory leaks. 

Another reason:

Let's assume that you wanted to implement an algorithm for determining whether something is speech, or, is just noise. How would/could you do this using a constant stream flow of sound data? It would be very difficult. Therefore, by storing this into an array (or list in your case) you can perform analysis on this data, for example RMS. Then you could have some threshold to determine if you want to keep the data, or the data is no good. E.g. 

CHUNK = 1024

var input[CHUNK] = readAudio(CHUNK); // reads in 1024 of data

// compute RMS 
a = RMS(input); 
if(a &gt;= THRES_VALUE)
{ 
    actual += input;
}


So in this example above, we record 1024 bytes of data, we then compute RMS and check to see whether or not the sound is speech or just white-noise. 

To confirm as well, the chunks contain the data.