Redemption
Posts: 17
Joined: Mon Sep 03, 2012 4:47 am

SSH Audio transmission

Sat Feb 23, 2013 2:03 am

http://mattkaar.com/blog/2012/12/01/ras ... y-monitor/

Hi, i'm doing a project similiar to a baby monitor require a Raspberry pi to transmit audio from a USB mic to another device. I was following the instruction on the website stated.

Setting up a ssh connection with putty for windows.

Code: Select all

$ arecord -D plughw:1,0 -f dat | ssh -C [email protected] aplay -f dat 
While i was able to remotely control certain features of RPI with putty from my windows PC. I am still unable to transmit any audio/ sound over using the command suggested. It indicates that the user refused connection. What does it mean? Any way to solve it?

User avatar
jojopi
Posts: 3192
Joined: Tue Oct 11, 2011 8:38 pm

Re: SSH Audio transmission

Sat Feb 23, 2013 4:44 am

That command is for sending audio between two Linux machines. The "arecord" part runs on one computer, and turns the audio into a binary stream, "|ssh" pipes the data to the other computer, where "aplay" sends it to the sound card.

Redemption
Posts: 17
Joined: Mon Sep 03, 2012 4:47 am

Re: SSH Audio transmission

Sat Feb 23, 2013 8:57 am

Ok. That explains a lot. I shall try that with two raspberry Pi.

Redemption
Posts: 17
Joined: Mon Sep 03, 2012 4:47 am

Re: SSH Audio transmission

Tue Feb 26, 2013 4:03 am

Hi, i have a problem again, i set up ssh connection with two raspberry pi, through a router.

However, when i type the

Code: Select all

arecord -D plughw:1,0 -f dat | ssh -C [email protected] aplay -f dat
This will result in

Code: Select all

[email protected] ~ $ arecord -D plughw:1,0 -f dat | ssh -C [email protected] aplay -f datRecording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
The authenticity of host '192.168.1.13 (192.168.1.13)' can't be established.
ECDSA key fingerprint is 53:3c:bb:47:6f:f1:f5:b9:4d:22:7a:c6:fb:c0:81:c6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.13' (ECDSA) to the list of known hosts.
[email protected]'s password: 
Permission denied, please try again.
[email protected]'s password: 
Permission denied, please try again.
[email protected]'s password: 
Permission denied (publickey,password).
what's the [email protected]'s password? I have no idea what it could be. I don't remember setting any password for it. Anyone know it?

User avatar
tonyhughes
Posts: 951
Joined: Wed Dec 26, 2012 3:46 am

Re: SSH Audio transmission

Tue Feb 26, 2013 4:57 am

Its a valid username and password for the machine in question.

If it's running Raspbian, its "pi" and "raspberry".

If you changed it, it's whatever you changed it to.

Redemption
Posts: 17
Joined: Mon Sep 03, 2012 4:47 am

Re: SSH Audio transmission

Tue Feb 26, 2013 5:00 am

yes. both the raspberry pi is working on raspbian wheezy.

