Skip to content

Commit

Permalink
text synthesis added
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrithemaker committed Mar 7, 2020
1 parent 0de4899 commit fab2042
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -18,6 +18,8 @@ To build this device you need:

- Telegram app

- Optional: speaker

## Basic building instructions

- Install raspbian distro, with Python3 and Telepot and PiCamera modules using pip3 or apt
Expand All @@ -26,6 +28,8 @@ To build this device you need:

- Install PiCam and PIR Sensor (Passive InfraRed presence sensor) hardware on your Raspberry Pi

- Install espeak (sudo apt-get install espeak)

- Check if all is working separately

- Set the python script telegram key and chat id from BotFather telegram data
Expand All @@ -45,3 +49,5 @@ To build this device you need:
- **disable pir**: if PIR sensor is disabled, never takes a picture automatically (when you are at home, PIR sensor must be disabled to avoid a picture flood)

- **show**: take a real-time picture and send it to the telegram bot channel

- **say TEXT** : read the TEXT string through the speaker
9 changes: 7 additions & 2 deletions intruder-detector.py
Expand Up @@ -3,6 +3,7 @@
import telepot
from picamera import PiCamera
import RPi.GPIO as GPIO
import subprocess

camera = PiCamera()
camera.rotation = 180
Expand All @@ -16,7 +17,7 @@
def handle(msg):
global enabled
global intruder

command = msg['text']
from_id = msg['from']['id']
#chat_id = msg['chat']['id']
Expand All @@ -35,7 +36,11 @@ def handle(msg):
bot.sendMessage(chat_id,text="PIR enabled")
if command.lower() == "disable pir":
enabled = False
bot.sendMessage(chat_id,text="PIR disabled")
bot.sendMessage(chat_id,text="PIR disabled"
if command.lower().split(' ')[0]=='say':
# not using the espeak python module due to raspberry pi and alsa compatibility problems
command = "espeak -ves \""+command[3:]+"\" --stdout|aplay" # remove or change -ves (spanish text) option to change the language
process = subprocess.Popen(command,shell=True, executable='/bin/bash')
else:
bot.sendMessage(from_id,text="I'm not allowed to talk with you, sorry")
bot.sendMessage(chat_id,text="Somebody is trying to use the chatbot")
Expand Down

0 comments on commit fab2042

Please sign in to comment.