From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id eKpLCiACKGSZdwAASxT56A (envelope-from ) for ; Sat, 01 Apr 2023 12:06:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id KEBXCSACKGTRvwAAG6o9tA (envelope-from ) for ; Sat, 01 Apr 2023 12:06:24 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 903C95FCE for ; Sat, 1 Apr 2023 12:06:23 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1piY7a-0003z3-Iu; Sat, 01 Apr 2023 06:06:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1piY7Y-0003yr-5D for bug-guix@gnu.org; Sat, 01 Apr 2023 06:06:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1piY7X-00058D-FM for bug-guix@gnu.org; Sat, 01 Apr 2023 06:06:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1piY7W-0001Tg-IM for bug-guix@gnu.org; Sat, 01 Apr 2023 06:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#62589: [PATCH] gnu: nerd-dictation: Factor out wrapper. Add package variants. References: <87ilefgbza.fsf@ngraves.fr> In-Reply-To: <87ilefgbza.fsf@ngraves.fr> Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 01 Apr 2023 10:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62589 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 62589@debbugs.gnu.org Cc: ngraves@ngraves.fr Received: via spool by 62589-submit@debbugs.gnu.org id=B62589.16803435185620 (code B ref 62589); Sat, 01 Apr 2023 10:06:02 +0000 Received: (at 62589) by debbugs.gnu.org; 1 Apr 2023 10:05:18 +0000 Received: from localhost ([127.0.0.1]:35567 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1piY6n-0001Sa-FB for submit@debbugs.gnu.org; Sat, 01 Apr 2023 06:05:17 -0400 Received: from 15.mo583.mail-out.ovh.net ([178.33.107.29]:41919) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1piY6j-0001SQ-PX for 62589@debbugs.gnu.org; Sat, 01 Apr 2023 06:05:15 -0400 Received: from director2.ghost.mail-out.ovh.net (unknown [10.108.16.164]) by mo583.mail-out.ovh.net (Postfix) with ESMTP id 65D252268F for <62589@debbugs.gnu.org>; Sat, 1 Apr 2023 10:05:12 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-8fdxs (unknown [10.109.146.157]) by director2.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 0C69F1FDB0; Sat, 1 Apr 2023 10:05:11 +0000 (UTC) Received: from ngraves.fr ([37.59.142.101]) by ghost-submission-6684bf9d7b-8fdxs with ESMTPSA id kGQmANgBKGR6gCEAHYa+Aw (envelope-from ); Sat, 01 Apr 2023 10:05:11 +0000 X-OVh-ClientIp: 81.67.140.142 Date: Sat, 1 Apr 2023 12:05:09 +0200 Message-Id: <20230401100509.24723-1-ngraves@ngraves.fr> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 132856190600798946 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdeifedgvdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffogggtgfesthekredtredtjeenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeelueehgfevfeevhffftdetgedugeevveehteeileeuueejhfegffetteffhffhvdenucffohhmrghinhepghhithhhuhgsrdgtohhmnecukfhppeduvdejrddtrddtrddupdekuddrieejrddugedtrddugedvpdefjedrheelrddugedvrddutddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqedpnhgspghrtghpthhtohepuddprhgtphhtthhopeeivdehkeelseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehkeefpdhmohguvgepshhmthhpohhuth X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Nicolas Graves From: Nicolas Graves via Bug reports for GNU Guix Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680343583; a=rsa-sha256; cv=none; b=RYRLw132V//qmPZt/YOhIAG5bSETGXikF482Ap3ovT0HjdpjibveDKfdGHbt2c7CvrENeA 4YmHWc3PSKsGjFCH056BRObRnOHPj7mKGTIjdaEUx3q3wUOXAF3xMwFWsVP29QFXoCPPFS cvPeNu7XYh/X45MbKLBSm3bev0uszqxSw3LpmwnQT2Tb6bqie8iL7BNHu3zMQdV+kVvEW5 txB+QUHFnawnHyphMRa7m8Vxxj+lzeIuvsIqRf9MKW22vofOT9CaQ3HdTjMjTRUARuZLZZ YYwAV20rgqFuToO741/zIQNtLo1SpZDhS5MdQsG9X+jMxr9aHUzB1i6UGZq7YA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680343583; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=7qQQJvNjsUGOCb/Sym3s2u3zVejNtiI32xP3qzw3TJ0=; b=SQEJWfNB+U2yvC+HFna6B4k5n0VLuYZDq3dhMppl37clKKk8+aSR+dJoUFL5ZS1xR55GQ7 U6advvbWAp6SfdEkcn/0E6aPD7YcimNAB0BLO93gboc4Nc2c7nAxAo64G2NC7jPnFXZD2C Z1OgY/E//mj/fSOgmQKtjgznEEt/eejdzaW6hCtVXk5pyMprWszKvESx+PvHZ/1iGo83A8 6ZewYY7+9X0mgPDJ95A+J6cLhR9lIjYd10XE2OhwGiQCMATUb+TOI4QxIEXQtzxI4bGlS1 VeXPPPosWlUzKM3X1+PIJ1Lhxk3xYFUf2wmeUbF3iVmuIOJTR8k2XOjC2Pabfw== X-Migadu-Spam-Score: -3.73 X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Spam-Score: -3.73 X-Migadu-Queue-Id: 903C95FCE X-TUID: 46IZC8pO4CmR * gnu/packages/machine-learning.scm (nerd-dictation): Avoid inputs pulseaudio and ydotool when not necessary. Factor out wrapper make-nerd-dictation-package. Add package variants : - nerd-dictation/xdotool - nerd-dictation/sox-xdotool - nerd-dictation/sox-ydotool - nerd-dictation/sox-wtype --- gnu/packages/machine-learning.scm | 88 +++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 28 deletions(-) diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 6c78b14fc6..16a5c1a7c4 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -17,6 +17,7 @@ ;;; Copyright © 2020 Edouard Klein ;;; Copyright © 2020, 2021, 2022, 2023 Vinicius Monego ;;; Copyright © 2020, 2021, 2022, 2023 Maxim Cournoyer +;;; Copyright © 2022, 2023 Nicolas Graves ;;; ;;; This file is part of GNU Guix. ;;; @@ -63,6 +64,7 @@ (define-module (gnu packages machine-learning) #:use-module (gnu packages cran) #:use-module (gnu packages databases) #:use-module (gnu packages dejagnu) + #:use-module (gnu packages freedesktop) #:use-module (gnu packages gcc) #:use-module (gnu packages gettext) #:use-module (gnu packages gl) @@ -106,6 +108,7 @@ (define-module (gnu packages machine-learning) #:use-module (gnu packages xml) #:use-module (gnu packages xdisorg) #:use-module (gnu packages xorg) + #:use-module (srfi srfi-45) #:use-module (ice-9 match)) (define-public fann @@ -3864,7 +3867,6 @@ (define-public nerd-dictation (add-after 'unpack 'chdir (lambda _ (chdir "package/python")))))) (propagated-inputs (list python-vosk)) - (inputs (list pulseaudio xdotool)) (home-page "https://github.com/ideasman42/nerd-dictation") (synopsis "Offline speech-to-text for desktop Linux") (description "\ @@ -3876,38 +3878,68 @@ (define-public nerd-dictation @code{nerd-dictation begin} and @code{nerd-dictation end} commands.") (license license:gpl3+)))) -(define-public nerd-dictation/wayland - (package - (inherit nerd-dictation) - (name "nerd-dictation-wayland") - (inputs (list bash-minimal nerd-dictation)) - (propagated-inputs (list ydotool sox)) - (build-system trivial-build-system) - (arguments - (list - #:modules '((guix build utils)) - #:builder - #~(begin - (use-modules (guix build utils)) - (let* ((exe (string-append #$output "/bin/nerd-dictation")) - (original-exe #$(file-append nerd-dictation - "/bin/nerd-dictation")) - (bash #$(this-package-input "bash-minimal")) - (bash-exe (string-append bash "/bin/bash"))) - (mkdir-p (dirname exe)) - (call-with-output-file exe - (lambda (port) - (format port "#!~a +(define* (make-nerd-dictation-package + input-tool output-tool + #:key (nerd-dictation-package nerd-dictation)) + "Construct a nerd-dictation package for OUTPUT-TOOL." + (match-let* (((input-name output-name) + (map (lambda (tool) + (lazy + (delay (package-name (force tool))))) + (list input-tool output-tool)))) + (package + (inherit nerd-dictation-package) + (name (string-append "nerd-dictation-" + (if (equal? (force input-name) "sox") + "sox-" + "") + (force output-name))) + (build-system trivial-build-system) + (arguments + (list + #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils)) + (let* ((exe (string-append #$output "/bin/nerd-dictation")) + (original-exe #$(file-append + (this-package-input "nerd-dictation") + "/bin/nerd-dictation")) + (bash #$(this-package-input "bash-minimal")) + (bash-exe (string-append bash "/bin/bash"))) + (mkdir-p (dirname exe)) + (call-with-output-file exe + (lambda (port) + (format port "#!~a if [ \"$1\" = begin ] then - exec ~a $@ --input=SOX --simulate-input-tool=YDOTOOL + exec ~a $@ --input=~a --simulate-input-tool=~a else exec ~a $@ fi" - bash-exe - original-exe - original-exe))) - (chmod exe #o555))))))) + bash-exe + original-exe + (if (equal? #$(force input-name) "pulseaudio") + "parec" + (string-upcase #$(force input-name))) + (string-upcase #$(force output-name)) + original-exe))) + (chmod exe #o555))))) + (inputs (list bash-minimal nerd-dictation-package)) + (propagated-inputs (list (force input-tool) (force output-tool)))))) + +;; More variants are possible, but wayland without pipewire seems unlikely. +(define-public nerd-dictation/xdotool + (make-nerd-dictation-package (delay pulseaudio) (delay xdotool))) + +(define-public nerd-dictation/sox-xdotool + (make-nerd-dictation-package (delay sox) (delay xdotool))) + +(define-public nerd-dictation/sox-ydotool + (make-nerd-dictation-package (delay sox) (delay ydotool))) + +(define-public nerd-dictation/sox-wtype + (make-nerd-dictation-package (delay sox) (delay wtype))) (define-public python-brian2 (package -- 2.39.2