I've tried both "pi" and "raspberry", I've not changed it either.
Neither of them work ;(

I'm on a dead end .

User avatar
tonyhughes
Posts: 951
Joined: Wed Dec 26, 2012 3:46 am

Re: SSH Audio transmission

Tue Feb 26, 2013 5:09 am

Code: Select all

arecord -D plughw:1,0 -f dat | ssh -C [email protected] aplay -f dat
The line above... paste the actual line you are typing, with no modifications...

Redemption
Posts: 17
Joined: Mon Sep 03, 2012 4:47 am

Re: SSH Audio transmission

Wed Feb 27, 2013 1:09 pm

Oh..that's the actual line i type with no modifications.

User avatar
tonyhughes
Posts: 951
Joined: Wed Dec 26, 2012 3:46 am

Re: SSH Audio transmission

Wed Feb 27, 2013 7:27 pm

Do you have a user on that device with that actual system username of "user"?

Should be "pi" or "john" or "sally" or something.

Redemption
Posts: 17
Joined: Mon Sep 03, 2012 4:47 am

Re: SSH Audio transmission

Thu Feb 28, 2013 2:56 am

Just double checking.

I've no user on the RPI itself, using the default login id as "pi" and "raspberry" as password for Raspbian OS. So i should be typing this instead?

Code: Select all

arecord -D plughw:1,0 -f dat | ssh -C [email protected] aplay -f dat

User avatar
tonyhughes
Posts: 951
Joined: Wed Dec 26, 2012 3:46 am

Re: SSH Audio transmission

Thu Feb 28, 2013 3:00 am

Definitley yes.

If you have only got the "pi" user, then you must use that.

Literally typing "user" as a username simply won't work.

If your Pi is exposed to the internet at all (via DMZ or port forwarding) you MUST change the password for the "pi" account.

You can do this by running

Code: Select all

sudo raspi-config
on your Pi.

Redemption
Posts: 17
Joined: Mon Sep 03, 2012 4:47 am

Re: SSH Audio transmission

Fri Mar 01, 2013 7:36 am

Hi, i've tried the code.

[code]arecord -D plughw:1,0 -f dat | ssh -C [email protected] aplay -f dat [/code]

It still does not work. Instead, another problem arises.
[code] [email protected] ~ $ arecord -D plughw:1,0 -f dat | ssh -C [email protected] aplay -f dat
ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
arecord: main:682: audio open error: No such file or directory
[email protected]'s password:
aplay: playback:2483: read error[/code]

What does this mean? Have i set up the system wrongly?

Let me list down the method i use to set up SSH between my two RPI.

First i enable the SSH server on pi with

[code][email protected] ~ $ sudo raspi-config
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'S17resize2fs_once' missing LSB tags and overrides
insserv: warning: script 'resize2fs_once' missing LSB tags and overrides
[ ok ] Starting OpenBSD Secure Shell server: sshd.[/code]

then i connect it with

[code][email protected] ~ $ ssh 192.168.1.13[/code]

and it indicates that it is successful with

[code][email protected]'s password:
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Feb 21 17:20:25 2013[/code]

Have i done it wrongly?

toku
Posts: 1
Joined: Tue Mar 19, 2013 1:37 am

Re: SSH Audio transmission

Tue Mar 19, 2013 2:01 am

It looks like you've got the SSH part working now. I think the issue you're having now is the -D argument you're passing to arecord.

Run this command on the pi you're trying to record from to list the available devices:

Code: Select all

arecord -l
You should see output like this:

Code: Select all

$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: GoMic [Samson GoMic], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
I think you take the card number (1 here) and the device number (0 here) for the arecord -D option. Based on my output above, I'm maknig this work with this command:

Code: Select all

arecord -D plughw:1,0 -f dat | ssh -C [email protected] aplay -D plughw:0,3 -f dat
Note that I also specified a device on the aplay side. You may need to determine your aplay device using the same method (inspect the output of aplay -l on the pi you're going to use to play).

seyoung
Posts: 5
Joined: Wed Feb 18, 2015 11:22 am

Re: SSH Audio transmission

Wed Feb 18, 2015 11:26 am

I succeeded doing it from Ubuntu with the following command:

Code: Select all

ssh [email protected] arecord -c 2 -f S16_LE -d 300 -r 44100 | aplay -f S16_LE
Note: I have attached an Wolfson soundcard but you can change the parameters as you wish.

fruitoftheloom
Posts: 22646
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: SSH Audio transmission

Wed Feb 25, 2015 2:37 pm

seyoung wrote:I succeeded doing it from Ubuntu with the following command:

Code: Select all

ssh [email protected] arecord -c 2 -f S16_LE -d 300 -r 44100 | aplay -f S16_LE
Note: I have attached an Wolfson soundcard but you can change the parameters as you wish.
You do realise the post you are replying to is nigh on 2 years old ;)
Rather than negativity think outside the box !

Asus ChromeBox 3 Celeron is my other computer.

Return to “Graphics, sound and multimedia”