summaryrefslogtreecommitdiffstats
path: root/pkgs/development/python-modules/beat-this/default.nix
blob: 09211960cf3a9bcc3755f0b19079bb627ba1135b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
  lib,
  buildPythonPackage,
  einops,
  fetchFromGitHub,
  fetchurl,
  numpy,
  pytestCheckHook,
  rotary-embedding-torch,
  setuptools,
  soundfile,
  soxr,
  torch,
  torchaudio,
  writableTmpDirAsHomeHook,
}:

buildPythonPackage (finalAttrs: {
  pname = "beat-this";
  version = "1.1.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "CPJKU";
    repo = "beat_this";
    tag = "v${finalAttrs.version}";
    hash = "sha256-AEcDptPn5FUBb8+FuYSKjd00sFY5z6bS2iEOU64jido=";
  };

  build-system = [ setuptools ];

  dependencies = [
    einops
    numpy
    rotary-embedding-torch
    soxr
    torch
    torchaudio
  ];

  nativeCheckInputs = [
    pytestCheckHook
    soundfile
    writableTmpDirAsHomeHook
  ];

  preCheck = ''
    mkdir -p $HOME/.cache/torch/hub/checkpoints/
    cp ${finalAttrs.passthru.final0Ckpt} $HOME/.cache/torch/hub/checkpoints/beat_this-final0.ckpt
  '';

  pythonImportsCheck = [ "beat_this" ];

  passthru = {
    # The program prints the download URLs in the error message when it cannot download things in the nix sandbox
    final0Ckpt = fetchurl {
      url = "https://cloud.cp.jku.at/public.php/dav/files/7ik4RrBKTS273gp/final0.ckpt";
      hash = "sha256-jDKLRfWdjdPf8hklP/ao1kgr5X0BM6KRQOL+u/jrgzE=";
    };
    small0Ckpt = fetchurl {
      url = "https://cloud.cp.jku.at/public.php/dav/files/7ik4RrBKTS273gp/small0.ckpt";
      hash = "sha256-YHS+LE1JDF9hAfzDdKHscq6TRW4ju2AZeDuEn13H1Hs=";
    };
  };

  meta = {
    description = "Accurate and general beat tracker";
    homepage = "https://github.com/CPJKU/beat_this";
    changelog = "https://github.com/CPJKU/beat_this/blob/main/CHANGELOG.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ SuperSandro2000 ];
  };
})