emacs-nano-tts-minor-mode

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 4656dd3aa40ab5d3e7051f218a2d64904f9d38e6
parent 7455dd6a9c89bce51b94002e7c1f412d0e4df3bd
Author: Yuval Langer <yuval.langer@gmail.com>
Date:   Mon, 10 Jul 2023 20:43:04 +0300

Add some packaging metadata and a customizable variable.

Diffstat:
Mnano-tts.el | 37+++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/nano-tts.el b/nano-tts.el @@ -3,7 +3,9 @@ ;; Copyright (C) 2023 Yuval Langer ;; Author: Yuval Langer <yuval.langer@gmail.com> +;; Version: 0.1 ;; Keywords: convenience, multimedia +;; URL: https://sr.ht/~kakafarm/emacs-nano-tts-minor-mode/ ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -20,12 +22,28 @@ ;;; Commentary: +;; Usage: +;; +;; 1. Mark a region of text. +;; 2. Press C-c C-c or C-c c to run the nano-tts-speak command. +;; 3. Press C-c c or C-c k to stop the speaking process. +;; +;; You can run nano-tts-speak (C-c C-c or C-c c) several times while +;; nano-tts is reading to add more text for it to read. +;; ;; Much more can be added and maybe it will be added, e.g. WPM ;; customization, maybe better command and control... who knows! ;;; Code: +(defcustom nano-tts-words-per-minute + 175 + "Words per minute spoken." + :type 'integer + :group 'nano-tts + ) + (defvar nano-tts--tts-process nil "The process of a running text-to-speech engine. @@ -64,17 +82,9 @@ about the last process." (nano-tts--get-region-as-string-to-speak))) ;; If the TTS process is not running. (t - - ;; TODO: Trying to also kill the process before making the - ;; system forget about it. - (nano-tts-kill) - - ;; TODO: Commenting the previous way of dealing with - ;; non-running processes: - ;; - ;; Make the system aware that the TTS process had stopped. - ;; (setq nano-tts--tts-process nil) - ))) + ;; Kill the TTS process before making the system forget about + ;; it. + (nano-tts-kill)))) ;; If there is no running TTS process. (progn @@ -82,7 +92,8 @@ about the last process." (setq nano-tts--tts-process (make-process :name "espeak" - :command (list "espeak"))) + :command (list "espeak" + "-s" (number-to-string nano-tts-words-per-minute)))) ;; Send text to it. (process-send-string nano-tts--tts-process @@ -106,10 +117,12 @@ kill the process." old-tts-process))))) +;;;###autoload (define-minor-mode nano-tts "A very small text to speech thingimajig." :init-value nil :lighter " ntts" + :group 'nano-tts :keymap (list (cons (kbd "C-c c") 'nano-tts-speak)