The electric doorbell, invented by Joseph Henry in 1831, remains a reliable choice for most places. Now, in Buenos Aires, a doorbell can ring up to ten times a day: six times to request clothes, twice to offer socks, and twice more to present you with garbage bags. You might ponder, “Well, perhaps I won’t answer, or better yet, I’ll disconnect the doorbell altogether.” But beware—the moment you sever that connection, the odds increase that all those lovely bronze pieces (the handles, mailbox, and the entire doorbell front cover) might vanish, or worse, your home could fall victim to a robbery.

This is the context for RinGPT.

Hardware

The doorbell switch is connected to P23, using 2 male jumpers 23 PIN and GND female, using the Unihiker cable. The middle pin is not used.

The led button is connected to P22 using a grove cable.

To pair the bluetooth speaker, just run the following commands, replacing 00:00:00:00:00:00 by the speakers Mac address. You can get the Mac address by connecting the speaker to your Smartphone and read the connection information.

bluetoothctl

default-agent

power on

trust 00:00:00:00:00:00

pair 00:00:00:00:00:00

connect F00:00:00:00:00:00

 Setup

Connect the Unihiker with a USBC cable to the computer, then load http://10.1.2.3/ to configure your WiFi Credentials. From now on you can connect with sFTP and SSH using root, dfrobot (of course, change them later)

Install these dependencies and copy all the files to /home/timbre

pip install SpeechRecognition

apt-get install flac

pip install openai

pip install edge-tts

After first execution - python timbre.py - you can use Toggle auto run execution from Unihikers Menu.

Program functions

The RinGPT doorbell operates as follows: When it detects a button press, it plays the doorbell sound. Subsequently, it activates a voice prompt asking, ‘Who is there?’ After recording the visitor’s response, it applies speech recognition to interpret the answer. The doorbell then sends a Telegram notification containing the transcribed text. Additionally, it forwards this text to chatGPT via the OpenAI API, using a specific prompt. Once chatGPT generates a reply, the doorbell converts it to voice and plays it for the visitor. The device also maintains a log file and allows you to set up custom presets. For instance, you can configure it to consistently respond with, ‘I don’t have any knives,’ whenever a sharpener rings.

OpenAI API

To make calls to chatGPT under the hood, an openAI API key is required. Sign up and more information here https://platform.openai.com/docs/api-reference/introduction

Presets

Just edit the array using keyword to spot and file name - without mp3 – In the example below: if you spot the word “cuchillo” (means knife and yes, knife sharpers also ring the bell from time to time) the answer to be played will be afilador.mp3

recon = ['Dios','medias','cuchillo','Nada']

answers = ['ateo','yacompre','afilador','nada']

Greetings

One of three random greetings will be played to start. This can be changed from the code. If you want to create your own greetings or presets, ppen generateAudio.py and edit the text and file name.

Telegram notifications

RinGPT will send you a Telegram notification with the speech transcript. You only have to enter the Bot ID and chatID. The procedure to get Telegram bot ID and chatID is explained in this project

Code settings

You can configure the voice, language, pins, openAI model and prompts using these settings.

# Settings

ttsVoice = "es-AR-TomasNeural"

btnDoorbell = Pin(Pin.P23, Pin.IN)

btnProgre = Pin(Pin.P22, Pin.IN)

chatGPTKey =""

tiempoGrabacion =5

pausaTimbre =2

model = "gpt-3.5-turbo-instruct"

temperature =0.8

prompt1 ="Estás malhumorado por muchas interrupciones y tocan la puerta para preguntar: "

prompt2 ="¿Qué respondes?"

telegramEnabled = 0

telegramBot...
Read more »