I have IR sensor which have TRS connector and I can record my remotes signals into audio. Now I want to control my computer with TV remote, but I don't have any clue how to compare audio input with pre-recorded audio. But after I realized that these audio waves contains only some kind data (binary) I can turn these into binary or hex, so it is much easier to compare.
Waves look just like this:
And this:
These are records of "OK" button, sometimes there are some impulses on right channel too and I don't know why, it seems like connections in sensor are damaged maybe. Ok thats not matter, anyway
I need help with python program which read these impulses and turn these into binary, in realtime from audio input(mic). I know it's sounds like "Do it for me, while I enjoy my life", but I don't have experiences with sound transforming/reading... I've looking for python examples for recording and reading audio, but unsuccessfully.
The this is quite easy if you can forgo the real time requirement: just save the data as a .wav file, and then read it in using Python's wave module.
Here's an example of how to read a wav file in Python,
import wave
w = wave.open("myfile.wav", "rb")
binary_data = w.readframes(w.getnframes())
w.close()
It's possible to do this in real time, but it's harder, though still not super difficult. For real time, I use PyAudio, and a good start would be to follow the examples in the demos. In these you basically open a stream and read small chunks at a time, and if you want any interactivity, you need to do this in a thread.
(Also, note, that the sound card will filter your audio inputs, so what you see isn't going to be the true input signal. In particular, I think remote controls often have a carrier frequency around 40KHz, which is higher than human hearing, so I doubt that sound cards work well in this range, though they may be sufficient depending on what you want to do.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With