all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using NoiseTorch with Sway and Polkit
@ 2023-07-18 22:45 Robby Zambito
  2023-07-30 23:08 ` nathan via
  0 siblings, 1 reply; 2+ messages in thread
From: Robby Zambito @ 2023-07-18 22:45 UTC (permalink / raw)
  To: Help guix

Hi Guix,

I am trying to run NoiseTorch on my desktop, which runs swaywm and
pipewire. I added the following configuration to my system:

(setuid-programs
  (append
   (list
    (setuid-program (program (file-append noisetorch "/bin/NoiseTorch"))))
   %setuid-programs))

and rebuilt my system. When I run NoiseTorch from my path (the system),
I get this error:

XGB: conn.go:47: Could not get authority info: open /home/robby/.Xauthority: no such file or directory
XGB: conn.go:48: Trying connection without authority info...
panic: x protocol authentication refused: Authorization required, but no authorization protocol specified


goroutine 1 [running]:
github.com/noisetorch/NoiseTorch/vendor/github.com/aarzilli/nucular/clipboard.Start()
	/tmp/guix-build-noisetorch-0.12.2.drv-0/src/github.com/noisetorch/NoiseTorch/vendor/github.com/aarzilli/nucular/clipboard/clipboard_x11.go:28 +0x354
github.com/noisetorch/NoiseTorch/vendor/github.com/aarzilli/nucular.NewMasterWindowSize(0xc0001b0000, {0x7b04b4, 0xa}, {0x0, 0xffffffffffffffff}, 0x0)
	/tmp/guix-build-noisetorch-0.12.2.drv-0/src/github.com/noisetorch/NoiseTorch/vendor/github.com/aarzilli/nucular/shiny.go:83 +0x114
main.main()
	/tmp/guix-build-noisetorch-0.12.2.drv-0/src/github.com/noisetorch/NoiseTorch/main.go:77
        +0x371

When I install NoiseTorch as my user and run it directly I get the following:

robby@lambda ~$ /home/robby/.guix-profile/bin/NoiseTorch
XGB: conn.go:47: Could not get authority info: open /home/robby/.Xauthority: no such file or directory
XGB: conn.go:48: Trying connection without authority info...
XGB: conn.go:47: Could not get authority info: open /home/robby/.Xauthority: no such file or directory
XGB: conn.go:48: Trying connection without authority info...
XGB: conn.go:47: Could not get authority info: open /home/robby/.Xauthority: no such file or directory
XGB: conn.go:48: Trying connection without authority info...
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/gnu/store/bpvbbg981p5cmj1qvr0c81czjgp0bq4l-noisetorch-0.12.2/bin/NoiseTorch' as the super user
Authenticating as: Robby Zambito (robby)
Password: 
==== AUTHENTICATION FAILED ====

The GUI will open (unlike the other method), but it will prompt saying
it does not have the "capabilities to function properly", and a button
to grant it the capabilities it needs (requiring root). Clicking the
button will prompt for my password, but entering the correct password
does not work (I have tried dozens of times, I know I'm typing it right)

I found a supposed solution to this for Nix, but this solution yields
the same results for me:
https://github.com/NixOS/nixpkgs/issues/18012#issuecomment-335350903

If anyone has any insight that would be greatly appreciated!

Robby


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Using NoiseTorch with Sway and Polkit
  2023-07-18 22:45 Using NoiseTorch with Sway and Polkit Robby Zambito
@ 2023-07-30 23:08 ` nathan via
  0 siblings, 0 replies; 2+ messages in thread
From: nathan via @ 2023-07-30 23:08 UTC (permalink / raw)
  To: contact, help-guix

