Generation

generate functionSun, 13 Nov 2022

perform fast fourier transform and output the frequency with the highest magnitude

def freq_from_fft(raw_signal, sampling_rate): signal = np.array(raw_signal, dtype=np.float32) signal_fft = np.fft.rfft(signal) signal_fft = np.abs(signal_fft) freqs = np.fft.rfftfreq(signal.size, 1/sampling_rate) max_freq_index = np.argmax(signal_fft) freq = freqs[max_freq_index] return freq

Want to kickstart your project?Use the new AI Studio to create your code