Hello DIYrs, have there been instances when you really wanted to share your feelings with someone and no trusted one was around? In today’s busy world, this is a common instance. Well, a chatbot can help here to make you feel better. And that leads to the introduction of Eve.
Eve is a cute little chatbot. Well as everyone knows, a chatterbot or chatbot is a computer program or device that conducts a conversation with humans based on textual or auditory methods. The automated voices you hear on a customer service call, or on a bank line is an example of a chatbot.
With her, You can share your experiences, your feelings and most importantly, argue about different things; she is well-experienced at it. Because that’s the most important function of a chatbot, make the person feel happy.
An early example of Natural Language Processing (NLU) and Artificial intelligence, Eve is capable of answering ANY question you ask her. It is not that She can answer just a specific number of questions. She can sing, tell you jokes, stories and do anything that makes you feel good.
If She says something you do not wish to hear, just tell her, please don’t say that again, and she will remember that. She even knows that she should not repeat the same answers and chats, so that the conversation does not become boring.
Based upon simple, cheap components and basic programming, she can behave smart to a really great extent. Further the LCD eyes that she possess show how she feels when you say anything.
So basically in this instructable, we shall start from the definition of a chatbot, look into the design, some theories based on which Eve runs, the manufacturing and finally the programming part.
Looks much does it? Don’t worry, it shall be quite interesting in the journey.
You can view the demo of the robot above, or in this link:
Step 1: Definition of a Chatbot
As mentioned above, chatbots are based upon either textual or auditory method and hence can be divided into two. In the textual method conversations are in the form of written text just as WhatsApp. Whereas in the auditory method, conversations are done orally as with a real human.
I guess it is more exciting to converse with someone by verbally speaking to him instead of just texting him. No doubt text based communication messaging apps meet the people’s requirements, but I feel that chatting by speaking is the best thing to get rid of your emotional disturbances and make you feel better. So that’s the main reason I designed Eve to be an auditory chatbot.
Step 2: Origin of Eve
Eve disappointed me about a hundred times. Guess it was the 101th time she worked and made me feel really happy.
So that was the origin of Eve. I wanted her to be intelligent but as simple as possible, so that anyone can make her easily. No doubt she is not absolutely smart and sometimes say stupid answers, she can behave as a friend.
And now, enough stories, let’s start building Eve.
Step 3: Gathering the Components and Equipments:
Arduino Pro Mini (Or Arduino Nano)
Wtv-020-SD-16p sound module
HC-05 bluetooth module
16×2 LCD module
LM7805 regulator IC
An amplifier module (I used the PAM8403 circuit)
An 8 ohm speaker
A female audio jack
a 9v battery
And an Android phone
So these are the required components. Another important thing, the cost. Eve cost me around 3000 INR. The cost might be different in your country but in India, this approx is the rate.
A Little description of the parts:
The Arduino Pro mini is the main MCU in our robot. I used it because of its small size, simplicity and excellent performance. It meets all the requirements in our robot. Except for the voice recognition function which is done by the Android (discussed later), every other functionality starting from the keyword finding and output formation are done on the Pro Mini itself. Don’t worry for the terms mentioned above if you don’t understand it, all are discussed in the later part.
The wtv020sd 16p module is used for playing the audio files, hc 05 Bluetooth for communication with the Android and the LCD for displaying the emotions. We need the female audio jack the provision of connecting the robot to an external amplifier.
The Arduino is used as the main controller here. It receives Bluetooth data through the HC 05 Bluetooth module and plays the file through the WTV-020-SD-16p voice module. The emotions are displayed in the LCD module and a 9v battery for the power. Eve recognises speeches through the Google Voice recognition of the Android device. It is later discussed properly in the respective step.
A bad news about the Arduino Pro Mini:
IT has RETIRED from the market. Well that means that it has been officially stopped being manufactured by Arduino. But you can still find it in many sites including Ebay. Many third party manufacturers still might be making and selling the board. Don’t worry if you weren’t able to find one, you can use the Arduino Nano. It shall make no difference in the performance and also in the size.
Step 4: Theory Part 1: History and Introduction.
It works in the following way that when a string is received, it searches for a predefined word or phrase in that string. Suppose in the question ” how old are you? ” the program searches for “old” word. If it succeeds then it plays the respective voice file through the wtv020sd module. If it fails then it searches for the next predefined keyword.
Like this we need to build up a vocabulary of predefined words. Looks tough, doesn’t it? It is as though we need to build up a vocabulary of all English words and there are around 230 thousand overall words in the English language. Well the fact is that we just need to add a few basic words that are most commonly used in our communication. Still looks tough? Don’t worry, the work has already been done by Joseph Wizembaum.
A part of Eve’s responses and predefined keywords have been incorporated from the very first chatterbot program called Eliza, developed by Joseph Wizembaum (pictured above). Eliza was designed to be a Rogerian Therapist. Not a highly scientific term, it means that she used to counsel people, making them understand themselves better and make them think more positive. Looks really good right? And Eliza was very well able to perform her duty. Her curious and sceptical attitude was loved by people. Even Wizembaum was surprised by the importance people gave Eliza. They seemed to forget that they were talking to a computer, and fancied a beautiful lady sitting inside the computer chatting with them.
But Eliza was not that smart; it came to be realised soon . By the passing of time, people started getting bored of her limited communication and she was termed as “dumb”.
No wonder how dumb she was, it was a great leap in the history of Artificial Intelligence and natural language processing . Having founded the base of Chatterbots, different bots with new and better technology came into the market. And now we have them everywhere.
As mentioned, a part of Eve’s responses have been derived from ELIZA. So that means that even Eve shall posses the attitude of Eliza to some extent along with some of my own ideas.
Another important thing is the replies . It should be really boring to get the same replies every time you ask the same question. Therfore many replies are stored for the same keyword. Eve randomly chooses which file to play, also making sure she does not repeat the same file. That’s it, simple bread and butter, but it is important to cleverly program the responding voices, so that it gives an illusion to the viewers as if she is really answering our questions.
So that was a brief introduction to the functioning of Eve. In the next step we shall get this in into detail and programming.
Step 5: Searching for the Keyword
So think of it, someone asks your name and you need to tell what it is. In how many ways can we ask the same question? Your teacher may ask “would you please tell me your name?” A relative may ask, “what is your name?” Your brother may say, “Hey, I just forgot your name. Will you say it just one more time?”
So that means the same question can be asked in several ways. Yet we need to give the same answer, our name. So that means that we need to find something common in all the sentences. It is clearly seen that the word, “your name” is present in all the sentences. So that’s our hint. For all the questions asking the name, we need to search for the phrase “your name”. By following this basic pattern we can predict the respective answer to all the input strings.
Also important to remember that this algorithm will not always be accurate. Suppose someone said, “I found your name in the waiting list. I expected you to be in the reserved seats.”.
Now since “your name” is present in this string, Eve, being innocent will tell her name to the person… Foolish right? This is one of the big demerits of this basic algorithm. Anyway, these would be rare cases. Otherwise the algorithm is very effective.
Now that I have mentioned about the pattern matching technology, it is time to think where does this input string comes from where we search for the string.
Well this string is actually our voice that has been converted to text by Google Voice Recognition. The app used here converts our voice to text and then sends the same to the arduino through the Bluetooth.
I used the app because it is the simplest and the best of its kind. The name is AMR Voice, and can be found easily in Google play.
Step 6: Formulating the Answers
We need to find appropriate answers to satisfy every question. And here comes another function incorporated from ELIZA. Wizembaum developed some answers for a specific number of keywords. An example is of the keyword “you”. Whenever it was detected the program output ” we were discussing you – not me.” Hence the answer was made in such a way that it suits all the sentences containing “you”.
Further Eliza gave a different answer every time. There was a kind of numerical address for each answer which. This was incremented (added by 1) every time an answer was formulated. Suppose as in the above example, if the address of the answer was 1, the address was changed to 2 and the hence file 2 was played next.
But we won’t be following this incrementation algorithm. You see after some continuous use of the software, the answers became predictable. You came to knew which answer is to be given next.
So for this purpose we will be producing random addresses for each keyword. Overall it is the same in both the cases, just the difference that we can’t predict what the robot will say next for the same keyword.
Step 7: The Prohibited Statements and Others
The prohibited statements are an array of addresses that are prevented from being played. A voice address is characterised as a prohibited statement upon the asking of the user. Further this address shall be stored in the EEPROM of the Arduino so that Eve does not forget that it is a prohibited statement even after she is switched Off.
Basically what the program does is to check every address that is to be played. If the address is one of the prohibited ones, then it is either incremented or decremented.
Read more: Eve, the Arduino Chatbot