Inspiration

DadBot was originally a Python script I made with a peer I met through the KnightHacks mentorship program. We decided to make a Discord Bot as a fun personal project and it ended up being one of my favorite concepts for a programming project this year. I had a lot of fun coming up with feature ideas and navigating their implementation. I knew I had to push the ideas further with my newfound technical skills for this year's hackathon.

What it does

NOTE: I didn't clarify in the demo, but the responses are randomly generated, not static, so you can run through the commands as many times as you want an expect a different response each time. (Data is randomly pulled from APIs and responses to commands should be different each time.)

DadBot was created as an an interactive bot that reflects the personality of a typical dad. For me, that meant it tells the user infamously bad dad jokes, it can tell you what the weather is going to look like, and it can give you life advice in the form of inspirational quotes.

DadBot 2.0 pushes the medium from a Discord chat to real-time speech recognition and text-to-speech feedback. The user can simply speak commands using keywords or phrases and have DadBot 2.0 respond via text-to-speech.

To add more personality to the project, I reflected on some of my favorite iconic dads from pop culture. These characters range anywhere from Homer Simpson to Darth Vader, and users can choose who takes center stage as they interact with DadBot.

How I built it

I picked Python to leverage its compatibility with several APIs and frameworks, as well as using an object-oriented design. I created separate classes for DadBot as well as a class (SpeechHandler) that acted as an interface for all the speech-recognition & text-to-speech features. For the GUI, I used QT designer to help customize and personalize my GUI.

The first step was revamping the original DadBot program to OOP. Basically, I started from scratch, referencing the original for certain API calls and algorithm ideas. Most of the code was abstracted so that functions only had a single given purpose, which contributed to the cleanliness of the code.

The second step was to create the SpeechHandler that could help send userInput (speech) as strings to the DadBot that could produce a response, as well as converting the output (text) from DadBot back to text-to-speech audio. This was done using popular Python libraries speech-recognition (which acts as a wrapper for many different speech-recognition engines) and pytts, which is a popular text-to-speech engine library for Python.

The final step was to implement a GUI. For Python, I usually use the tk framework but since I wanted to focus on the aesthetic aspect, I opted for PyQt instead. I first went to my whiteboard and made a rough draft of how I wanted the GUI to look. I then created the GUI elements using an image editor known as Canva. Then, in Qt Designer, I created the GUI using the elements I made. The final step was to convert the Qt Designer (.ui) file to Python code using Pyuic5. From there, I could create event handlers for button clicks on my GUI by working in the Python code.

Challenges I ran into

One of the most interesting challenges with this project was redesigning DadBot's code to work better with the SpeechHandler class. Naturally, a Discord Bot cannot function exactly the same as an interactive speech-recognition bot. I had to change some of the code that detected keywords to better suit the speech-recognition engine, since when I was testing it, it could not recognize a few of the original keyword commands from the first project. On the text-to-speech end, some of the lines didn't sound right when DadBot produced audio for them, so I had to rewrite them, as well as manually make some tweaks to the rate of speech and volume.

Accomplishments that I'm proud of

One accomplishment I'm very proud of is the way the GUI turned out. GUI design and aesthetics were always a struggle for me in my OOP class last summer, so I definitely put a focus on user design and visuals for this project.

I am also really glad I got to explore this project further on my own time and sticking with a concept I was interested in for a long time. The goal of the project this year was to create an experience similar to popular smart assistants such as Siri, Cortana, and Alexa, and I feel like I emulated that in a lot of ways.

What I learned

Some of my major takeaways from this project are

1) Don't try to mix programming languages

2) Design your project before coding

3) Focusing on user experience and GUI design is equally important as backend

4) How OOP works in Python

5) Iteratively using version control (Git & Github) to keep track of changes

What's next for DadBot 2.0

Some feature ideas I hope to implement in the future:

1) DadBot remembering names/nicknames

2) Specific commands and voices for characters

3) Custom jokes that I choose rather than random ones from APIs

4) Animated GUI elements

5) OS integration (activation from idle state)

Built With

  • dadjokes
  • git/github
  • pip
  • playsound
  • pyowm
  • pyqt
  • python
  • pyttsx3
  • qt
  • requests
  • speech-recognition
Share this project:

Updates

posted an update

NOTE: I didn't clarify in the demo, but the responses are randomly generated, not static, so you can run through the commands as many times as you want an expect a different response each time. (Data is randomly pulled from APIs and responses to commands should be different each time.)

Log in or sign up for Devpost to join the conversation.