I made an AI to chats with my friends without them noticing.(Part-1)
I made an AI to chats with my friends without them noticing.(Part-1)
So, the other day I was talking to one of my good friends and was having a chat with him. Then suddenly this idea came to my mind that lets make an AI that can chat with my friends and then later it can surprise them with how it actually is an AI.
So, I new what I needed to use for the conversation. Ofc GPT-3 or GPT-J I just had to chose one out the of both. I decided to use GPT-3 at the end .
Now, I needed to get a way to get the chats from whatsapp. I looked into whatsapp API. It was 👎🏻. So, I thought of an alternative.
Now we can use tesseract OCR and OpenCV on this image to get the text from WhatsApp and then this text can be prompted on GPT-3.
How will I get the chat ??
Here is how
First I will take screenshot of the specific region:
Then I will make the Image a negative:
Then I will detect words and read it with tesseract ocr and paste the text in a word file:
Now that we have the text it can be passed with GPT-3 and the answer could be sent to the chatter.
Now lets get started with the code:
First lets get the imports:
Lets take the screenshot:
Lets set up the OCR:
Lets preprocess the image and make it ready for tesseract OCR:
Lets use tesseract ocr and opencv to detect the the text:
Now lets add the detected text into a .txt file:
And thats the end of the getting the data part.
Lets clean the data and make it easy to use:
What this code basically does is that it removes the the timestamps from the the detected text.
Now the data part is over.
Lets get started with the AI part.
First lets gets the imports:
Lets set up our openAI API key:
Now lets get the prompt ready:
Now lets set up GPT-3 And fine tune it:
Lets extract the response from the variable and show it to the user:
Now lets make the reply mechanism which will basically type the response and press ente:
Now we need to delete all the text in recognized.txt file:
Now lets make a kill switch to kill the program if something wierd happens (like spamming):
And with that the code for version 1 is done woooo.
Lets see some outputs:
As you can see its spamming alot cuz its speed is very fast. So, thats what we will fix at the next part. The refinement of this AI will be done on that article for now the message reading AI is working and the response is being given.
Thanks for reading. Follow me on medium if you liked the article.
For the code go here:
For my day to day AIML updates go here:
Thanks for reading 😁, See ya guys next week👋🏼.