Sunday, August 25, 2013

Transmit Voice From Microphone

I copied this from a post on the Raspberry Pi forums found here.

I figured out how to broadcast your voice through the radio using the raspberry pi, i.e. speak through a mic and tune your radio to a frequency to hear it, in real time!

It's actually quite simple.
First, follow the instructions here to get the FM transmitter setup on your raspberry pi. This transmits .wav files through a specified frequency and requires no extra hardware besides an optional antenna! These guys that did this are brilliant, and it's open source! (This link is a cached version because the original site is down).
http://webcache.googleusercontent.com/search?q=cache:2sSuOAJQhN4J:www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter+raspberry+pi+fm+transmitter&cd=1&hl=en&ct=clnk&gl=us

Second, you need the ALSA sound library installed which most of you should already have this. The executable out of this we will use is 'arecord'.

Plug in your mic and attach an antenna to GPIO4 if desired. 

Then here is the command you will use to start the broadcast. Each piece will be explained. Note that this command may need modified to work for your mic, just keep reading.
CODE: SELECT ALL
arecord -fS16_LE -r 22050 -Dplughw:1,0 - | sudo ./pifm - 100.1 22050


Alright so:
CODE: SELECT ALL
arecord

Program we are using to record audio.
---------------------------------------------------------

CODE: SELECT ALL
-fS16_LE

Output 16-bit data. Needed this way for PiFM to read it.
---------------------------------------------------------

CODE: SELECT ALL
-r 22050

This specifies sampling rate to output recording. 22,050 is a good balance for speed and quality.
---------------------------------------------------------

CODE: SELECT ALL
-Dplughw:1,0

This is where you may need to modify. The '1' specifies card number and '0' is the device number I think. To find this out for your device, use
CODE: SELECT ALL
arecord -l
to see all of the audio devices connected.
---------------------------------------------------------

CODE: SELECT ALL
-

Here it means to print output to standard out.
---------------------------------------------------------

CODE: SELECT ALL
|

Pipe the standard out from previous command to next command's standard input.
---------------------------------------------------------

CODE: SELECT ALL
sudo ./pifm - 100.1 22050

This is explained in the link at the top. '-' means use standard input for "file"(Remember we piped it). '100.1' is the frequency in Mhz to transmit and '22050' is the sampling rate of the input. Actually if you change the sampling rate lower it will output a low pitch sound and higher will do a high pitch sound, kind of a voice changer.

If you did everything right, after you run the command you should be able to tune your radio to 100.1 Mhz and hear yourself talking through the mic!

Good luck! And don't amplify your signal or you could risk getting a fine from the FCC or whatever the agency is for your country!

4 comments:

  1. Is the signal produced over a 20cm cable still in the legal limit in the US? If not, how do you change the strength?

    ReplyDelete
  2. Voice Dial Connect is the premier voice broadcasting dialer platform that will transform your call center into a sales revenue machine, steadily providing voice broadcasting leads. We love political voice broadcasting and getting the word out on candidates so give voice dial connect a call.

    Voice Broadcasting
    Voice Broadcasting Leads
    Voice Broadcasting Software

    ReplyDelete
  3. Does it support all microphones

    ReplyDelete
  4. Thank you so much great thorough review and the selections in this one! hyperx quadcast amazon

    ReplyDelete