Principles and Ecosystems: The Multi-Layered Product Architecture

How to Setup NoiseTorch AI Mic on Ubuntu

  

 

🎙️ How to Setup NoiseTorch AI Mic on Ubuntu

NoiseTorch is an incredible open-source application that uses AI to suppress background noise like keyboard clicks, fans, and barking dogs. While the app is great, it often needs a little help to start automatically and link correctly to your hardware on every boot.

This guide shows you how to use a generic script to automate the setup for any microphone.

1. Requirements

  • Operating System: Ubuntu 22.04+ (or any modern PipeWire-based distro).
  • Software: NoiseTorch (Installed via GitHub).
  • Packages: pipewire, wireplumber.

2. Get Your Microphone Details

To make the automation work, you need two specific pieces of text that identify your microphone. Open your terminal and run these commands:

A. Find your "Full Node Name"

Run this command to list all input devices:

pw-link -i | grep alsa_input

Copy the long string that looks like your microphone.
(Example: alsa_input.usb-Brand_Model_12345.analog-stereo)

B. Find your "Device Search Term"

Run this command to see your hardware status:

wpctl status

Look under the Devices section. Find your microphone and pick a single, unique word from its name to use as a search keyword.
(Example: If it says "HyperX Solocast", just use Solocast).


3. The Automation Script

Copy the code below into a file named start_mic.sh.
IMPORTANT: You must edit the top two variables with the text you found in Step 2.

#!/bin/bash
# Native PipeWire NoiseTorch Script - Generic Version

# =========================================================
#  USER CONFIGURATION SECTION
# =========================================================

# 1. PASTE YOUR FULL NODE NAME HERE (From Step 2A):
MY_MIC_NAME="INSERT_FULL_NODE_NAME_HERE"

# 2. PASTE YOUR UNIQUE SEARCH KEYWORD HERE (From Step 2B):
# (This helps the script find the hardware ID to set Duplex mode)
CARD_SEARCH_TERM="INSERT_UNIQUE_KEYWORD_HERE"

# =========================================================

# 1. Wait for PipeWire to initialize
until wpctl status > /dev/null 2>&1; do sleep 1; done

# 2. Force Hardware to Duplex Mode
# (This fixes the common "Silence/No Audio" bug on restart)
CARD_ID=$(wpctl status | grep "$CARD_SEARCH_TERM" | grep "type: Device" | head -n 1 | grep -o '[0-9]\+' | head -n 1)

if [ -n "$CARD_ID" ]; then
    PROFILE_INDEX=$(wpctl inspect "$CARD_ID" | grep -B 1 "analog-stereo-duplex" | grep "index" | grep -o '[0-9]\+' | head -n 1)
    
    if [ -n "$PROFILE_INDEX" ]; then
        echo "Setting Device (ID: $CARD_ID) to Profile Index: $PROFILE_INDEX"
        wpctl set-profile "$CARD_ID" "$PROFILE_INDEX"
    fi
fi

# 3. Cleanup existing instances
noisetorch -u 2>/dev/null
killall noisetorch 2>/dev/null
sleep 1

# 4. Start NoiseTorch with a clean name
PIPEWIRE_NODE_PROPS='{ "node.description": "Mic - NCNoiseTorch", "node.nick": "Mic - NCNoiseTorch" }' \
noisetorch -i "$MY_MIC_NAME" -s 75 &

# 5. Set the new AI Mic as Default
for i in {1..20}; do
    # Search for our custom name in the status output
    NT_ID=$(wpctl status | grep -E "Mic - NCNoiseTorch|NoiseTorch" | grep -v "monitor" | head -n 1 | grep -o '[0-9]\+' | head -n 1)

    if [ -n "$NT_ID" ]; then
        # Ensure we don't try to set a system dummy node (IDs usually > 30)
        if [ "$NT_ID" -gt 30 ]; then 
            sleep 1
            if wpctl set-default "$NT_ID"; then
                echo "SUCCESS: 'Mic - NCNoiseTorch' is active."
                exit 0
            fi
        fi
    fi
    sleep 1
done

exit 1

4. Final Steps

  1. Save the file as start_mic.sh in your Home directory.
  2. Make it executable:
    chmod +x ~/start_mic.sh
  3. Test it by running:
    ./start_mic.sh
  4. If it works, add it to your Startup Applications to run automatically when you log in.

Video Walkthrough

If you want to see the manual setup process visually, check out this tutorial:

Watch: Advanced Linux Audio with PipeWire and NoiseTorch

تعليقات