Talking to people from a distance

Instead of listening in on the action, maybe you'd like to be the one creating all the noise by making the Pi an extension of your own voice. You'll be on a computer with a microphone, and the Pi can be somewhere else broadcasting your message to the world through a pair of speakers (or a megaphone). In other words, the roles of the Pi and your computer from the previous topic will be reversed.

Talking in Windows

First, make sure SoX is added to Windows as per the instructions in the Listening in Windows section:

  1. Connect your microphone and check the input volume of your device. You'll find the settings in Control Panel | Hardware and Sound | Manage audio devices under the Recording tab. Make your microphone the default device by selecting it and clicking on Set Default.
  2. Start a command prompt from the Start menu by clicking on the shortcut or by typing cmd in the Run/Search field.
  3. We can start a monitoring loop first to ensure our microphone works as intended:
    C:> "C:Program Files (x86)sox-14-4-2sox" -d -d
    
  4. Now, to send the audio from our microphone to the speakers on the Pi,
  5. use the following command:
    C:> "C:Program Files (x86)sox-14-4-2sox" -d -t wav - | "C:Program Files (x86)PuTTYplink" pi@[IP address] -pw [password] sox -q -t wav - -d
    
  6. Maybe you'd like to broadcast some nice music or a prerecorded message instead of your own live voice? Use the following command to send My Song.mp3 from your desktop to be played out of the speakers connected to the Pi:
    C:> type "%UserProfile%DesktopMy Song.mp3" | "C:Program Files (x86)PuTTYplink" pi@[IP Address] -pw [password] sox -t mp3 - -d
    
  7. Or why not broadcast an entire album with sweet tunes located in the My Album folder on the desktop:
    C:> type "%UserProfile%DesktopMy Album*.mp3" | "C:Program Files (x86)PuTTYplink" pi@[IP Address] -pw [password] sox -t mp3 - -d
    

Talking in Mac OS X or Linux

First make sure SoX is added to your operating system as per the instructions in the Listening in Mac OS X or Linux section:

  1. Connect your microphone and check the input volume of your device. On Mac, you'll find the settings in System Preferences | Sound under the Input tab. Make your microphone the default device by selecting it from the list. On Linux, use the default mixer application of your distribution or alsamixer.
  2. Open up a Terminal (located in /Applications/Utilities on the Mac).
  3. We can start a monitoring loop first to ensure our microphone works as intended, with the following command:
    $ sox -d -d
    
  4. Now, to send the audio from our microphone to the speakers on the Pi, use the following command:
    $ sox -d -t sox - | ssh pi@[IP address] sox -q -t sox - -d
    

Attention Mac users

You'll likely be flooded with warnings from the CoreAudio driver while SSH is waiting for you to input your password for the pi user. Just ignore the messages, type in your password anyway, and press the Enter key-the recording will proceed as normal:

  1. Maybe you'd like to broadcast some nice music or a prerecorded message instead of your own live voice. Use the following command to send My Song.mp3 from your desktop to be played out of the speakers connected to the Pi:
    $ cat ~/"Desktop/My Song.mp3" | ssh pi@[IP address] sox -t mp3 - -d
    
  2. Or why not broadcast an entire album with sweet tunes located in the My Album folder on the desktop:
    $ cat ~/"Desktop/My Album/"*.mp3 | ssh pi@[IP address] sox -t mp3 - -d
    

Talking in Bluetooth

Using Bluetooth makes it easy to be mischievous by using the techniques explored in the Listening over Bluetooth section. For example, you could set your Pi to remotely connect to the Bluetooth sound-bar connected to your TV in the living room, with you sitting in another room projecting your voice by speaking into the microphone attached to your Pi's soundcard.

Or, if your Pi is an integral part of the furniture in a particular room, you could use a Bluetooth headset with a microphone to send audio to a speaker connected to the Pi's jack output.

To do this, we need to tell PulseAudio what our default sound source and output is, and simply run the SoX monitoring loop again.

If PulseAudio isn't already running, then start it with:

pi@raspberrypi ~ $ pulseaudio --start

The following command will set your Pi's default audio output to the jack plug:

pi@raspberrypi ~ $ pactl set-default-sink alsa_output.0.analog-stereo

With my headset connected to the Pi (which has a built-in mic), I can find the source device name, according to PulseAudio, using:

pi@raspberrypi ~ $ pacmd list-sources short | grep -e 'name:'

In my case, this is:

bluez_sink.00_03_89_93_8D_B4.monitor

To set this as the default audio input device, use this command:

pi@raspberrypi ~ $ pactl set-default-source bluez_sink.00_03_89_93_8D_B4.monitor

Set up the monitor loop to use the default devices and start talking:

pi@raspberrypi ~ $ sox -d -d
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.131.10