Tools
GNU Readline, rlwrap, cat, espeak.
E - the program
There is espeak.
espeak - A multi-lingual software speech synthesizer.
It is very simple to use in the terminal and scripts:
echo "hello world" | espeak -v en
In order to make use of the clipboard, cat should be sufficient.
cat | espeak -v mb-en1 # uses mbriola voice to speak pasted lines
Next, rlwrap makes cat
support command line editing using GNU Readline library.
This also supports storing and cycling through input history, just like in an interactive shell.
rlwrap cat
Putting it all together we get a REPL for espeak
. A simple alias (fixed language):
alias E='rlwrap -H ~/.espeak.history.en.txt cat | espeak -v en'
espeak is a multi-lingual software, so it feels mandatory for the solution
to support the language argument, at the very least.
I use it for Greek, thus the default is 'el'.
Full script follows:
#!/bin/sh
# Copyleft: CodeASAP.pl
# LICENSE: CC BY-SA 4.0
#
# E - espeaks what cat says
set -eu
# Program options
Language=${1:-el}
echo "#" $Language $(date -R)
echo
# Program
rlwrap -H ~/.espeak.history.$Language.txt cat | egrep -v '^#' --line-buffered | espeak -v $Language
A little egrep -v '^#'
is used between cat
and espeak
to filter out "comments" (lines starting with a '#').
The --line-buffered
switch makes grep output text on line by line basis, otherwise it would run
once cat
receives EOF (^D).
Result:
It doesn't sound human, but it has wonderful UX.
Video
Video: MP4, 1.7M, 1920x1080. Duration: 00:01:47 Link