icon

Unihiker chattering teeth optimistic news reader with ChatGPT

0 13608 Medium

This UNIHIKER - a tiny Debian Linux board with integrated touch screen - was programmed to get the latest news headlines via RSS feeds. 

 

Before speaking, OpenAI ChatGPT API rewrites the headlines, but with a twist. ChatGPT is told to rewrite them with a happy, optimistic tone. The response is then fed into Google Translate's text-to-speech API that generates an audio file. The audio file is then played with the help of a Bluetooth speaker. As the audio file is played back, an SG90 servo motor moves a set of plastic chattering teeth to open and close it as if it were reading the headlines for comedic effect.

 

Parts required

 

    DFRobot Unihiker SBC 

SG90 Servo 
   • Bluetooth speaker 
   • Optional 3d servo support 
   • Chattering teeth 

 

And some male-male jumper cables.

 

 

Software configuration

 

Connect the Unihiker with a USBC cable to the PC. 
Load 10.1.2.3 in the browser


Configure your WiFi SSID and password and obtain the IP of the Unihiker
 

Now open Putty or some other SSH client and connect to the Unihiker with the IP, user root and password dfrobot

 

Run the following:
 

pip install reader
pip install openai
pip install gTTS 
pip3 install simpleaudio

 

Go to https://platform.openai.com/ and sign up for the API. There is a free credit enough for several months of this project. Go to https://platform.openai.com/account/api-keys and create a new secret key.

 

Open Yrigoyen.ino code and enter your OpenAI API key.

openai.api_key = ""

 

You can edit the OpenAI model:

model_to_use ="text-davinci-003"

 

The prompt:

prompt  = "Rewrite this news headline with a joyful and optimistic tone:"

 

The RSS source:

feed_url  = "https://www.cbsnews.com/latest/rss/main"

 

Now connect with Filezilla/ SFTP or any other FTP client using the same IP, user and password as with the SSH client.

 

Upload yrigoyen_en.py and background.png to /home folder.

 

Turn on the Bluetooth speaker.

 

Run the following:
 

bluetoothctl
default-agent
power on
scan on
pair
trust xx:xx:xx:xx:xx:xx (Device MAC ID)
pair xx:xx:xx:xx:xx:xx  (Device ID)
connect xx:xx:xx:xx:xx:xx (Device ID)

 

You only have to do BlueTooth pairing once. Then it will reconnect automatically.

 

 

Hardware configuration


Gpio ports can be accessed using one of the cables provided. Connect the cable to D22 pin on the side of the Unihiker. Connect 3 male to male jumper cables to the Servo respecting the +, - and signal.

 

Download and print the servo base.

 

Remove all the inner parts of the jaw and glue the servo arm to the side.

 

Software

 

Download the Python code from https://github.com/ronibandini/yrigoyen 

 

 


 

How does it work

 


 

Everything should be ready now. Go back to the SSH client and run:


 

/home python yrigoyen_en.py

 

License
All Rights
Reserved
licensBg
0