sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

pdfread (731B)


      1 #!/usr/bin/env sh
      2 
      3 # Description: Read a text or PDF file in British English
      4 #
      5 # Shell: POSIX compliant
      6 # Author: Arun Prakash Jana
      7 
      8 if [ -n "$1" ]; then
      9     tmpf="$(basename "$1")"
     10     tmpf="${TMPDIR:-/tmp}"/"${tmpf%.*}"
     11 
     12     if [ "$(head -c 4 "$1")" = "%PDF" ]; then
     13         # Convert using pdftotext
     14         pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' > "$tmpf".txt
     15 
     16         pico2wave -w "$tmpf".wav -l en-GB "$(tr '\n' ' ' < "$tmpf".txt)"
     17 
     18         rm "$tmpf".txt
     19     else
     20         pico2wave -w "$tmpf".wav -l en-GB "$(tr '\n' ' ' < "$1")"
     21     fi
     22 
     23     # to jump around and note the time
     24     mpv "$tmpf".wav
     25 
     26     # flat read but better quality
     27     # play -qV0 "$tmpf".wav treble 2 gain -l 2
     28 
     29     rm "$tmpf".wav
     30 fi