Skip to content

Instantly share code, notes, and snippets.

@c3rb3ru5d3d53c
Created October 21, 2024 22:01
Show Gist options
  • Save c3rb3ru5d3d53c/c02709a0d7a01dbb12142a85c5aab695 to your computer and use it in GitHub Desktop.
Save c3rb3ru5d3d53c/c02709a0d7a01dbb12142a85c5aab695 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Author: @c3rb3ru5d3d53c
# Requires: ffplay, piper
# piper : https://github.com/rhasspy/piper
# Global Variable Configuration
PIPER=/home/c3rb3ru5/Tools/piper/piper
PIPER_VOICE=/home/c3rb3ru5/Tools/piper/piper-voices/en/en_US/hfc_female/medium/en_US-hfc_female-medium.onnx
PIPER_PITCH=1
PIPER_SPEED=1.75
PIPER_SAMPLE_RATE=21050
PIPER_BIT_RATE=s16le
function say(){
$PIPER \
--model $PIPER_VOICE \
--output-raw | \
ffplay \
-f ${PIPER_BIT_RATE} \
-ar ${PIPER_SAMPLE_RATE} \
-nodisp \
-autoexit \
-af "atempo=${PIPER_SPEED},rubberband=pitch=${PIPER_PITCH}" -
}
if [ "$(pidof piper)" ]; then
pkill piper;
exit 0;
fi
if [ "$(pidof ffplay)" ]; then
pkill ffplay;
exit 0;
fi
wl-paste | say
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment