Repository navigation
Expand file tree
/
Copy pathpitextreader.py
More file actions
executable file
·82 lines (64 loc) · 1.72 KB
/
Copy pathpitextreader.py
File metadata and controls
executable file
·82 lines (64 loc) · 1.72 KB
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
#!/usr/bin/python
#
# PiTextReader - Raspberry Pi Printed Text-to-Speech Reader
#
# Allows sight impaired person to have printed text read using
# OCR and text-to-speech.
#
# Normally run by pi crontab at bootup
# Turn off by commenting out @reboot... using $ crontab -e; sudo reboot
# Manually run using $ python pitextreader.py
#
# This is a simplistic (i.e. not pretty) python program
# Just runs cmd-line pgms raspistill, tesseract-ocr, flite to do all the work
#
# Version 1.0 2018.02.10 - initial release - rgrokett
# v1.1 - added some text cleanup to improve reading
# v1.2 - removed tabs
#
# http://kd.grokett.com/
#
# License: GPLv3, see: www.gnu.org/licenses/gpl-3.0.html
#
import time
import sys
from logger import logger
from app import App
import RPi.GPIO as GPIO
from gpiozero import Button
from constantes import SOUNDS
# We need to keep button object on scope so
# that they are not garbage collected
buttons = []
def init_gpio(app):
"""
Link GPIO pins and callback according to app.associations
"""
for i in range(len(app.associations)):
pin = app.associations[i][0]
callback = app.associations[i][1]
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
logger.info("Bouton gpio %d" % (pin))
button = Button(pin)
button.when_pressed = callback
buttons.append(button)
######
# MAIN
######
try:
app = App()
app.settings.set_volume_help()
app.leds.light(0)
GPIO.setmode(GPIO.BCM)
init_gpio(app)
time.sleep(2)
app.player.play(SOUNDS + 'ready')
# speak("OK, on est pret")
# app.leds.set(1)
while True:
time.sleep(10)
# end while
except KeyboardInterrupt:
logger.info("exiting")
app.close()
sys.exit(0)