-
Notifications
You must be signed in to change notification settings - Fork 1
/
ScreenReader
executable file
·86 lines (72 loc) · 2 KB
/
ScreenReader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#Développeurs : Paullux, U_Bren
# create work folder
workDir="/tmp/OCR"
[ ! -d "$workDir" ] && mkdir "$workDir"
# Initialisation des variables
unset MOUSE
unset CURRENT_WINDOW
unset SELECTION
MOUSE=false
CURRENT_WINDOW=false
SELECTION=false
#Options choice
case $1 in
-m)
MOUSE=true;;
-w)
CURRENT_WINDOW=true;;
-s)
SELECTION=true;;
*)
#Quit if non choice
a="Vous devez préciser une option valable"
/etc/alternatives/tts "$a"
exit 0;;
esac
#Make screenshots
if $MOUSE; then
#Offset the screenshot rectangle to the upper-left corner (0,1) by this amount in the X/Y direction
#Might be a problem for i18n & RTL languages but... Oh, well
NegX01Offset=128
NegY01Offset=50
#Size of the rectangle
posX10=256
posY10=100
#Set X,Y to the Cursor position.
eval $(xdotool getmouselocation --shell)
posX01=$(($X-$NegX01Offset))
posY01=$(($Y-$NegY01Offset))
#Drawing Rectangle (real draw)
lemonbar -n my_lemonbar -d -g "$posX10"x"$posY10"+"$posX01"+"$posY01" -B '#88ff0000' &
#To take screenShot
scrot -a "$posX01","$posY01","$posX10","$posY10" -o "$workDir"/OCR.png
fi
if $CURRENT_WINDOW; then
# To prepare the commande
a="La fenêtre courante est"
b=$(cat /proc/"$(xdotool getwindowpid $(xdotool getactivewindow))"/comm)
c="La fenêtre courante contient"
d="${a} ${b} ${c}"
/etc/alternatives/tts "$d"
#ScreenShot
scrot -u -o "$workDir"/OCR.png
fi
if $SELECTION; then
#To prepare the commande
/etc/alternatives/tts "sélectionnez la zone à lire"
#ScreenShot
import "$workDir"/OCR.png
fi
#Déchiffrement de la capture par OCR
tesseract "$workDir"/OCR.png "$workDir"/text -l fra
#Lecture du texte déchiffrer par OCR grâce au TTS
/etc/alternatives/tts "$(cat "$workDir"/text.txt)"
#kill rectangle
sleep 3
if $MOUSE; then
kill $(pgrep -f "lemonbar -n my_lemonbar")
kill $(pgrep -f "lemonbar -n my_lemonbar")
fi
#delete work folder
rm -rf "$workDir"