Add Nix flake 7096e28f parent 74d532d9

authored by ~talya

1
[![crate](https://img.shields.io/crates/v/blissify.svg)](https://crates.io/crates/blissify)
2
[![build](https://github.com/Polochon-street/blissify-rs/workflows/Rust/badge.svg)](https://github.com/Polochon-street/blissify-rs/actions)
3
4
# Blissify - analyze an MPD library and make smart playlists
5
6
Blissify is a program used to make playlists of songs that sound alike
7
from your [MPD](https://www.musicpd.org/) track library, ร  la Spotify radio.
8
9
Under the hood, it is an [MPD](https://www.musicpd.org/) plugin
10
for [bliss](https://crates.io/crates/bliss-audio).
11
12
Blissify needs first to analyze your music library, i.e. compute and store
13
a series of features from your songs, extracting the tempo, timbre,
14
loudness, etc.
15
16
After that, it is ready to make playlists: play a song to start from, run
17
`blissify playlist 30`, and voilร ! You have a playlist of 30 songs that
18
sound like your first track.
19
20
Note: you *need* to have MPD installed to use blissify. Otherwise, you
21
probably want to implement bliss-rs support for the audio player you use.
22
23
# Installation / Usage
24
25
You'll need clang, pkg-config and ffmpeg libraries (including development
26
headers) to install it, as well as a
27
[working Rust installation](https://www.rust-lang.org/tools/install)
28
29
On Debian-based systems:
30
31
$ sudo apt install -y build-essential pkg-config libavutil-dev libavformat-dev \
32
libavfilter-dev libavdevice-dev libclang-dev libsqlite3-dev
33
34
On Archlinux:
35
36
$ sudo pacman -S base-devel clang ffmpeg sqlite
37
38
Finally, install it using:
39
40
$ cargo install blissify
41
42
Note: if you are using a raspberry pi and its corresponding ffmpeg
43
(i.e. `ffmpeg -version|grep rpi` gives back something), use
44
`cargo install --features=rpi blissify` instead.
45
46
By default, blissify uses [FFmpeg](https://www.ffmpeg.org/) to decode songs.
47
Instead of using FFmpeg, you can also use
48
[Symphonia](https://github.com/pdeljanov/Symphonia) by using the `symphonia`
49
feature: `cargo install --features=symphonia --no-default-features`.
50
Symphonia supports slightly less audio formats and the analysis results are
51
slightly different than with ffmpeg, so make sure to always use either blissify
52
compiled with Symphonia or blissify compiled with ffmepg - but do not mix both.
53
Since Symphonia is written in pure Rust, you will remove the need for ffmpeg,
54
which can be a quite big external dependency.
55
56
All the commands below read the `MPD_HOST` and `MPD_PORT` environment
57
variables and try to reach MPD using that. You might want to change
58
it if MPD is listening to somewhere else than `127.0.0.1:6600` (the default).
59
It should be fully compatible with [the MPD documentation](https://mpd.readthedocs.io/en/latest/client.html#connecting-to-mpd).
60
61
## Analyze a library
62
63
To initialize and analyze your MPD library, use
64
```
65
$ blissify init /path/to/mpd/root
66
```
67
68
It will create a configuration file `config.json` and a database file
69
`songs.db` in `~/.local/share/bliss-rs`. If you want to specify a different
70
path for the configuration file and the database file, running
71
```
72
$ blissify init -d /path/to/database.db /path/to/mpd/root -c /path/to/configuration.json
73
```
74
should do the trick. All the subsequent blissify commands should start
75
with `blissify <command> -c /path/to/configuration.json` in order to work.
76
77
Note that it may take several minutes (up to some hours, on very large
78
libraries with more than for instance 20k songs) to complete.
79
80
You can further update your library by running
81
```
82
$ blissify update
83
```
84
85
Sometimes (very rarely), the bliss algorithm for song analysis will change, and
86
using it will require to analyze your library again. You can keep using the
87
older algorithm for as long as you want, but once you are ready to upgrade
88
your library, you will need to run
89
```
90
$ blissify update --full
91
```
92
93
If something goes wrong and the database enters an
94
unstable state, you can use
95
```
96
$ blissify rescan
97
```
98
to remove the existing database and rescan all files.
99
100
If you want to see if the analysis has been successful, or simply want to see
101
the current files in the database, you can use
102
```
103
$ blissify list-db
104
```
105
106
## Make a playlist
107
108
### Simple version
109
110
```
111
$ blissify playlist 100
112
```
113
114
This will add 100 songs similar to the song that is currently
115
playing on MPD, starting with the closest possible. This will also remove
116
all the others songs previously in the queue, leaving only the smart playlist.
117
118
If you wish to queue the songs after the current playing song but keep the
119
current queue, you can use the `--keep-current-queue` flag, like so:
120
121
```
122
$ blissify playlist 100 --keep-current-queue
123
```
124
125
### Changing the distance metric
126
127
To make a playlist with a distance metric different than the default one
128
(euclidean distance), which will yield different playlists, run:
129
130
```
131
$ blissify playlist --distance <distance_name> 30
132
```
133
134
`distance_name` can currently be `euclidean` or `cosine`. Don't hesitate to
135
experiment with this parameter if the generated playlists are not to your
136
linking!
137
138
### Make a "seeded" playlist
139
140
Instead of making a playlist with songs that are only similar to the first song,
141
from the most similar to the least similar (the default), you can make a
142
playlist that queues the closest song to the first song, then the closest song
143
the second song, etc, effectively making "path" through the songs.
144
145
To try it out (it can take a bit more time to build the playlist):
146
147
```
148
$ blissify playlist --seed-song 30
149
```
150
151
### Make an album playlist
152
153
You can also make a playlist of albums that sound like the current album
154
you're listening to (more specifically, the album of the current song you're
155
playing, regardless of whether you queued the full album or not).
156
157
To try it out:
158
159
```
160
$ blissify playlist --album-playlist 30
161
```
162
163
If you wish to queue the albums after the current playing album, but keep the
164
current queue, you can use the `--keep-current-queue` flag, like so:
165
166
```
167
$ blissify playlist --album-playlist 100 --keep-current-queue
168
```
169
170
### Make an interactive playlist
171
172
Interactive playlists start from a song, and let you choose which song should
173
be played next among the 3 closest songs (the number of songs displayed
174
can be set manually):
175
176
```
177
$ blissify interactive-playlist --number-choices 5
178
```
179
180
By default, it crops the current playlist to just keep the currently played
181
song. If you want to just start from the last song and continue from there, use
182
`--continue`:
183
184
```
185
$ blissify interactive-playlist --number-choices 5 --continue
186
```
187
188
### Dry run mode
189
190
If you want to see which playlist blissify would make without changing the
191
queue at all, or you wish to plug blissify's output somewhere else, you
192
can use the `--dry-run` option, like so:
193
194
```
195
$ blissify playlist 100 --dry-run
196
```
197
198
# Metric learning
199
200
If you feel like making your smartโ„ข๏ธ playlists even smarterยฎ๏ธ , take a look
201
at the [metric-learning](https://github.com/Polochon-street/bliss-metric-learning)
202
repo. It gives you the possibility of evaluating the proximity of your own
203
songs, and tailor playlists to your own taste.
204
205
Once you ran the tool in the [metric-learning](https://github.com/Polochon-street/bliss-metric-learning)
206
repo, you can use the mahalanobis distance to make playlists from the learned
207
metric:
208
209
```
210
$ blissify playlist 100 --distance mahalanobis
211
```
212
213
Note that it is all very much alpha development, so if you have any feedback,
214
feel free to submit an issue.
215
216
# Details
217
218
If you are interested about what is happening under the hood, or want to make
219
a similar plug-in for other audio players, see
220
[bliss' doc](https://docs.rs/crate/bliss-audio/).
221
222
# Troubleshooting
223
224
If you are compiling blissify-rs for non-linux OSes, you might run into an
225
error telling you to use the bindgen feature:
226
227
```
228
error: failed to run custom build command for `bliss-audio-aubio-sys v0.2.2`
229
230
Caused by:
231
process didn't exit successfully: `path/release/build/bliss-audio-aubio-sys-fb4d0ec74b3698ed/build-script-build` (exit status: 101)
232
--- stderr
233
thread 'main' panicked at .cargo/registry/src/index.crates.io-6f17d22bba15001f/bliss-audio-aubio-sys-0.2.2/build.rs:34:13:
234
No prebuilt bindings. Try use `bindgen` feature.
235
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
236
warning: build failed, waiting for other jobs to finish...
237
error: failed to compile `blissify v0.4.1`, intermediate artifacts can be found at `/var/folders/pb/g43q604n6v71kwp_89ccy6840000gn/T/cargo-installoyKiUv`.
238
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
239
```
240
241
To fix this and build blissify-rs successfully, use `cargo install blissify --features=default,bliss-audio/update-aubio-bindings`.
242