Here is a graph that shows a "control" (blue) and "recorded" (orange) signals.
Both are numpy arrays with 10,756 items, acquired from a .wav
file with the code:
from wave import open as open_wave
waveFile = open_wave(filename,'rb')
nframes = waveFile.getnframes()
wavFrames = waveFile.readframes(nframes)
ys = np.fromstring(wavFrames, dtype=np.int16)
I have 26 control signals (all letters of alphabet), and I'd like to take a recorded wave and figure out which control signal it is most similar too.
My first approach was using scipy.signal.find_peaks()
which works perfectly for control signals, and sometimes for recorded signals, but not good enough. I understand the shortcoming here to be a) possible clipping of signal at beginning/end, or b) noise in the recorded signal can create false peaks.
My second approach was subtracting the recorded array from all controls, hoping the most similar would result in the smallest diff. This didn't work well either (though still interested in this approach...).
What I'm hoping to do now is:
- continue to identify peaks with
scipy.signal.find_peaks()
- get average distance between peaks across signal
- look for a control signal where this average peak distance is similar
Where, of course, "peak distance" is the frequency of the sin wave.
Any suggestions or streamlines appreciated! I realize I'm bumbling into a very rich world of signal processing, using this toy / fun example to dip my toes.