Skip to main content

ListenBrainz' empathic music recommendation/playlisting engine

Project description

Introduction

The Troi Playlisting Engine combines all of ListenBrainz' playlist efforts:

  1. Playlist generation: Music recommendations and algorithmic playlist generation using a pipeline architecture that allows easy construction of custom pipelines that output playlists. You can see this part in action on ListenBrainz's Created for You pages, where we show of Weekly jams and Weekly Discovery playlists. The playlist generation tools use an API-first approach were users don't need to download massive amounts of data, but instead fetch the data via APIs as needed.

  2. Local content database: Using these tools a user can scan their music collection on disk or via a Subsonic API (e.g. Navidrome, Funkwhale, Gonic), download metadata for it and then resolve global playlists (playlist with only MBIDs) to files available in a local collection. We also have support for duplicate file detection, top tags in your collection and other insights.

  3. Playlist exchange: We're in the process of building this toolkit out to support saving/loading playlists in a number of format to hopefully break playlists free from the music silos (Spotify, Apple, etc)

The project is named after Deanna Troi.

Features

Playlist generation

Troi can be used to generate playlists:

  1. A pipelined architecture for creating playlists from any number of sources.
  2. Data sources that fetch data from APIs and feed the data into the troi pipelines.
  3. Pipeline elements that are connected together are called Patches. Troi includes a number of built-in patches.
  4. The largest patch implements ListenBrainz radio that can generate "radio style" playlists based on one or more artists, tags, user statistics, user recommendations, LB playlists and MB collections.
  5. Generated playlists are output in the JSPF format, the JSON version of XPSF playlists.

Troi is being used to generate weekly recommendations on ListenBrainz (weekly jams, weekly exploration) as well as LB Radio.

Data-sets

To accomplish this goal, we, the MetaBrainz Foundation, have created and hosted a number of data-sets that can be accessed as a part of this project. For instance, the more stable APIs are hosted on our Labs API page.

ListenBrainz offers a number of data sets:

  1. Collaborative filtered recordings that suggest what recordings a user should listen to based on their previous listening habits.
  2. User statistics that were derived from users recent listening habits.
  3. Listening stats that can be used as a measure of popularity.
  4. Similarity data for artists and recordings

We will continue to build and host more datasets as time passes. If an API endpoint becomes useful to a greater number of people we will elevate these API endpoints to officially supported endpoints that we ensure are up to date on online at all times.

Database / Content Resolution

The ListenBrainz Content Resolver resolves global JSPF playlists to a local collection of music, using the content resolver.

The features include:

  1. ListenBrainz Radio Local: allows you to generate radio-style playlists that that are created using only the files in the local collection, or if that is not possible, a global playlist with MBIDS will be resolved to a local file collection as best as possible.

  2. Periodic-jams: ListenBrainz periodic-jams, but fully resolved against your own local collection. This is optimized for local collections and gives better results than the global troi patch by the same name.

  3. Resolve global playlists (usually JSPF files with MusicBrainz IDs) to a local collection of music. Resolution happens via: MusicBrainz IDs, metadata matching or fuzzy metadata matching.

  4. Metadata fetching: Several of the features here require metadata to be downloaded from ListenBrainz in order to power the LB Radio Local.

  5. Scan local file collections. MP3, Ogg Vorbis, Ogg Opus, WMA, M4A and FLAC file are supported.

  6. Scan a remote subsonic API collection. We've tested Navidrome, Funkwhale and Gonic.

  7. Print a report of duplicate files in the collection

  8. Print a list of top tags for the collection

  9. Print a list of tracks that failed to resolve and print the list of albums that they belong to. This gives the user feedback about tracks that could be added to the collection to improve the local matching.

Documentation

Full documentation for Troi is available at troi.readthedocs.org.

Installation for end users

Troi is available for download via PyPi.

virtualenv -p python3 .ve
pip3 install troi[nmslib]
troi --help

Troi also depends on nmslib-metabrainz to enable fuzzy matching of tracks against a local collection. nmslib-metabrainz is not required to run troi, it's only required for fuzzy matching, so if you're having a hard time installing nsmlib, omit it like this:

virtualenv -p python3 .ve
pip3 install troi
troi --help

Installation for Development

Note: If you have trouble installing nmslib, it is optional. Remove nsmlib from the install command below:

Linux and Mac

virtualenv -p python3 .ve
source .ve/bin/activate
pip3 install -e .[nmslib,tests]
troi --help

Windows

virtualenv -p python .ve
.ve\Scripts\activate.bat
pip install -e .[nmslib,tests]
troi --help

User-guide

For details on how to run Troi, please see see our user guide.

Running tests

troi test
troi test -v
troi test -v <file to test>

Building Documentation

To build the documentation locally:

pip install .[docs]
cd docs
make clean html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

troi-2026.3.10.0.tar.gz (126.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

troi-2026.3.10.0-py3-none-any.whl (125.6 kB view details)

Uploaded Python 3

File details

Details for the file troi-2026.3.10.0.tar.gz.

File metadata

  • Download URL: troi-2026.3.10.0.tar.gz
  • Upload date:
  • Size: 126.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for troi-2026.3.10.0.tar.gz
Algorithm Hash digest
SHA256 5e7079169a217b5c4f680f4d3f04f12f21f16e9a29f67142f033a25062e062f9
MD5 396c2c9b0c807117d0b6d93de81ba2ed
BLAKE2b-256 b6279f9a7d71d6c35e7a7a5f6d4bc562dcde47c06cf3759afad989ba471385ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for troi-2026.3.10.0.tar.gz:

Publisher: cd.yml on metabrainz/troi-recommendation-playground

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file troi-2026.3.10.0-py3-none-any.whl.

File metadata

  • Download URL: troi-2026.3.10.0-py3-none-any.whl
  • Upload date:
  • Size: 125.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for troi-2026.3.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc44d99b1fc772788eebaeaa6778efc19a4fc222080f92fc723ccaf4754e3d88
MD5 7db134ae84c6b9eae4f6f9130dd0428c
BLAKE2b-256 1b3d48473689359a7d724d52b535016446a787ea2d1b4b4faec1b6a3fc5a9310

See more details on using hashes here.

Provenance

The following attestation bundles were made for troi-2026.3.10.0-py3-none-any.whl:

Publisher: cd.yml on metabrainz/troi-recommendation-playground

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page