I’m trying to recreate a fast fourier transform of some audio data (copied from this tutorial: https://makersportal.com/blog/2018/9/20/audio-processing-in-python-part-iii-guitar-string-theory-and-frequency-analysis) in order to analyze the frequency of the audio in a WAV file. The problem is that the example uses pyaudio, which I haven’t figured out how to install. It also seems that you need windows to install it, and I would like to use a platform agnostic alternative like simpleaudio.
The example creates an input stream like so:
stream = audio.open(format = form_1,rate = samp_rate,channels = chans, input_device_index = dev_index,input = True, frames_per_buffer=chunk)
And opens the stream to record audio and process the data:
stream.start_stream() data = np.fromstring(stream.read(chunk),dtype=np.int16)
I tried to look up the stream.read() documentation (https://people.csail.mit.edu/hubert/pyaudio/docs/#pyaudio.Stream) but it wasn’t very informative. What I can tell it reads an audio sample from the stream and converts the output to a string, which can then be read into a numpy array. What does this string output look like, and is there a way to do this with simpleaudio or another platform agnostic library? Ideally I would like to have the option of doing this using an input audio stream in real time, and also converting an mp3 or WAV file to the desired output for this audio processing.
Any help would be much appreciated.