2

I am thinking of doing a project with my Raspberry Pi. I am going to put the Raspberry Pi near my front door and attach a speaker to its audio output. Then I will go to my Mac and say something into the microphone. I was wondering if there is any way to send this live microphone audio to the Raspberry Pi and output the audio.

3
  • It may be simpler to send a text string to your pi and then have the pi speak the text using (festival atext to speech app). see here for how to install it: raspberrypi.stackexchange.com/questions/1015/…. Once that works you may want to tackle the harder problem of streaming audio to the Pi for playback. – Steve Robillard Jun 27 '14 at 21:36
  • 3
    Hopefully you are going to use a powered speaker (amplifyer). The Rpi cannot directly drive a low impedance speaker. – Marla Jun 28 '14 at 14:02
  • you can also try avconv (former ffmeg) and ffserver. i have never used the second one, but i think googling it will yield lots of tutorials. – thekiwi5000 Nov 26 '14 at 23:17
1

I think this is doable you just have to stream the captured audio from your Macbook to the Pi, to do that use arecord and aplay. Using these tools you can stream the audio across a network, so assuming the Pi and Mac are on the same local network this could be quite quick to implement...

The following article is based around using the Pi as a spy tool, but imagine it the other way around, using the Mac as the mic and the Pi as the output - its the same principle and it uses this command to send the audio along the network which looks kinda scary at first but is just piping audio through ssh:

arecord -D plughw:1,0 -f dat | ssh -C user@rpiIPaddress aplay -f dat

See this great post for more...

8
  • so instead of sending from pi to computer I would run the script on my computer and then send it via ssh to the pi? – mihirb Jun 27 '14 at 23:23
  • where it says user@rpiIPadress would I just replace it with the Raspberry Pi's IP address? – mihirb Jun 27 '14 at 23:24
  • So i would access the raspberry pi remotely via ssh and then execute this code? – mihirb Jun 27 '14 at 23:35
  • Yes that's right. Replace with the pi IP address on a local network that will be some thing like 192.168.0.x where x will be another number obviously. There are probably other ways to do what you want namely via radio but as your post said using the mic from your mac ssh seems like the way to go. – user13523 Jun 28 '14 at 6:40
  • on m mac when i type this command it says arecord command not found – mihirb Jun 28 '14 at 15:33
1

You can make your Pi a BT audio receiver and connect your Mac and Pi together and run a program to real time listen to your microphone. Have the Mac set the audio out to the BT Pi and you should be good. Resources for this can be found

http://www.raspberrypi.org/forums/viewtopic.php?t=26685

http://prupert.wordpress.com/2010/08/02/stream-live-audio-from-a-microphone-in-near-real-time-in-ubuntu/

/OR/

https://askubuntu.com/questions/123798/how-to-hear-my-voice-in-speakers-with-a-mic

0

The simplest way to do this would be to utilise Apple's Airplay technology so that remote audio devices are accessible from most OSX and iOS audio apps. The best way to do this is to install and run shairport-sync on the Pi - Which turns the Pi into a network speaker you can select via Airplay on a OSX or iOS device. You'll have to build it from source on Raspbian, though there are apparently binary packages on ArchLinux for the Pi. There is also an older version of shairport (apt-get install libshairport1) which apparently works but has some issues.

Another approach would be to use jacktrip, or netjack, which work with the JACK audio system which is available for OSX, Linux, and Windows.

It is also possible to use Gstreamer (see related question) and/or ffmpeg to set up streaming audio and video.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.