167

I have a USB microphone that I can chat on Skype, record sound etc. But how can I make it so that when my mic is on and I speak, Ι hear it in speakers live without having to record my voice first and then play it back? What apps do I need or where can I enable this option?

I'm running Ubuntu 10.10

11 Answers11

229

Here is a solution that I've tested with Pulse Audio on Ubuntu 12.04.

  • Install PulseAudio Volume Control (pavucontrol):

    sudo apt install pavucontrol
    
  • Now we will route your microphone to your speakers. Do this by running the following command:

    pactl load-module module-loopback latency_msec=1
    
  • On the Recording tab of pavucontrol, you can show all streams (combobox at the bottom) and then configure which microphone (if you have more than one) should loopback into the built-in analog stereo

To stop it running, run:

pactl unload-module module-loopback
Eliah Kagan
  • 119,640
Charl Botha
  • 2,846
81

Simple solution

Just use:

arecord -f cd - | aplay -

If you wanna play while saving:

arecord -f cd - | tee output.wav | aplay -
35
  1. First install PulseAudio Volume Control/pavucontrol.

Either install via Software Manager.

Or run this below command in terminal:

    sudo apt-get install pavucontrol
  1. To start Mic to Speaker working, run below command in terminal.

     pactl load-module module-loopback latency_msec=1
    
  2. To stop the same, run below command in terminal.

     pactl unload-module module-loopback
    
28

I've packaged up other people's answers into 'listen', a Bash script. Run this to listen to your mic input. It sleeps forever. Kill it (e.g. Ctrl-C) to stop listening.

#!/usr/bin/env bash

Directs audio input (e.g. mic) to audio output (e.g. speakers),

then sleeps forever. Stops audio redirection when it is killed.

So, for example, plug your phone into the PC's mic, run 'listen',

and listen to phone audio through your computer's speakers.

Requires:

sudo apt-get install pactl

set -e

module=$(pactl load-module module-loopback latency_msec=10)

function cleanup { pactl unload-module $module }

trap cleanup EXIT

sleep infinity

Pablo Bianchi
  • 17,371
24

You can do it with jackd and qjackctl.

The program jackd is an audio sound server daemon for Linux, and its counterpart qjackctl is a simple user interface that lets you handle JACK audio server. From this you can virtually connect the output of your mic to your speakers.

You can install them from you terminal with:

sudo apt-get install jackd qjackctl

After installing it and running qjackctl, the connections mentioned will look like the following screenshot:

qjackctl app in action

Note, I am a professional audio editor and use it each week recordings sessions.

9

Just an update for 2018 if you use gnome. There's a gnome extension that you can use to achieve just that. Here is the link in case anyone wants to try it out https://extensions.gnome.org/extension/954/pulseaudio-loopback-device/

4

You can use audacity to amplify your voice by "playback while recording" feature. go to edit>preferences>recording> check software playthrough.

nick
  • 51
2

Mixxx is awesome! I'm using it on Ubuntu (Budgie) 18.04. Quick setup, just turn it on, set up your hardware (I only had to set up the input device) and turn on the mic. You're up and running in no time with no latency, plus the ability to do tons more if you want. I dowloaded it from the software store.

Bus42
  • 374
1

You can also use ffplay (part of ffmpeg) e.g. to listen to ALSA device hw:1 and disabling ffplay's display feature (-nodisp) so no X11 is needed:

ffplay -nodisp  -f alsa -i hw:1

Note: You can list possible ALSA [input] sources using ffplay:

ffplay --sources alsa
Pierz
  • 3,391
0

simple script:

 Simple convenience wrapper to record then play back a temporary sound file.
# Usage: arecord-mic duration
[[ $1 == *[![:digit:]]* ]] || return
typeset tmpFile
tmpFile=$(mktemp --suffix .wav) || return

typeset -a arecordOpts=( -c 1 # number of channels -D plughw:0,0 # device name -d "$1" # duration -f S32_LE # format -r 48000 # sample rate -V mono # VU meter type )

arecord "${arecordOpts[@]}" -- "$tmpFile" && aplay -- "$tmpFile" rm -f -- "$tmpFile"

usage: ./arecord-mic <duration>

e.g ./arecord-mic 10 will record about 10 seconds and then plays it back.

source https://wiki.gentoo.org/wiki/ALSA

0

You can also use OBS Studio. After you add an input source like a microphone, click on the gear icon next to it and select Advanced Audio Properties, on this menu select "Monitor and Output" for the "Audio Monitoring" option.

I use this to pass audio from my Nintendo Switch over usb capture card to my PC headphones and I did not notice any delay.

I believe it uses PulseAudio, but it's a more friendly user interface imo.