One of the things I’ve greatly missed, since switching my home machines to Linux, was the program NaturalReader. It sounded fairly realistic and had decent integration with the OS. And it was the program that got me thru college.

Needing to do more reading than normal, I started to see what sorts of options there are for ArchLinux. I’ve dabbled with things like Orca before, but it was too heavy and didn’t do the one thing I wanted, which was the ability to highlight the text and have the computer read it to me. So I decided to roll my own.

UPDATE: I’ve switched to Mimic, https://github.com/MycroftAI/mimic, and a voice provided by http://www.festvox.org/flite/packed/flite-2.0/voices/cmu_us_slt.flitevox.

This combination is fairly quick and fast; though I have had issues where the first several words are not coming out of the speakers of an Intel based laptop.

This hack, as it were also feeds into another interest of my, which is keeping track of what I read for future data mining. Below is the bash script I use:

Lang: bash
#!/bin/bash

# wget http://www.festvox.org/flite/packed/flite-2.0/voices/cmu_us_slt.flitevox
LOCKFILE="/tmp/mimic-lock"
if [ ! -f "${LOCKFILE}" ];then
  touch "${LOCKFILE}"
else
  pkill mimic
  exit 0
fi
DATE=$(date +"%Y%m%d")
TIME=$(date +"%Y-%m-%d %H:%M:%S")
FILE="$HOME/nextcloud/Documents/read/${DATE}.txt"
DUR="0.55"
#DUR="1.0"
echo '####################################################################' >> ${FILE}
echo "################### $(date +"%Y-%m-%d %H:%M:%S")  DUR ${DUR} ###################" >> ${FILE}
TEXT="$(xclip -o )"
TEXTSHA="$(echo ${TEXT} | sha256sum -)"
echo "# ${TEXTSHA/ -/}#" >> ${FILE}
echo ${TEXT}
echo '####################################################################' >> ${FILE}
mimic -pw --setf duration_stretch=${DUR} -t "${TEXT}" -voice ~/cmu_us_slt.flitevox >> ${FILE}
echo '####################################################################' >> ${FILE}
      ####################### 2016-08-16 14:26:42 #######################
echo "####################### $(date +"%Y-%m-%d %H:%M:%S") ########################" >> ${FILE}
echo '####################################################################' >> ${FILE}
echo '' >> ${FILE}
rm "${LOCKFILE}"

I took a look at 2 programs espeak and festival. Once setup they are both passable and can work, but what about the easy shortcut do I didn’t have to context switch. Using the GNOME keyboard shortcut window I mad a special command that would run a custom script. The command is Alt+Shift+@

The script

Lang: bash
#!/bin/bash

#pgrep espeak && pkill espeak || xclip -o | espeak -v female1
xclip -o | festival --tts

So far I’m not sure which I like better and further usage and tweaking will be needed.