icon

MarioAI, the personal Italian assistant that follows you

The goal of this project is to create an AI Assistant that follows a face by rotating.
MarioAI was born from the combination of different technologies. The heart of the project is the Unihiker hardware. A perfect board which, thanks to its display and connectivity, made this project feasible. The mind is represented by Google's Gemini API which allows you to quickly obtain answers. The eyes are represented by a USB Camera located at the top of the project.

HARDWARE LIST
1 UNIHIKER - IoT Python Single Board Computer with Touchscreen
1 Bluetooth Speaker
1 USB Camera
1 DC Motor
1 DC Driver motor L298N
1 USB Type-C cable
1 Wooden plank 14x6 cm
5 Screws
1 Converter Module 12V to 5V
4 Jumper
1 12 V Jumper
STEP 1
Connect the Hardware

Fix the l298n module on the wooden board together with the DC Motor. Connect the two ends of the motor to Input A of the control module.
 


Then connect the UNIHIKER board to the motor.

 

 

Connect PIN 23 and 24 respectively to INT 1 AND INT 2 of the L298N

 

Connect and secure (I used cable ties but you can use anything) the USB Camera to the UNIHIKER Board.
 


Finally connect the UNIHIKER power supply with the USB type-C to the 12v to 5v converter. Also connect the 12V +/- outputs to the L298N power supply.
 

 


Connect your Bluetooth Speaker to UNIHIKER link

 

Perfect, your structure is now complete

STEP 2
The Code

The code I have provided in the RAR archive is composed of various structures.

 

main.py
 In this code, the respective code for face tracking and the code for AI technology are started separately

 

face_recognition.py 
 Within this part of code the UNIHIKER board connects via USB to the camera using opencv. It uses a face recognition system thanks to the haarcascade_frontalface_default.xml cascade which allows you to quickly identify and track a face. It then uses a control to identify when the face moves either left or right and moves accordingly. The movement is generated by the control of the L298N. The Pins used are 23 and 24 which are declared as OUTPUT at the beginning of the code. Subsequently you will find the various functions that allow the motor to move clockwise or anti-clockwise. These functions are obtained thanks to the combination of digitalWrite. In fact, when Pin 23 is on HIGH while Pin 24 is on LOW, the motor moves clockwise if they are reversed counterclockwise. Finally, if the two PINs have the same LOW/HIGH value, the motor remains stopped. Thanks to these combinations the DC motor moves by tracing the face by moving it approximately 1* at a time.

ai.py 

This part of code represents the brain of our Assistant. First of all, the system requires an API_KEY for gemini which can be obtained by following this link .
It then connects to whisper's hugginface (OpenAI) to perform real-time transcription of user requests.  Subsequently, in a while loop, thanks to the microphone pre-inserted in the UNIHIKER card, it detects the activation word (Mario) and begins recording the wav file which will then be transcribed. Recording stops automatically when it no longer detects sound. The output obtained from whisper is passed to Gemini which processes it producing a result which is synthesized using gtts. This library allows you to perform Text-to-Speech in various languages ​​with different accents (I chose the Italian one). Subsequently the audio output is reproduced thanks to the connection with the Bluetooth Speaker. The system is then decorated with a gif present in the RAR archive which allows you to understand when MarioAI is listening.

STEP 3
Libraries

To make the code work you need to install several libraries:

CODE
pip install opencv
pip install google-generativeai
pip install gTTS
pip install gradio-client
pip install unihiker
STEP 4
The END

Connect to the UNIHIKER board via ssh
root@IP_UNIHIKER
password: dfrobot.

Once connected, move to the MarioAI folder and start with python3 main.py

Now have fun with your Italian AI Assistant.
 

 

Of course you can talk to him in English or in all the languages ​​supported by Gemini. The code is versatile and can be modified by changing the activation word and of course adding expressions. Try to customize it and have fun with MarioAI

icon MarioAI.zip 1.33MB Download(0)
License
All Rights
Reserved
licensBg
0