aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/pdfread
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-11-22 17:51:13 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-11-22 17:51:13 +0530
commit594d645e259083b217518ef0507edfe5395711af (patch)
tree531fcf59d50287011797fd3179258379b0376622 /plugins/pdfread
parent085bda03305ffd5cb502743a06ac6b2513b7234e (diff)
downloadnnn-594d645e259083b217518ef0507edfe5395711af.tar.gz
Rename plugins, group related ones
Diffstat (limited to 'plugins/pdfread')
-rwxr-xr-xplugins/pdfread30
1 files changed, 30 insertions, 0 deletions
diff --git a/plugins/pdfread b/plugins/pdfread
new file mode 100755
index 0000000..4f47992
--- /dev/null
+++ b/plugins/pdfread
@@ -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 "$(tr '\n' ' ' < "$tmpf".txt)"
+
+ rm "$tmpf".txt
+ else
+ pico2wave -w "$tmpf".wav -l en-GB "$(tr '\n' ' ' < "$1")"
+ 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