aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/readit
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-06-23 01:10:14 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-06-23 01:43:52 +0530
commit619ac1700473541a45fa1e6c9fe3a8a4693ff1f1 (patch)
treec10c3cd6e4f1cc1b2fcabdb6ad2c260decc544eb /plugins/readit
parent4d6f304204075569bec7ed39f839e51ebf728366 (diff)
downloadnnn-619ac1700473541a45fa1e6c9fe3a8a4693ff1f1.tar.gz
Add text2speech plugin
Diffstat (limited to 'plugins/readit')
-rwxr-xr-xplugins/readit30
1 files changed, 30 insertions, 0 deletions
diff --git a/plugins/readit b/plugins/readit
new file mode 100755
index 0000000..b997235
--- /dev/null
+++ b/plugins/readit
@@ -0,0 +1,30 @@
+#!/usr/bin/env sh
+
+# Description: Read a text or PDF file in British English
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+if ! [ -z "$1" ]; then
+ tmpf=`basename "$1"`
+ tmpf="${TMPDIR:-/tmp}"/"${tmpf%.*}"
+
+ if [ $(head -c 4 "$1") = "%PDF" ]; then
+ # Convert using pdftotext
+ pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' > "$tmpf".txt
+
+ pico2wave -w "$tmpf".wav -l en-GB "$(cat "$tmpf".txt | tr '\n' ' ')"
+
+ rm "$tmpf".txt
+ else
+ pico2wave -w "$tmpf".wav -l en-GB "$(cat "$1" | tr '\n' ' ')"
+ 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
+
+ rm "$tmpf".wav
+fi