1. Overview

Microphones are just audio input devices. Thus, any devices that accept audio input use a microphone. Further, we can use a phone as a microphone for a PC or laptop. This is very helpful if we have no dedicated microphone.

Notably, Android has many apps for this purpose. As a result, we can turn our Android phones into a microphone for a Linux system.

In this tutorial, we’ll see how to use an Android phone as a microphone in Linux.

We’ll go through each step of this tutorial on a Ubuntu 22.04 system. However, the steps should work on many other Linux systems with little or no changes.

2. Using AudioRelay

AudioRelay streams audio from an Android phone to a Linux machine. Also, it can stream the data over WiFi or a USB connection.

AudioRelay creates a virtual audio device. This device acts as a middleman between the phone and other applications. In particular, the virtual device gets an audio stream from the phone. It then presents the audio as an input to the system.

Let’s set up AudioRelay on Linux.

2.1. Installing AudioRelay

First, we download the application from the official website using wget:

$ wget https://dl.audiorelay.net/setups/linux/audiorelay-0.27.5.deb

Then, we install the downloaded package using dpkg:

$ sudo dpkg -i audiorelay-0.27.5.deb
Selecting ...
(Reading database ...
...

As a result, we have access to the application.

2.2. Creating a Virtual Audio Device

Let’s see now how to use AudioRelay as an audio source.

First, we create a virtual audio device. Moreover, this device receives the audio from AudioRelay. It then acts as an actual audio source for other applications.

To set the audio device from the command line, we use the pactl command:

$ pactl load-module module-null-sink \
sink_name=audiorelay-virtual-mic-sink \
sink_properties=device.description=Virtual-Mic-Sink

Let’s break down the above command:

  • load-module: loads a given module
  • module-null-sink: name of the module to load
  • sink_name=audiorelay-virtual-mic-sink: sets a name to the virtual sink we’re creating
  • sink_properties=device.description=Virtual-Mic-Sink: sets a property or description for the virtual sink

In summary, the above command instructs pactl to load the module-null-sink module. As expected, this module creates a null sink which doesn’t preserve audio data.

Moreover, we’ve set sink_name to audiorelay-virtual-mic-sink. This is for clarity purposes.

Also, the device.description property defines a human-readable description of the device. We’ve set it to Virtual-Mic-Sink to easily identify it in applications.

Then, we create a virtual device discoverable by other applications:

$ pactl load-module module-remap-source \
master=audiorelay-virtual-mic-sink.monitor \
source_name=audiorelay-virtual-mic-sink \
source_properties=device.description=Virtual-Mic

Let’s break down the above command:

  • module-remap-source: generates a remapped source on top of a master source
  • master: index of the master source
  • source_name: name for the remapped source
  • source_properties: extra properties for the remapped source

These changes are still temporary. As we reload the PulseAudio, the virtual device is gone:

$ pulseaudio -k

Let’s make these changes permanent. For this, we modify the file /etc/pulse/default.pa.

2.3. Making the Changes Permanent

Let’s make the virtual audio device persist between system restarts.

First, we open the server startup script for PulseAudio. Then, we append some lines to the end of the script:

$ cat /etc/pulse/default.pa
...
# Creates a device where AudioRelay can stream audio into
load-module module-null-sink sink_name=audiorelay-virtual-mic-sink sink_properties=device.description=Virtual-Mic-Sink
# Creates a device usable by other apps
load-module module-remap-source master=audiorelay-virtual-mic-sink.monitor source_name=audiorelay-virtual-mic-sink source_properties=device.description=Virtual-Mic

These lines are similar to the commands we ran above.

2.4. PulseAudio Volume Control

Let’s open PulseAudio Volume Control. Here, we should see our virtual input and output devices:

PulseAudio Volume Control

Now, let’s select the Virtual-Mic as an input to our applications. For this, we open the system Sound settings:

System Sound Settings

Here, we choose Virtual-Mic as an input device.

2.5. Using the AudioRelay App on the Android Phone

Let’s install the AudioRelay app from the Playstore:

Mumble Clients

Also, we have to connect the phone to the same network as our Linux machine.

Then, we open the app. Under the Server tab, we select the option Microphone. As a result, the AudioRelay server starts on the phone.

Also, we can see the server IP on the screen:

AudioRelay Server IP

Let’s keep a note of the IP of the server.

2.6. Connecting to Android Phone From the Desktop

Next, we open the AudioRelay app on our desktop. Then, we go to the Player section.

After that, we select the server IP that matches the AudioRelay server on the phone:

AudioRelay Server Selection

As a result, this connects the phone’s microphone to the desktop client:

AudioRelay Connected to Server

Finally, we should now be able to use the phone’s mic as an input.

3. Using Mumble

Mumble is a popular open-source voice chat application. It can also stream audio from an Android phone to a Linux machine.

Let’s install Mumble on our Linux machine.

3.1. Configuring Mumble on Linux

We can install the Mumble server on Ubuntu using apt:

$ sudo apt install mumble-server

After that, we use the dpkg-reconfigure command to configure the server:

$ sudo dpkg-reconfigure mumble-server

Initially, the configuration prompts whether we want the Mumble server to start at system boot automatically:

Mumble Server Autostart

We select Yes here to enable server auto start.

Next, we give the Mumble server a higher priority to ensure low latency:

Mumble Server Priority

On the next window, we set a password for Mumble’s SuperUser account:

Mumble Server Password

This account has the highest-level administrative privileges on the server.

For this reason, SuperUser has the privilege to administer server management.

At this point, the server configuration is complete. However, we can also set any advanced settings. For this, we can update the file /etc/mumble-server.ini.

3.2. Installing Mumble Client

Let’s now install the Mumble client on the system:

$ sudo apt install mumble

Once it’s installed, we can start it from the Application menu.

Upon startup, we see an Audio Tuning Wizard introduction window:

Mumble Client Introduction

After pressing Next, we continue with the default options at each step:

Mumble Client Default Options

Next, the setup plays a sample voice. We can use the slider to set how much data to buffer:

Tuning Mumble Client

Moving on, we tune the microphone volume to its optimal settings. There are some instructions in the given window. We can use them to apply these settings:

 

Tuning MicrophoneNext, we select the data value as Raw amplitude from input. Then, we set the voice detection threshold:

Voice Detection Threshold

On the next window, we set the quality and notification settings:

Quality and Notification Settings

Then, the setup adjusts the audio positioning for some games:

Audio Positioning

Finally, we can finish the setup:

Finishing Mumble Client Setup

At this point, the client setup is complete.

3.3. Connecting to the Mumble Server

Let’s now restart the Mumble server:

$ sudo systemctl restart mumble-server

Next, we check the Mumble client application. We should see our local Mumble server here.

Let’s select the local Mumble server, juveriya in our case. Then, we click the Connect button:

Connecting to Mumble Server

After this, we enter a name, say Desktop_Client. Then, it prompts us to accept a certificate:

Mumble Server Certificate

On a successful connection, the client plays a voice message connected.

3.4. Installing Mumble Client on Android Phone

Let’s now install the Mumble client on the phone from the Play Store:

Mumble Client for Phone

After that, we launch the Mumble client app on the phone. Initially, it prompts us to generate a certificate.

Again, the phone should be on the same network as the Linux system.

Next, we add the server details. The IP address of this server is the same as that of the Mumble server on the desktop.

Let’s give a name to the user, say Baeldung:

Mumble User on Phone

The above server name is shown under the Favorites section. Then, we click the server name.

Again, a certificate shows up on the phone screen. We need to allow this certificate. This connects the phone to the Mumble server:

Mumble Clients

As a result, we see both the client users on the Mumble client applications.

We can now use the phone’s microphone to speak and listen to the voice playback.

4. Using the IP Webcam Android App

IP Webcam is an Android app. We can use it to turn an Android phone into a microphone for a desktop machine. Let’s see how it works.

First, we install the IP Webcam app from Playstore:

IP Webcam App

Then, we start the server. For this, we click the Start server option from the three vertical dots:

Starting IP Webcam Server

By this time, an IP address and a port number should be shown on the phone:

IP Webcam IP Address

Hence, we input the above IP address and port number in a web browser.

On the landing page, we select an output format for the audio. For example, let’s take the option as HTML 5Wav:

IP Webcam Homepage

After that, we can speak on the phone’s microphone. As a result, we can listen to the audio playback.

IP Webcam works as a webcam and as a microphone as well.

5. Comparison Between the Tools

Let’s compare the tools above.

5.1. Audio Quality

First, we test the audio quality for the free version of these tools.

Let’s check it over USB mode:

  • AudioRelay: fairly good audio quality
  • Mumble: provides high audio quality
  • IP Webcam: audio quality isn’t as fine as in the first two cases

Generally, Mumble quality is better than the rest.

5.2. Latency

Now, let’s see the delay in audio delivery:

  • AudioRelay: latency is very low
  • Mumble: minimal delay, close to a real microphone
  • IP Webcam: more delay along with echoing problem

As a result, we can say IP Webcam isn’t a good choice for real-time transmission.

5.3. Setup Complexity

Let’s now see the setup complexity for these tools:

  • AudioRelay: relatively simple setup method
  • Mumble: setting up a Mumble client on a desktop is fairly complex
  • IP Webcam: very easy to set up when compared to the others

As we’ve seen, Mumble performs better than others. However, this comes at the cost of setting up the client on the desktop, which can be involved.

6. Conclusion

In this article, we’ve seen how to use an Android phone as a microphone in Linux. We used multiple apps to achieve this goal.

First, we checked AudioRelay. Then, we worked with the Mumble tool. Further, we saw the IP Webcam Android app.

Finally, we looked at the performance of each and compared them to each other.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.