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.
-
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– Steve Robillard2014年06月27日 21:36:29 +00:00Commented Jun 27, 2014 at 21:36
-
3Hopefully you are going to use a powered speaker (amplifyer). The Rpi cannot directly drive a low impedance speaker.Marla– Marla2014年06月28日 14:02:16 +00:00Commented Jun 28, 2014 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– thekiwi50002014年11月26日 23:17:24 +00:00Commented Nov 26, 2014 at 23:17
3 Answers 3
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...
-
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– mihirb2014年06月27日 23:23:23 +00:00Commented Jun 27, 2014 at 23:23
-
where it says user@rpiIPadress would I just replace it with the Raspberry Pi's IP address?mihirb– mihirb2014年06月27日 23:24:45 +00:00Commented Jun 27, 2014 at 23:24
-
So i would access the raspberry pi remotely via ssh and then execute this code?mihirb– mihirb2014年06月27日 23:35:23 +00:00Commented Jun 27, 2014 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– user135232014年06月28日 06:40:48 +00:00Commented Jun 28, 2014 at 6:40
-
on m mac when i type this command it says arecord command not foundmihirb– mihirb2014年06月28日 15:33:54 +00:00Commented Jun 28, 2014 at 15:33
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
/OR/
https://askubuntu.com/questions/123798/how-to-hear-my-voice-in-speakers-with-a-mic
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.