Merge pull request #163568 from azuwis/pianotrans
pianotrans: init at 1.0
This commit is contained in:
commit
bc40181f69
5 changed files with 169 additions and 0 deletions
38
pkgs/applications/audio/pianotrans/default.nix
Normal file
38
pkgs/applications/audio/pianotrans/default.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{ lib
|
||||
, fetchFromGitHub
|
||||
, python3
|
||||
, ffmpeg
|
||||
}:
|
||||
|
||||
python3.pkgs.buildPythonApplication rec {
|
||||
pname = "pianotrans";
|
||||
version = "1.0";
|
||||
format = "setuptools";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "azuwis";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
hash = "sha256-6Otup1Yat1dBZdSoR4lDfpytUQ2RbDXC6ieo835Nw+U=";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = with python3.pkgs; [
|
||||
piano-transcription-inference
|
||||
torch
|
||||
tkinter
|
||||
];
|
||||
|
||||
# Project has no tests
|
||||
doCheck = false;
|
||||
|
||||
makeWrapperArgs = [
|
||||
''--prefix PATH : "${lib.makeBinPath [ ffmpeg ]}"''
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Simple GUI for ByteDance's Piano Transcription with Pedals";
|
||||
homepage = "https://github.com/azuwis/pianotrans";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ azuwis ];
|
||||
};
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, buildPythonPackage
|
||||
, fetchPypi
|
||||
, fetchpatch
|
||||
, fetchurl
|
||||
, librosa
|
||||
, matplotlib
|
||||
, mido
|
||||
, torch
|
||||
, torchlibrosa
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "piano-transcription-inference";
|
||||
version = "0.0.5";
|
||||
format = "setuptools";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
hash = "sha256-nbhuSkXuWrekFxwdNHaspuag+3K1cKwq90IpATBpWPY=";
|
||||
};
|
||||
|
||||
checkpoint = fetchurl {
|
||||
name = "piano-transcription-inference.pth";
|
||||
# The download url can be found in
|
||||
# https://github.com/qiuqiangkong/piano_transcription_inference/blob/master/piano_transcription_inference/inference.py
|
||||
url = "https://zenodo.org/record/4034264/files/CRNN_note_F1%3D0.9677_pedal_F1%3D0.9186.pth?download=1";
|
||||
hash = "sha256-w/qXMHJb9Kdi8cFLyAzVmG6s2gGwJvWkolJc1geHYUE=";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [
|
||||
librosa
|
||||
matplotlib
|
||||
mido
|
||||
torch
|
||||
torchlibrosa
|
||||
];
|
||||
|
||||
patches = [
|
||||
# Fix run against librosa 0.9.0
|
||||
# https://github.com/qiuqiangkong/piano_transcription_inference/pull/10
|
||||
(fetchpatch {
|
||||
url = "https://github.com/qiuqiangkong/piano_transcription_inference/commit/b2d448916be771cd228f709c23c474942008e3e8.patch";
|
||||
hash = "sha256-8O4VtFij//k3fhcbMRz4J8Iz4AdOPLkuk3UTxuCSy8U=";
|
||||
})
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace piano_transcription_inference/inference.py --replace \
|
||||
"checkpoint_path='{}/piano_transcription_inference_data/note_F1=0.9677_pedal_F1=0.9186.pth'.format(str(Path.home()))" \
|
||||
"checkpoint_path='$out/share/checkpoint.pth'"
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
mkdir "$out/share"
|
||||
ln -s "${checkpoint}" "$out/share/checkpoint.pth"
|
||||
'';
|
||||
|
||||
# Project has no tests.
|
||||
# In order to make pythonImportsCheck work, NUMBA_CACHE_DIR env var need to
|
||||
# be set to a writable dir (https://github.com/numba/numba/issues/4032#issuecomment-488102702).
|
||||
# pythonImportsCheck has no pre* hook, use checkPhase to wordaround that.
|
||||
checkPhase = ''
|
||||
export NUMBA_CACHE_DIR="$(mktemp -d)"
|
||||
'';
|
||||
pythonImportsCheck = [ "piano_transcription_inference" ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "A piano transcription inference package";
|
||||
homepage = "https://github.com/qiuqiangkong/piano_transcription_inference";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ azuwis ];
|
||||
};
|
||||
}
|
50
pkgs/development/python-modules/torchlibrosa/default.nix
Normal file
50
pkgs/development/python-modules/torchlibrosa/default.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, buildPythonPackage
|
||||
, fetchPypi
|
||||
, fetchpatch
|
||||
, librosa
|
||||
, numpy
|
||||
, torch
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "torchlibrosa";
|
||||
version = "0.0.9";
|
||||
format = "setuptools";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
hash = "sha256-+LzejKvLlJIIwWm9rYPCWQDSueIwnG5gbkwNE+wbv0A=";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [
|
||||
librosa
|
||||
numpy
|
||||
torch
|
||||
];
|
||||
|
||||
patches = [
|
||||
# Fix run against librosa 0.9.0, https://github.com/qiuqiangkong/torchlibrosa/pull/8
|
||||
(fetchpatch {
|
||||
url = "https://github.com/qiuqiangkong/torchlibrosa/commit/eec7e7559a47d0ef0017322aee29a31dad0572d5.patch";
|
||||
hash = "sha256-c1x3MA14Plm7+lVuqiuLWgSY6FW615qnKbcWAfbrcas=";
|
||||
})
|
||||
];
|
||||
|
||||
# Project has no tests.
|
||||
# In order to make pythonImportsCheck work, NUMBA_CACHE_DIR env var need to
|
||||
# be set to a writable dir (https://github.com/numba/numba/issues/4032#issuecomment-488102702).
|
||||
# pythonImportsCheck has no pre* hook, use checkPhase to workaround that.
|
||||
checkPhase = ''
|
||||
export NUMBA_CACHE_DIR="$(mktemp -d)"
|
||||
'';
|
||||
pythonImportsCheck = [ "torchlibrosa" ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "PyTorch implemention of part of librosa functions";
|
||||
homepage = "https://github.com/qiuqiangkong/torchlibrosa";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ azuwis ];
|
||||
};
|
||||
}
|
|
@ -32088,6 +32088,8 @@ with pkgs;
|
|||
|
||||
pianoteq = callPackage ../applications/audio/pianoteq { };
|
||||
|
||||
pianotrans = callPackage ../applications/audio/pianotrans { };
|
||||
|
||||
picard = callPackage ../applications/audio/picard { };
|
||||
|
||||
picocom = callPackage ../tools/misc/picocom {
|
||||
|
|
|
@ -7066,6 +7066,8 @@ self: super: with self; {
|
|||
|
||||
pi1wire = callPackage ../development/python-modules/pi1wire { };
|
||||
|
||||
piano-transcription-inference = callPackage ../development/python-modules/piano-transcription-inference { };
|
||||
|
||||
piccata = callPackage ../development/python-modules/piccata { };
|
||||
|
||||
pick = callPackage ../development/python-modules/pick { };
|
||||
|
@ -11528,6 +11530,8 @@ self: super: with self; {
|
|||
|
||||
torchinfo = callPackage ../development/python-modules/torchinfo { };
|
||||
|
||||
torchlibrosa = callPackage ../development/python-modules/torchlibrosa { };
|
||||
|
||||
torchvision = callPackage ../development/python-modules/torchvision { };
|
||||
|
||||
torchvision-bin = callPackage ../development/python-modules/torchvision/bin.nix { };
|
||||
|
|
Loading…
Reference in a new issue