Code Monkey home page Code Monkey logo

musicbot's Introduction

MusicBot

A Telegram chatbot for recommending music based on Spotify using spaCy created by Timo van Niedek.


Introduction

MusicBot uses the Telegram bot API to create an interactive interface for requesting artist names that are similar to artists that the user tells MusicBot. It can also respond to some basic questions and statements.

Dependencies

The bot requires Python version 3.3 or higher. The required packages are:

If you want to run this code yourself, don't forget to add bot.ini file containing at least the follwing lines:

[BotConfig]
TOKEN = <your telegram token>

without the <>.

Example conversations

A simple example showing the main functionality of MusicBot is shown below.

User: 		Hello MusicBot!
MusicBot: 	Hey there!
MusicBot:	I am MusicBot 1.0. I can recommend some artist if you tell me 
			what you like.
MusicBot:	Which artists do you listen to?
User:		I usually listen to artists like The Beatles and The Doors, 
			but somtimes I like to listen to some lesser known artists 
			such as Mura Masa, Tennyson and The M Machine.
MusicBot:	Let me see, I might know The Beatles, The Doors, Mura Masa, 
			Tennyson, or The M Machine...
MusicBot:	Similar to The Beatles, The Doors, Mura Masa, Tennyson, 
			and The M Machine, you might also like:
			 - Milo Mills
			 - Dog Blood
			 - Lindsay Lowend
			 - Pascäal
			 - GEOTHEORY
			 - Alvin Risk
			 - Jim Morrison
			 - The Yardbirds
			 - The Byrds
			 - The Hollies
User:		Okay, thanks!
MusicBot:	Cool :)

As can be seen, the bot takes some recommendations for each artist and combines them into one list sorted from least popular to most.

How it works

When MusicBot is started, it loads a list of known artists and adds them to the spaCy Matcher. The list of artists is included in this repository, and is downloaded from the Last.fm public API using the pylast package (not included in the dependency list since the artists are pre-downloaded). The list includes the top 10000 artists retrieved at March, 2017. Note that this step takes a while, since the English model and artist list have to be loaded.

When a message is recieved by MusicBot, it is first checked for greetings using a predefined list of greeting words. If so, a greeting is sent to the user, which will contain the user's name if they have spoken to MusicBot before (given that the bot did not restart after then). Then, it is scanned for artist names using the spaCy Matcher class. If this is not the case, a check is performed whether or not the message was a question, and if so, an appropriate response is formed from a predefined list. Otherwise, the message is treated as a statement, which will generate a different response.

When a user sends a message containing one or more known artists, the bot will query the Spotify API for each of those artists, compiling lists of relevant artists. These lists are sorted in increasing popularity, such that the least popular artist will appear first. This was an important criterium, since we want to show artists that the user is less likely to already know, and thus stimulate exploration of lesser known artists.

Possible extensions

Since creating MusicBot was a project for only a couple weeks, there are many possible extensions that were beyond the scope of this project:

  • A memory all artists that the user has mentioned in the past. This can be used to further specify the recommendations.
  • A smarter general response system. The current implementation fails in many cases to correctly respond to statements or questions beyond requests for recommendations.
  • A recommendation system based on not only artists, but also genre, albums or specific songs.
  • In the same vein, an album or song recommendation system besides just artists.

musicbot's People

Contributors

timovniedek avatar

Stargazers

Jared Van Valkengoed avatar Isabel Soares avatar Emma avatar  avatar Yash Chaudhary avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.