Hello, I hope the session is right.
I need to acquire a sound through a USB microphone, capture the sound for 5 seconds and save the hex stream in a vector. At the end of the 3 seconds, filling a new carrier for another 5 seconds, during this acquisition, the previous carrier will be shot in UDP to the server that will save this information.
The cycle should continue for a total time of 10 minutes.
The python that captures the audio is:
form_1 = pyaudio.paInt16
chans = 1
samp_rate = 44100
chunk = 4096
record_secs = 10
dev_index = 2
wav_output_filename = 'test.wav'
file = open("test.txt","wb")
audio = pyaudio.PyAudio()
stream = audio.open(format = form_1, rate = samp_rate, channels = chans, \
input_device_index = dev_index, input = True, \
frames = 
for ii in range(0,int((samp_rate/chunk)*(record_secs/10))):
data = stream.read(chunk)
wavefile = wave.open(wav_output_filename,'wb')
I thought of nesting inside the sky
who were the counter
I need to acquire a sound through a USB microphone, capture the sound for 5 seconds and save the hex stream in a vector.
You can completely forget doing this exactly as stated.
You will NOT be using a collector that can change size.
So, you need to start with defining a collector, usually an array, of the maximum size needed. What IS that maximum size, and what type should the collector be, and does your Arduino have enough room to have two of them?
You seem to think that you will be able to send a UDP packet containing all that data, in the time between two samples, so you don't miss a sample. Do you REALLY believe that that is possible? I certainly do not.