what i need to do is to record a short audio of 2 seconds. my approach is to record 3 seconds and crop two seconds from it.
for now i managed to achieve this by using a while loop and calculate the average of every 2sec ranges possible. as the rate is 40100 and the original length is 3 of that, this takes a long time to finish.
i = 0
while i < len(channel_1) - (2 * rate):
avgs.append(get_average(channel_1[i:i + (2 * rate)]))
i += 10
max_int = np.argmax(avgs) * 10
new_audio = audio[max_int:max_int + (2 * rate)]
is there anyway how i can do this faster and more effectively than this.