Inspiration

When we were first brainstorming ideas, one idea that came up was a program that recommends music based on your facial expression, using machine learning to recognize the emotion on your face. None of us knew how we would implement this, so we decided to do something that would analyze the sentiment of your text instead. Because we were using Discord as part of the hackathon, we came up with the idea of coding a Discord bot that would analyze the mood of the server based on the messages that were being sent.

What it does

Daybreak keeps a log of the latest messages sent in the Discord server and automatically streams music through a voice channel based on the primary sentiment detected in these messages.

How we built it

Using the library discord.py, we programmed this Discord bot using Python. We also used IBM Watson's Tone Analyzer AI to read the sentiments in the Discord messages. To play music, our bot downloads songs from Youtube and streams them through the voice channel using Python's library youtube-dl. We created our own "playlists" of Youtube links to play depending on the sentiment of the channel—for instance, we'd play happy music when the bot detected joy, we'd play intense music when the bot detected anger, and we'd play soothing music when the bot detected fear. We deployed the bot onto Heroku so that the bot would run continuously.

Challenges we ran into

We had difficulties collaborating on the code at first, since repl.it didn’t support some of the libraries we were trying to use. We compromised by collaborating on the repl.it link for whatever did work on repl, and working offline on the parts that used libraries that repl didn’t support (like ffmpeg, which allowed the bot to play the music).

Accomplishments that we’re proud of

  • Creating a bot that runs smoothly and continuously
  • Being able to stream music through the voice channel with relatively high quality and no crashing (it used to crash every time we streamed music)

What we learned

  • How Discord bots work
  • How to code a Discord bot in Python using discord.py
  • How to get the Discord bot to join/create channels, send messages and embeds, and stream music
  • How to download music as mp3 from Youtube using youtube-dl
  • How to deploy a bot to Heroku

What's next for Daybreak

  • Allowing the bot to pull music from anywhere online instead of from our own playlist, perhaps using the Genius.com API or Spotify API to get songs based on rhythm or lyrics to match the mood
  • Adding commands to stop the music or skip songs

Built With

Share this project:

Updates