Replies: 1 comment 1 reply
-
You could add a systemwide/global speech/tts functionality to your computer and assign a keyboard shortcut to read/speak a selected text. I would suggest to install and setup piper. You will additionally need a voice model for piper (ONNX). The ONNX model consists of two parts: One You can find piper voices for example here on huggingface. And here is my script #!/bin/bash
set -eo pipefail
dir="$(dirname $0)"
# define your models path. replace
# the below with your real path
model="/mnt/backups/models/tts"
# specify a speaker of your choice
speaker="speaker_1"
# Note: the *.onnx.json file will give information about which frequency
# has to be used with which model. In my case it is 16 kHz for ramona_low
# and 22050 Hz for throsten_medium
# define the various speakers
case $speaker in
speaker_1)
model="$(model)/ramona/de_DE-ramona-low.onnx"
echo_out="play -r 16000 -e signed-integer -b 16 -c 1 -t raw -"
;;
speaker_2)
model="$(model)/thorsten/thorsten-emo/de_DE-thorsten_emotional-medium.onnx"
echo_out="play -r 22050 -e signed-integer -b 16 -c 1 -t raw -"
;;
*)
echo "Unknown Speaker: $speaker"
exit 1
;;
esac
# Optional:
# Instead of the "play" command from the SoX package you
# could also use the "aplay" command from the alsa utils package.
# In case of asla the command will look like this:
# `aplay -r 22050 -f S16_LE -t raw -`
#
# I recommend "play" from the "SoX" package, because it is available
# for both macos and linux.
#
# In case of macos we can also assume that "afplay" is installed.
# make sure you have xclip installed
# use primary selection so that we can get the currently selected text
data=$(xclip -out -selection primary)
# Debugging: print the length of data
#echo "Length of data: ${#data}"
if [ ${#data} -gt 2 ]; then
# Debugging: data output
echo "Data: $data"
echo "$(date) data: $data" >> /tmp/piper.log &
echo "$data" | "$dir"/piper --model "$model" --output_raw | $echo_out
else
echo "No data available."
fi Put the script in the same folder as piper and assign a shortcut to it - I can't tell you how to assign a keyboard shortcut, since this depends on the desktop environment you are using. In my case with KDE Plasma it is under system settings -> keyboard -> shortcuts -> add new -> command or script ... That's pretty much it. Why do I recommend piper? Because it is really fast, relatively lightweight and easy to use – and at the same time the piper voices are "okay'ish", at least better than the macos built-in And I find this approach pretty good (instead a GPT4All feature) because it is not limited to one specific app. You can now let your computer speak whenever you want. Edit: typos, layout, prettify |
Beta Was this translation helpful? Give feedback.
-
how to add text to speech on GPT4ALL? To make GPT4ALL read the answers it generates
Beta Was this translation helpful? Give feedback.
All reactions