Reading aloud content of clipboard. espeak fro clipboard under Linux / X (should work under other unixes , if required change `xclip` to something else )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# e.g. -s 300 to read faster : | |
# read_clipboard_espeak.sh -s 300 | |
# espeak has other parameters too, check man espeak-ng | |
#TTSCMD=espeak | |
TTSCMD=espeak-ng | |
if [ -z "$1" ]; then | |
xclip -selection clipboard -o | "$TTSCMD" -ven | |
elif [ "$1" == "code" ]; then | |
shift 1 | |
xclip -selection clipboard -o | "$TTSCMD" -ven --punct "$@" | |
else | |
xclip -selection clipboard -o | "$TTSCMD" "$@" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# this one checks clipboard in a loop and reads in case of changes. Try to detect URLs and not to read them. | |
# e.g. -s 300 to read faster : | |
# read_clipboard_espeak_in_loop.sh -s 300 | |
# espeak has other parameters too, check man espeak-ng | |
#TTSCMD=espeak | |
TTSCMD=espeak-ng | |
TTSargs=("-ven") | |
if [ "$1" == "code" ]; then | |
shift 1 | |
TTSargs=("-ven" "--punct") | |
fi | |
prev="" | |
while [ 1 ]; do | |
curr="$(xclip -selection clipboard -o)" | |
if [[ "$curr" != "$prev" ]]; then | |
if [[ ! "$curr" =~ ^http ]]; then | |
echo READING: "$curr" | |
#set -x | |
echo "$curr" | "$TTSCMD" ${TTSargs[*]} "$@" | |
#set +x | |
else | |
echo IGNORING DUE TO "http" prefix: $curr | |
fi | |
fi | |
prev="$curr" | |
sleep 0.25 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment