Pipewire 噪音消除 kubuntu 23.04

Pipewire 噪音消除 kubuntu 23.04

我正在尝试使用 pipewire 在笔记本电脑上设置噪音消除功能。我需要噪音消除功能,因为我正在录制自己的声音,用于奖学金申请。

我在下面找到了这篇文章。@joelostblom 发布了如何在 pipewire 上设置的说明:

  1. 使用 PulseAudio 实时消除噪音?

它对我来说不起作用。声音驱动程序已禁用。

这是我的文件中的代码pipewire.conf

context.modules = [
    #{ name = <module-name>
    #    [ args  = { <key> = <value> ... } ]
    #    [ flags = [ [ ifexists ] [ nofail ] ]
    #}
    #
    # Loads a module with the given parameters.
    # If ifexists is given, the module is ignored when it is not found.
    # If nofail is given, module initialization failures are ignored.
    #

    # Uses realtime scheduling to boost the audio thread priorities. This uses
    # RTKit if the user doesn't have permission to use regular realtime
    # scheduling.
    { name = libpipewire-module-echo-cancel
      args = {
          # library.name  = aec/libspa-aec-webrtc
          # node.latency = 1024/48000
          source.props = {
             node.name = "Echo Cancellation Source"
          }
          sink.props = {
             node.name = "Echo Cancellation Sink"
          }
       }
    }
    { name = libpipewire-module-rt
        args = {
            nice.level    = -11
            #rt.prio      = 88
            #rt.time.soft = -1
            #rt.time.hard = -1
        }
        flags = [ ifexists nofail ]
    }

    # The native communication protocol.
    { name = libpipewire-module-protocol-native }

    # The profile module. Allows application to access profiler
    # and performance data. It provides an interface that is used
    # by pw-top and pw-profiler.
    { name = libpipewire-module-profiler }

    # Allows applications to create metadata objects. It creates
    # a factory for Metadata objects.
    { name = libpipewire-module-metadata }

    # Creates a factory for making devices that run in the
    # context of the PipeWire server.
    { name = libpipewire-module-spa-device-factory }

    # Creates a factory for making nodes that run in the
    # context of the PipeWire server.
    { name = libpipewire-module-spa-node-factory }

    # Allows creating nodes that run in the context of the
    # client. Is used by all clients that want to provide
    # data to PipeWire.
    { name = libpipewire-module-client-node }

    # Allows creating devices that run in the context of the
    # client. Is used by the session manager.
    { name = libpipewire-module-client-device }

    # The portal module monitors the PID of the portal process
    # and tags connections with the same PID as portal
    # connections.
    { name = libpipewire-module-portal
        flags = [ ifexists nofail ]
    }

    # The access module can perform access checks and block
    # new clients.
    { name = libpipewire-module-access
        args = {
            # access.allowed to list an array of paths of allowed
            # apps.
            #access.allowed = [
            #    /usr/bin/pipewire-media-session
            #]

            # An array of rejected paths.
            #access.rejected = [ ]

            # An array of paths with restricted access.
            #access.restricted = [ ]

            # Anything not in the above lists gets assigned the
            # access.force permission.
            #access.force = flatpak
        }
    }

    # Makes a factory for wrapping nodes in an adapter with a
    # converter and resampler.
    { name = libpipewire-module-adapter }

    # Makes a factory for creating links between ports.
    { name = libpipewire-module-link-factory }

    # Provides factories to make session manager objects.
    { name = libpipewire-module-session-manager }

    # Use libcanberra to play X11 Bell
    { name = libpipewire-module-x11-bell
        args = {
            #sink.name = ""
            #sample.name = "bell-window-system"
            #x11.display = null
            #x11.xauthority = null
        }
        flags = [ ifexists nofail ]
    }
]

答案1

我已经找到解决方案了!以下是最终结果:

最终结果

我还没有测试过!

这些文章帮助我找到了解决方案:

  1. Linux 上的实时麦克风噪音消除

以下是 PipeWire 的实时噪声抑制插件 Github 存储库:

  1. 实时噪音抑制插件