[-- Attachment #1: Type: text/plain, Size: 606 bytes --]

You can add the capabilities manually if you copy the binary out of the store.
sudo setcap 'CAP_SYS_RESOURCE=+ep' ./whatever/filepath
Capabilities will be integrated into guix later:
https://lists.gnu.org/archive/html/guix-patches/2023-02/msg00700.html

But even then, the package doesn't work with PulseAudio due to incorrect ladspa plugin name.
The attached files contain the fix I use.

Because you use pipewire, it's possible NoiseTorch will work without my patch. I think it's still required.
But noise-supression-for-voice also easily supports pipewire without NoiseTorch, so you can just use that.


[-- Attachment #2: noisetorch.scm --]
[-- Type: application/octet-stream, Size: 3377 bytes --]

;; this file and the corresponding noisetorch-ng.patch file are public domain
;;
;; build with
;;   guix build -f ./noisetorch.scm
;; then copy the executable out of the store manually and add capabilities.
;;   sudo setcap 'CAP_SYS_RESOURCE=+ep' ./whatever/filepath
;; capabilities will be integrated later:
;; https://lists.gnu.org/archive/html/guix-patches/2023-02/msg00700.html
(use-modules
 (guix utils)
 (guix packages)
 (guix gexp)
 (guix git-download)
 (gnu packages pkg-config)
 (gnu packages xorg)
 (gnu packages pulseaudio))
;; an updated version of noise-supression-for-voice.
;; this features "VAD Grace Period" and "Retroactive VAD Grace Period," allowing you to add grace time around voice before clipping audio.
(define-public noise-suppression-for-voice-updated-ladspa-only
  (package
   (inherit noise-suppression-for-voice)
   (name "noise-suppression-for-voice")
   (version "1.03")
   (source
    (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/werman/noise-suppression-for-voice")
           (commit (string-append "v" version))))
     (file-name (git-file-name name version))
     (sha256
      (base32 "1aarsbjxha9ipkgk28inbcrbch118x80d7i7kakkcpp2fig4n0i8"))))
   (arguments
    (substitute-keyword-arguments
     (package-arguments noise-suppression-for-voice)
     ((#:configure-flags flags #~'())
      ;; these require building some big library called JUCE, which is not part of guix yet.
      #~(cons* "-DBUILD_VST_PLUGIN=off" "-DBUILD_VST3_PLUGIN=off" "-DBUILD_LV2_PLUGIN=off" "-DBUILD_AU_PLUGIN=off" "-DBUILD_AUV3_PLUGIN=off" #$flags))))))

;; properly rename NoiseTorch to NoiseTorch-ng.
;; https://github.com/noisetorch/NoiseTorch/issues/328
;; this is done in the master branch, but not the latest release of noisetorch-ng.
(define-public noisetorch-ng
  (package/inherit noisetorch
    (name "noisetorch-ng")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/noisetorch/NoiseTorch")
             (commit "254802e1a09efeef2e75bc862f9f342613d00fcc")))
       (sha256
        (base32 "1sw7jm60bprhl37iy3vl5ig4zp7q0k0vf8xj6cq396d8khl8mgpb"))))
    (arguments
     (substitute-keyword-arguments
         (package-arguments noisetorch)
       ((#:phases phases #~%standard-phases)
        #~(modify-phases #$phases
            (add-after 'install 'rename-binary
              (lambda* (#:key outputs #:allow-other-keys)
                (let* ((out (assoc-ref outputs "out")))
                  (rename-file (string-append out "/bin/NoiseTorch") (string-append out "/bin/noisetorch-ng")))))))))))

(define-public noisetorch-ng-nathan
  (package/inherit noisetorch-ng
    (version (string-append (package-version noisetorch-ng) ".1"))
    (source
     (origin
       (inherit (package-source noisetorch-ng))
       ;; - fix ladspa plugin name
       ;; - provide extra parameters required for updated noise-supresssion-for-voice to work.
       ;;   VAD Grace Period=1000
       ;;   Retroactive VAD Grace Period=50
       (patches (cons "./noisetorch-ng.patch"
                      (origin-patches (package-source noisetorch-ng))))))
    (inputs (modify-inputs
                (package-inputs noisetorch-ng)
              (replace "noise-suppression-for-voice" noise-suppression-for-voice-updated-ladspa-only)))))

noisetorch-ng-nathan

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: noisetorch-ng.patch --]
[-- Type: text/x-patch, Size: 1920 bytes --]

diff --git a/module.go b/module.go
index 6e69a7e..dd38275 100644
--- a/module.go
+++ b/module.go
@@ -200,7 +200,7 @@ func loadPipeWireInput(ctx *ntcontext, inp *device) error {
 	idx, err := loadModule(ctx, "module-ladspa-source",
 		fmt.Sprintf("source_name='Filtered Microphone for %s' master=%s "+
 			"rate=48000 channels=1 "+
-			"label=nt-filter plugin=%s control=%d", inp.Name, inp.ID, ctx.librnnoise, ctx.config.Threshold))
+			"label=noise_suppressor_mono plugin=%s control=%d,1000,50,0,0", inp.Name, inp.ID, ctx.librnnoise, ctx.config.Threshold))
 
 	if err != nil {
 		return err
@@ -214,7 +214,7 @@ func loadPipeWireOutput(ctx *ntcontext, out *device) error {
 	idx, err := loadModule(ctx, "module-ladspa-sink",
 		fmt.Sprintf("sink_name='Filtered Headphones' master=%s "+
 			"rate=48000 channels=1 "+
-			"label=nt-filter plugin=%s control=%d", out.ID, ctx.librnnoise, ctx.config.Threshold))
+			"label=noise_suppressor_mono plugin=%s control=%d,1000,50,0,0", out.ID, ctx.librnnoise, ctx.config.Threshold))
 
 	if err != nil {
 		return err
@@ -233,7 +233,7 @@ func loadPulseInput(ctx *ntcontext, inp *device) error {
 
 	idx, err = loadModule(ctx, "module-ladspa-sink",
 		fmt.Sprintf("sink_name=nui_mic_raw_in sink_master=nui_mic_denoised_out "+
-			"label=nt-filter plugin=%s control=%d", ctx.librnnoise, ctx.config.Threshold))
+			"label=noise_suppressor_mono plugin=%s control=%d,1000,50,0,0", ctx.librnnoise, ctx.config.Threshold))
 	if err != nil {
 		return err
 	}
@@ -276,7 +276,7 @@ func loadPulseOutput(ctx *ntcontext, out *device) error {
 	}
 
 	_, err = loadModule(ctx, "module-ladspa-sink", fmt.Sprintf(`sink_name=nui_out_ladspa sink_master=nui_out_out_sink `+
-		`label=nt-filter channels=1 plugin=%s control=%d rate=%d`,
+		`label=noise_suppressor_mono channels=1 plugin=%s control=%d,1000,50,0,0 rate=%d`,
 		ctx.librnnoise, ctx.config.Threshold, 48000))
 	if err != nil {
 		return err

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-04 19:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18 22:45 Using NoiseTorch with Sway and Polkit Robby Zambito
2023-07-30 23:08 ` nathan via

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.