emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/greader eb01e0b902 13/17: - Piper shell script updated


From: ELPA Syncer
Subject: [elpa] externals/greader eb01e0b902 13/17: - Piper shell script updated and improved, (thanks to @ra1nb0w).
Date: Wed, 18 Dec 2024 18:59:11 -0500 (EST)

branch: externals/greader
commit eb01e0b90238a35491e72aedbfce068921e811a4
Author: Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com>
Commit: Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com>

    - Piper shell script updated and improved, (thanks to @ra1nb0w).
    
    - greader-piper.el: pacified with the compiler.
---
 greader-piper.el |  7 ++++---
 greader.el       |  2 +-
 piper.sh         | 46 ++++++++++++++++++++++++++++++++--------------
 3 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/greader-piper.el b/greader-piper.el
index d879708633..ba2ed2bf6b 100644
--- a/greader-piper.el
+++ b/greader-piper.el
@@ -20,7 +20,8 @@
 ;; It uses a shell script to call piper.
 
 ;;; code:
-(require 'package)
+(require 'find-func)
+
 (defgroup greader-piper
   nil
   "piper back-end."
@@ -51,12 +52,12 @@ Error."
            (setq answer (call-process "curl" nil "*piper-script download*"
                                       nil greader-piper-script-url))
            (unless (file-exists-p greader-piper-script-path)
-             (Error "Error while downloading %s\nPlease try later or
+             (error "Error while downloading %s\nPlease try later or
 open an issue" greader-piper-script-url)))
        nil))))
 
 ;;;###autoload
-(defun greader-piper (command &optional arg)
+(defun greader-piper (command &optional _arg)
   "Entry point for greader-piper."
   (pcase command
     ('executable
diff --git a/greader.el b/greader.el
index 89b6f978c7..596d7ab440 100644
--- a/greader.el
+++ b/greader.el
@@ -45,7 +45,7 @@
 (require 'seq)
 (require 'view)
 (defvar-local greader-timer-flag nil)
-
+(require 'find-func)
 (defvar greader-auto-tired-timer nil)
 (defvar greader-auto-tired-end-timer)
 (defvar greader-last-point nil)
diff --git a/piper.sh b/piper.sh
index bfa013edf5..50b58cf9e6 100644
--- a/piper.sh
+++ b/piper.sh
@@ -1,29 +1,47 @@
-#!/bin/bash
+#!/bin/sh
 
-# Piper parameters configuration
-MODEL="en_US-lessac-medium.onnx" # Text-to-speech model
-OUTPUT_FORMAT="raw"             # Output format (e.g. raw, wav)
-SAMPLE_RATE=22050               # Sampling rate
-AUDIO_FORMAT="S16_LE"           # Audio format for aplay
+# ** Piper parameters configuration  **
+# Piper binary
+# Piper binary should be in your PATH.
+PIPER_BIN="piper"
+# Text-to-speech model; must be the full path
+MODEL="en_US-lessac-medium.onnx"
+# Output format (e.g. raw, wav)
+OUTPUT_FORMAT="raw"
+# Sampling rate
+SAMPLE_RATE=22050
+# Audio format for aplay
+AUDIO_FORMAT="S16_LE"
+# software used to play the audio generated by piper
+AUDIO_PLAYER_BIN="aplay"
+# options for the audio player software
+AUDIO_PLAYER_OPTS="-r ${SAMPLE_RATE} -f ${AUDIO_FORMAT} -t ${OUTPUT_FORMAT} -"
+
+TTS="${1}"
 
 # User input control
-if [ -z "$1" ]; then
+if test "${TTS}" = ""; then
     echo "Usage: $0 \"Text to synthesize\""
     exit 1
 fi
 
-TEXT="$1"
-
 # Check existence of model and Piper
-if [ ! -f "./piper" ]; then
-    echo "Error: The Piper executable file is not present in the current 
directory."
+if ! command -v "${PIPER_BIN}" > /dev/null 2>&1; then
+    echo "Error: The Piper executable file is not present."
     exit 2
 fi
 
-if [ ! -f "$MODEL" ]; then
-    echo "Error: Model $MODEL is not present in the current directory."
+if ! test -f "${MODEL}"; then
+    echo "Error: Model ${MODEL} is not present in the current directory."
     exit 3
 fi
 
+if ! command -v "${AUDIO_PLAYER_BIN}" > /dev/null 2>&1; then
+    echo "Error: The audio player executable file is not present."
+    exit 4
+fi
+
 # Text-to-speech flow
-echo "$TEXT" | ./piper --model "$MODEL" --output-$OUTPUT_FORMAT | aplay -r 
"$SAMPLE_RATE" -f "$AUDIO_FORMAT" -t "$OUTPUT_FORMAT" -
+echo "${TTS}" | \
+    "${PIPER_BIN}" --model "${MODEL}" --output-${OUTPUT_FORMAT} | \
+    "${AUDIO_PLAYER_BIN}" ${AUDIO_PLAYER_OPTS}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]