diff options
-rw-r--r-- | modules/home/conf/beets/default.nix | 8 | ||||
-rw-r--r-- | modules/home/conf/beets/plugins.nix | 3 | ||||
-rw-r--r-- | modules/home/conf/beets/plugins/default.nix | 1 | ||||
-rw-r--r-- | modules/home/conf/beets/plugins/xtractor/default.nix | 95 | ||||
-rw-r--r-- | pkgs/by-name/be/beetsExtraPlugins/package.nix | 3 | ||||
-rw-r--r-- | pkgs/by-name/be/beetsExtraPlugins/xtractor.nix | 54 |
6 files changed, 163 insertions, 1 deletions
diff --git a/modules/home/conf/beets/default.nix b/modules/home/conf/beets/default.nix index 58008bd6..e5e45179 100644 --- a/modules/home/conf/beets/default.nix +++ b/modules/home/conf/beets/default.nix @@ -2,6 +2,7 @@ pkgs, lib, config, + beetsExtraPlugins, ... }: let plugins = import ./plugins.nix; @@ -13,7 +14,12 @@ in { programs.beets = { enable = true; package = pkgs.beets.override { - pluginOverrides = {}; + pluginOverrides = { + xtractor = { + enable = true; + propagatedBuildInputs = [beetsExtraPlugins.xtractor]; + }; + }; }; settings = { diff --git a/modules/home/conf/beets/plugins.nix b/modules/home/conf/beets/plugins.nix index 7ab6819a..bea2fefe 100644 --- a/modules/home/conf/beets/plugins.nix +++ b/modules/home/conf/beets/plugins.nix @@ -11,6 +11,9 @@ # Help submitting stuff to music brainz "mbsubmit" + # Extract things from the music file + "xtractor" + # Calculate replay gain "replaygain" diff --git a/modules/home/conf/beets/plugins/default.nix b/modules/home/conf/beets/plugins/default.nix index 9fc04a8d..3bea5ea8 100644 --- a/modules/home/conf/beets/plugins/default.nix +++ b/modules/home/conf/beets/plugins/default.nix @@ -11,5 +11,6 @@ ./play ./replaygain ./smartplaylist + ./xtractor ]; } diff --git a/modules/home/conf/beets/plugins/xtractor/default.nix b/modules/home/conf/beets/plugins/xtractor/default.nix new file mode 100644 index 00000000..23f53add --- /dev/null +++ b/modules/home/conf/beets/plugins/xtractor/default.nix @@ -0,0 +1,95 @@ +{ + lib, + pkgs, + config, + ... +}: { + programs.beets.settings = { + xtractor = { + # This option is not yet implemented, thus requiring the hook + auto = true; + + dry-run = false; + # Writes the bpm key to the media files + write = true; + threads = 0; + # Also run for files, which already have the required keys + force = true; + quiet = false; + keep_output = true; + keep_profiles = true; + output_path = "${config.xdg.dataHome}/beets/xtactor"; + essentia_extractor = "${lib.getExe pkgs.essentia-extractor}"; + extractor_profile = { + highlevel = { + svm_models = let + m = pkgs.extraBeetsPlugins.xtractor.modules; + in [ + "${m}/danceability.history" + "${m}/danceability.history.param" + "${m}/danceability.history.results.html" + "${m}/gender.history" + "${m}/gender.history.param" + "${m}/gender.history.results.html" + "${m}/genre_dortmund.history" + "${m}/genre_dortmund.history.param" + "${m}/genre_dortmund.history.results.html" + "${m}/genre_electronic.history" + "${m}/genre_electronic.history.param" + "${m}/genre_electronic.history.results.html" + "${m}/genre_rosamerica.history" + "${m}/genre_rosamerica.history.param" + "${m}/genre_rosamerica.history.results.html" + "${m}/genre_tzanetakis.history" + "${m}/genre_tzanetakis.history.param" + "${m}/genre_tzanetakis.history.results.html" + "${m}/ismir04_rhythm.history" + "${m}/ismir04_rhythm.history.param" + "${m}/ismir04_rhythm.history.results.html" + "${m}/mood_acoustic.history" + "${m}/mood_acoustic.history.param" + "${m}/mood_acoustic.history.results.html" + "${m}/mood_aggressive.history" + "${m}/mood_aggressive.history.param" + "${m}/mood_aggressive.history.results.html" + "${m}/mood_electronic.history" + "${m}/mood_electronic.history.param" + "${m}/mood_electronic.history.results.html" + "${m}/mood_happy.history" + "${m}/mood_happy.history.param" + "${m}/mood_happy.history.results.html" + "${m}/mood_party.history" + "${m}/mood_party.history.param" + "${m}/mood_party.history.results.html" + "${m}/mood_relaxed.history" + "${m}/mood_relaxed.history.param" + "${m}/mood_relaxed.history.results.html" + "${m}/mood_sad.history" + "${m}/mood_sad.history.param" + "${m}/mood_sad.history.results.html" + "${m}/moods_mirex.history" + "${m}/moods_mirex.history.param" + "${m}/moods_mirex.history.results.html" + "${m}/timbre.history" + "${m}/timbre.history.param" + "${m}/timbre.history.results.html" + "${m}/tonal_atonal.history" + "${m}/tonal_atonal.history.param" + "${m}/tonal_atonal.history.results.html" + "${m}/voice_instrumental.history" + "${m}/voice_instrumental.history.param" + "${m}/voice_instrumental.history.results.html" + ]; + }; + }; + }; + hook = { + hooks = [ + { + event = "import"; + command = "echo Remember to run 'beet xtractor'!"; + } + ]; + }; + }; +} diff --git a/pkgs/by-name/be/beetsExtraPlugins/package.nix b/pkgs/by-name/be/beetsExtraPlugins/package.nix new file mode 100644 index 00000000..0da472fa --- /dev/null +++ b/pkgs/by-name/be/beetsExtraPlugins/package.nix @@ -0,0 +1,3 @@ +{pkgs, ...}: { + xtractor = pkgs.callPackage ./xtractor.nix {beets = pkgs.beetsPackages.beets-minimal;}; +} diff --git a/pkgs/by-name/be/beetsExtraPlugins/xtractor.nix b/pkgs/by-name/be/beetsExtraPlugins/xtractor.nix new file mode 100644 index 00000000..01c6207a --- /dev/null +++ b/pkgs/by-name/be/beetsExtraPlugins/xtractor.nix @@ -0,0 +1,54 @@ +{ + lib, + fetchFromGitHub, + python3Packages, + beets, +}: +# FIXME: Find a way to update this derivation <2024-08-11> +let + version = "0.4.2"; + models = builtins.fetchTarball { + url = "https://essentia.upf.edu/svm_models/essentia-extractor-svm_models-v2.1_beta5.tar.gz"; + sha256 = "11ps1l4h8bl4l9rlvkhjs61908l18dh7mpq65brm8ki99hnp9g64"; + }; +in + python3Packages.buildPythonApplication { + inherit version; + pname = "beets-xtractor"; + pyproject = true; + + src = fetchFromGitHub { + repo = "BeetsPluginXtractor"; + owner = "adamjakab"; + rev = "v${version}"; + hash = "sha256-it4qQ2OS4qBEaGLJK8FVGpjlvg0MQICazV7TAM8lH9s="; + }; + + nativeBuildInputs = [ + beets + python3Packages.setuptools + ]; + + passthru = {inherit models;}; + + nativeCheckInputs = with python3Packages; [ + pytestCheckHook + pytest-cov + mock + typeguard + ]; + + preCheck = '' + export HOME="$(mktemp -d)" + ''; + postInstall = '' + mkdir --parents $out/models + cp ${models}/* $out/models + ''; + + meta = { + description = "Obtain low and high level musical information from your song"; + homepage = "https://github.com/adamjakab/BeetsPluginXtractor/releasesfhhhhh"; + license = lib.licenses.mit; + }; + } |