2019-06-22 19:40:14 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
# Description: Read a text or PDF file in British English
|
|
|
|
#
|
|
|
|
# Shell: POSIX compliant
|
|
|
|
# Author: Arun Prakash Jana
|
|
|
|
|
2020-11-22 14:39:14 +00:00
|
|
|
if [ -n "$1" ]; then
|
2019-11-21 20:44:25 +00:00
|
|
|
tmpf="$(basename "$1")"
|
2019-06-22 19:40:14 +00:00
|
|
|
tmpf="${TMPDIR:-/tmp}"/"${tmpf%.*}"
|
|
|
|
|
2019-11-21 20:44:25 +00:00
|
|
|
if [ "$(head -c 4 "$1")" = "%PDF" ]; then
|
2019-06-22 19:40:14 +00:00
|
|
|
# Convert using pdftotext
|
|
|
|
pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' > "$tmpf".txt
|
|
|
|
|
2019-11-20 19:01:39 +00:00
|
|
|
pico2wave -w "$tmpf".wav -l en-GB "$(tr '\n' ' ' < "$tmpf".txt)"
|
2019-06-22 19:40:14 +00:00
|
|
|
|
2024-02-13 13:32:42 +00:00
|
|
|
rm -- "$tmpf".txt
|
2019-06-22 19:40:14 +00:00
|
|
|
else
|
2019-11-20 19:01:39 +00:00
|
|
|
pico2wave -w "$tmpf".wav -l en-GB "$(tr '\n' ' ' < "$1")"
|
2019-06-22 19:40:14 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# to jump around and note the time
|
|
|
|
mpv "$tmpf".wav
|
|
|
|
|
|
|
|
# flat read but better quality
|
|
|
|
# play -qV0 "$tmpf".wav treble 2 gain -l 2
|
|
|
|
|
2024-02-13 13:32:42 +00:00
|
|
|
rm -- "$tmpf".wav
|
2019-06-22 19:40:14 +00:00
|
|
|
fi
|