以下是我遵循的简化说明,对我有帮助。请随意纠正我的命令:

前往您的下载文件夹:

cd ~/Downloads

在您的下载文件夹中下载实时噪声抑制插件的最新版本:

以下是链接 >噪声抑制 v1.03(VST2、VST3、LV2、LADSPA、AU、AUv3

噪音

将文件解压linux-rnnoise.zip到下载文件夹

/usr/lib/ladspa如果您的路径中没有文件夹usr,请创建一个:

sudo mkdir /usr/lib/ladspa/

复制librnnoise_ladspa.so插件到你的/usr/lib/ladspa

用您的用户名替换<USERNAME>

sudo cp ~/Downloads/linux-rnnoise/ladspa/librnnoise_ladspa.so /usr/lib/ladspa

创建配置目录,用于存放过滤器链配置文件

mkdir -p ~/.config/pipewire/

创建一个名为“input-filter-chain.conf”的过滤链文件

gedit ~/.config/pipewire/input-filter-chain.conf

将这些代码粘贴到您的input-filter-chain.conf文件中:

# Noise canceling source
#
# start with pipewire -c filter-chain/input-filter-chain.conf
#
context.properties = {
    log.level        = 0
}

context.spa-libs = {
    audio.convert.* = audioconvert/libspa-audioconvert
    support.*       = support/libspa-support
}

context.modules = [
    {   name = libpipewire-module-rtkit
        args = {
            #nice.level   = -11
            #rt.prio      = 88
            #rt.time.soft = 200000
            #rt.time.hard = 200000
        }
        flags = [ ifexists nofail ]
    }
    {   name = libpipewire-module-protocol-native }
    {   name = libpipewire-module-client-node }
    {   name = libpipewire-module-adapter }

    {   name = libpipewire-module-filter-chain
        args = {
            node.name =  "rnnoise_source"
            node.description =  "Noise Canceling source"
            media.name =  "Noise Canceling source"
            filter.graph = {
                nodes = [
                    {
                        type = ladspa
                        name = rnnoise
                        plugin = /usr/lib/ladspa/librnnoise_ladspa.so
                        label = noise_suppressor_stereo
                        control = {
                            "VAD Threshold (%)" 50.0
                        }
                    }
                ]
            }
            capture.props = {
                node.passive = true
            }
            playback.props = {
                media.class = Audio/Source
            }
        }
    }
]

确保您的插件变量指向您的插件!

plugin = /usr/lib/ladspa/librnnoise_ladspa.so

如果不存在,请创建 systemd 用户配置目录。

mkdir -p ~/.config/systemd/user/

创建新的 systemd 单元文件

gedit ~/.config/systemd/user/pipewire-input-filter-chain.service

确保:

  1. 如果您对过滤器链配置文件使用了不同的名称,请替换该文件名。

  2. <username>用您的帐户用户名替换。

[Unit]
Description=PipeWire Input Filter Chain
After=pipewire.service
BindsTo=pipewire.service

[Service]
ExecStart=/usr/bin/pipewire -c /home/<username>/.config/pipewire/input-filter-chain.conf
Type=simple
Restart=on-failure

[Install]
WantedBy=pipewire.service

重新加载 systemd 用户单元文件

systemctl --user daemon-reload

启用创建的 systemd 服务

systemctl --user enable pipewire-input-filter-chain.service

启动过滤器

systemctl --user enable pipewire-input-filter-chain.service

验证pipewire-input-filter-chain.service状态为正在运行

systemctl --user status pipewire-input-filter-chain.service

重新启动 pipewire

systemctl --user restart pipewire.service pipewire-pulse.service

一切已准备就绪!

答案2

如果你习惯使用 Flatpak(只需在 Discover 中启用它),我建议你尝试一下简易效果- 这实际上是 PulseEffects 经过彻底改造后的新名称,以管道而不是 PulseAudio 为目标;它配备了开箱即用的 RNNoise 和许多额外的好东西,基本上是即插即用的,使用起来非常简单。

它基本上将您在“KISS”GUI 中使用管道、过滤器和 RNNoise 所做的所有工作都包裹起来。

相关内容