/SoundBooth

The indie vocalist social network (NUS CS 4242 Final Project)

Primary LanguageJavaScriptMIT LicenseMIT

SoundBooth

The premier social media platform for indie vocalists to share and discover easy-to-digest soundclips.

Installation

SoundBooth is built on top of React (front-end) and Flask (back-end), and so has two sets of dependencies. SoundBooth also requires ffmpeg and various environment variables. For a simpler installation/deployment, consider this one-click deploy to Heroku:
Deploy

Regardless of your choice, you'll need to get API credentials for Firebase, Google Cloud, and Spotify. Create a Firebase project, then save the config information and download a service account JSON key. Then create a Google Cloud project, enable the Speech to Text API, and download a service account JSON key. Finally, create a Spotify project and keep track of your Client ID and Secret. You'll need all these values later to fill out environment variables.

To handle the front-end dependencies, make sure you have both Node.js and Yarn installed. Then run the following in the root directory:

$ yarn install

To install the back-end dependencies, first make sure you have Python 3 installed. It's recommended that before continuing, you create a virtual environment so packages don't conflict with your other projects. To do so, install Python virtual-env:

$ pip install virtualenv

In the root directory, create a folder for the virtual environment and then activate it with:

$ virtualenv venv
$ . venv/bin/activate

You can exit the environment by running deactivate at any time. Now install the back-end dependencies with:

$ pip install -r requirements.txt

SoundBooth also requires ffmpeg, so make sure it is installed and available in your system path.

Finally, SoundBooth requires the following environment variables to be set:

# Create a Firebase project and fill out these (last one is a JSON service account credential)
REACT_APP_API_KEY=<GET_FROM_FIREBASE>
REACT_APP_AUTH_DOMAIN=<GET_FROM_FIREBASE>
REACT_APP_DATABASE_URL=<GET_FROM_FIREBASE>
REACT_APP_PROJECT_ID=<GET_FROM_FIREBASE>
REACT_APP_STORAGE_BUCKET=<GET_FROM_FIREBASE>
REACT_APP_MESSAGING_SENDER_ID=<GET_FROM_FIREBASE>
FIREBASE_CREDENTIALS={"type":"service_account",...}

# Choose your own key
REACT_APP_SERVER_KEY=<CHOOSE_A_SECURE_KEY>

# Create a Spotify app and fill out these
REACT_APP_SPOTIFY_ID=<GET_FROM_SPOTIFY>
REACT_APP_SPOTIFY_SECRET=<GET_FROM_SPOTIFY>

# Create a Google Cloud project with access to the Speech to Text API and get a JSON service account credential
GOOGLE_CREDENTIALS={"type":"service_account",...}

You don't need to train the machine learning models as we provide pre-trained models (downloaded on application startup). However, if you'd like to tinker with them, the following sections cover the datasets used and how to train on them.

Train Popularity Predictor

  1. Download song_info.csv and place into data/raw/

https://www.kaggle.com/edalrami/19000-spotify-songs#song_info.csv

  1. Start lyrics preprocessing
$ python data/lyrics/preprocess_lyric_data.py
  1. Start XGBoost training
$ python server/train_popularity_model.py
  1. Models are saved in data/trained

Train Genre Classifier

  1. Download genres.tar.gz and place into data/raw/

http://opihi.cs.uvic.ca/sound/genres.tar.gz

  1. Unzip the tar.gz file inside data/raw/
$ tar xvzf file.tar.gz
  1. Start genre audio preprocessing
$ python data/genre/preprocess_genre_data.py
  1. Start Neural Network Training
$ python server/train_NN_genre_model.py
  1. Models are saved in data/trained

Running

To use SoundBooth, run the following from the root directory:

$ yarn build # compile React front-end
$ gunicorn --chdir server -w 4 app:app # run a WSGI server in front of the Flask application

The app should then be available on http://localhost:8000.

For front-end development, run yarn start, which starts a development server on http://localhost:3000. This server has hot-reloading enabled, so you can focus on making changes. However, it won't start the Flask server, and so you won't be able to test any changes to the classifiers or server. To see those changes, have a gunicorn server running in one terminal and use another terminal to run yarn build whenever you have changes to the front-end. You'll have to restart the gunicorn server if changes are made to the back-end as hot-reloading is not configured for it, but feel free to submit a pull request!

References

  1. https://towardsdatascience.com/music-genre-classification-with-python-c714d032f0d8
  2. https://towardsdatascience.com/song-popularity-predictor-1ef69735e380
  3. https://github.com/carl03q/AudioClassifier/blob/master

License

MIT