# Record and playback has echo/feedback

I didn't mess around with the code here, it was straight from their website, I just want to see if it would work. However, whenever I run it, it has feedback in it, sometimes I can't hear anything at all. It is not the speaker because I can record and play things separately. Here is the code if you want.

I tried changing the frames per buffer to 5000 and it lost the feedback and started an echo. I also tried to have it record and then play back later, but it said that the input had overloaded.

NEW DEVELOPMENT: the feedback is the echo, for some reason when the frames per buffer or the CHUNK is decently high, there is an echo, when it is like the code below, the echo compounds and speeds up to result in feedback, multiple echos playing at once to become a high shrill noise.

import pyaudio

CHUNK = 1024
WIDTH = 2
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 5

p = pyaudio.PyAudio()

stream = p.open(format=p.get_format_from_width(WIDTH),
channels=CHANNELS,
rate=RATE,
input=True,
output=True,
frames_per_buffer=CHUNK)

print("* recording")

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

print("* done")

stream.stop_stream()
stream.close()

p.terminate()