If you are a spy or work for the CIA or the FBI, this will come in handy in your knowledge. Given the size and price of the Raspberry Pi, it occurred to me that using it as a spying device (which are actually really expensive) would be really appropriate.
In this case, I’ll explain how to convert your Raspberry Pi into an audio streaming device, or audio spying device, however suits best to you. Use it under your own responsibility.
Plugging the microphone and loading the module
The Raspberry Pi has an audio output jack, but unfortunately there is no input port. We will then need a USB microphone. If you have one, keep reading, if not, go buy one 😉 (or plug a webcam with microphone).
Once the microphone is plugged in, you might have to load the audio module by typing the following command if it isn’t.
sudo modprobe snd_bcm2835
Recording and playing a test file
Now we can try to record some audio into a file by running:
arecord -D plughw:1,0 test.wav
Just press CTRL+C once you think you’ve got enough recording. Now let’s play it to see if it works! But first, plug your earphones to the audio output of your Raspberry Pi!
Did you hear anything? Great! Your Raspberry is ready to “rock”ord some audio!
If you want to record louder or adjust some parameter, you can use the alsamixer tool to play with the input/output levels of your microphone.
Once you have set your settings, remember to store your changes:
sudo alsactl store
Streaming the audio to another PC
What we want to do next, is to give the Pi the capability to send this audio through the network, maybe to a server we have somewhere. In order to tho that, we will pipe the audio from the microphone into an ssh communication to the destination computer. As simple as:
arecord -D plughw:1,0 -f dat | ssh -C user@remoteip aplay -f dat
Now you have everything set! Switch on your speakers in the destination PC, and hear what the Raspberry Pi is spying from hundreds of miles!
In this (two overlapped and faded) pictures you can see my Raspberry Pi set under a bed, using a Wifi dongle, set to work as a baby-cry transmitter.
This might be useful in some situations ^^