Merge pull request #210303 from mweinelt/larynx

This commit is contained in:
Martin Weinelt 2023-01-14 20:04:31 +00:00 committed by GitHub
commit bc12358925
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 381 additions and 16 deletions

View file

@ -0,0 +1,21 @@
diff --git a/espeak_phonemizer/__init__.py b/espeak_phonemizer/__init__.py
index a09472e..730a7f9 100644
--- a/espeak_phonemizer/__init__.py
+++ b/espeak_phonemizer/__init__.py
@@ -163,14 +163,10 @@ class Phonemizer:
# Already initialized
return
- self.libc = ctypes.cdll.LoadLibrary("libc.so.6")
+ self.libc = ctypes.cdll.LoadLibrary("@libc@")
self.libc.open_memstream.restype = ctypes.POINTER(ctypes.c_char)
- try:
- self.lib_espeak = ctypes.cdll.LoadLibrary("libespeak-ng.so")
- except OSError:
- # Try .so.1
- self.lib_espeak = ctypes.cdll.LoadLibrary("libespeak-ng.so.1")
+ self.lib_espeak = ctypes.cdll.LoadLibrary("@libespeak_ng@")
sample_rate = self.lib_espeak.espeak_Initialize(
Phonemizer.AUDIO_OUTPUT_SYNCHRONOUS, 0, None, 0

View file

@ -0,0 +1,42 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, substituteAll
, glibc
, espeak-ng
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "espeak-phonemizer";
version = "1.1.0";
format = "setuptools";
src = fetchFromGitHub {
owner = "rhasspy";
repo = "espeak-phonemizer";
rev = "refs/tags/v${version}";
hash = "sha256-qnJtS5iIARdg+umolzLHT3/nLon9syjxfTnMWHOmYPU=";
};
patches = [
(substituteAll {
src = ./cdll.patch;
libc = "${lib.getLib glibc}/lib/libc.so.6";
libespeak_ng = "${lib.getLib espeak-ng}/lib/libespeak-ng.so";
})
];
checkInputs = [
pytestCheckHook
];
meta = with lib; {
changelog = "https://github.com/rhasspy/espeak-phonemizer/releases/tag/v${version}";
description = "Uses ctypes and libespeak-ng to transform test into IPA phonemes";
homepage = "https://github.com/rhasspy/espeak-phonemizer";
license = licenses.mit;
maintainers = with maintainers; [ hexa ];
platforms = platforms.linux;
};
}

View file

@ -13,6 +13,20 @@
, requests
, smbprotocol
, tqdm
# optionals
, adlfs
, dask
, distributed
, dropbox
, fusepy
, gcsfs
, libarchive-c
, ocifs
, panel
, pyarrow
, pygit2
, s3fs
}:
buildPythonPackage rec {
@ -37,6 +51,75 @@ buildPythonPackage rec {
tqdm
];
passthru.optional-dependencies = {
entrypoints = [
];
abfs = [
adlfs
];
adl = [
adlfs
];
dask = [
dask
distributed
];
dropbox = [
# missing dropboxdrivefs
requests
dropbox
];
gcs = [
gcsfs
];
git = [
pygit2
];
github = [
requests
];
gs = [
gcsfs
];
hdfs = [
pyarrow
];
arrow = [
pyarrow
];
http = [
aiohttp
requests
];
sftp = [
paramiko
];
s3 = [
s3fs
];
oci = [
ocifs
];
smb = [
smbprotocol
];
ssh = [
paramiko
];
fuse = [
fusepy
];
libarchive = [
libarchive-c
];
gui = [
panel
];
tqdm = [
tqdm
];
};
checkInputs = [
numpy
pytest-asyncio

View file

@ -0,0 +1,61 @@
{ lib
, buildPythonPackage
, larynx
# build
, cython
, python
# propagates
, espeak-phonemizer
, librosa
, numpy
, onnxruntime
, pytorch-lightning
, torch
}:
buildPythonPackage rec {
inherit (larynx) version src meta;
pname = "larynx-train";
format = "setuptools";
sourceRoot = "source/src/python";
nativeBuildInputs = [
cython
];
postPatch = ''
substituteInPlace requirements.txt \
--replace "onnxruntime~=1.11.0" "onnxruntime" \
--replace "pytorch-lightning~=1.7.0" "pytorch-lightning" \
--replace "torch~=1.11.0" "torch"
'';
postBuild = ''
make -C larynx_train/vits/monotonic_align
'';
postInstall = ''
export MONOTONIC_ALIGN=$out/${python.sitePackages}/larynx_train/vits/monotonic_align/monotonic_align
mkdir -p $MONOTONIC_ALIGN
cp -v ./larynx_train/vits/monotonic_align/larynx_train/vits/monotonic_align/core.*.so $MONOTONIC_ALIGN/
'';
propagatedBuildInputs = [
espeak-phonemizer
librosa
numpy
onnxruntime
pytorch-lightning
torch
];
pythonImportsCheck = [
"larynx_train"
];
doCheck = false; # no tests
}

View file

@ -0,0 +1,66 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
# build
, setuptools
# runtime
, packaging
, typing-extensions
# tests
, pytest-timeout
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "lightning-utilities";
version = "0.5.0";
format = "pyproject";
src = fetchFromGitHub {
owner = "Lightning-AI";
repo = "utilities";
rev = "refs/tags/v${version}";
hash = "sha256-J73sUmX1a7ww+rt1vwBt9P0Xbeoxag6jR0W63xEySCI=";
};
nativeBuildInputs = [
setuptools
];
propagatedBuildInputs = [
packaging
typing-extensions
];
pythonImportsCheck = [
"lightning_utilities"
];
checkInputs = [
pytest-timeout
pytestCheckHook
];
disabledTests = [
"lightning_utilities.core.enums.StrEnum"
"lightning_utilities.core.imports.RequirementCache"
"lightning_utilities.core.imports.compare_version"
"lightning_utilities.core.imports.get_dependency_min_version_spec"
];
disabledTestPaths = [
"docs"
];
meta = with lib; {
changelog = "https://github.com/Lightning-AI/utilities/releases/tag/v${version}";
description = "Common Python utilities and GitHub Actions in Lightning Ecosystem";
homepage = "https://github.com/Lightning-AI/utilities";
license = licenses.asl20;
maintainers = with maintainers; [ hexa ];
};
}

View file

@ -1,47 +1,65 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, isPy27
, future
, pythonOlder
, fsspec
, lightning-utilities
, numpy
, packaging
, pytestCheckHook
, torch
, pyyaml
, tensorboard
, tensorboardx
, torch
, torchmetrics
, tqdm }:
, tqdm
, traitlets
# tests
, psutil
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "pytorch-lightning";
version = "1.8.6";
disabled = isPy27;
format = "pyproject";
src = fetchFromGitHub {
owner = "PyTorchLightning";
repo = pname;
owner = "Lightning-AI";
repo = "pytorch-lightning";
rev = "refs/tags/${version}";
hash = "sha256-5AyOCeRFiV7rdmoBPx03Xju6eTR/3jiE+HQBiEmdzmo=";
};
preConfigure = ''
export PACKAGE_NAME=pytorch
'';
propagatedBuildInputs = [
packaging
future
fsspec
torch
numpy
packaging
pyyaml
tensorboard
tensorboardx
torch
lightning-utilities
torchmetrics
tqdm
traitlets
]
++ fsspec.optional-dependencies.http;
checkInputs = [
psutil
pytestCheckHook
];
checkInputs = [ pytestCheckHook ];
# Some packages are not in NixPkgs; other tests try to build distributed
# models, which doesn't work in the sandbox.
doCheck = false;
pythonImportsCheck = [ "pytorch_lightning" ];
pythonImportsCheck = [
"pytorch_lightning"
];
meta = with lib; {
description = "Lightweight PyTorch wrapper for machine learning researchers";

View file

@ -0,0 +1,64 @@
{ lib
, stdenv
, fetchFromGitHub
, cmake
, pkgconfig
, espeak-ng
, onnxruntime
, pcaudiolib
, larynx-train
}:
let
pname = "larynx";
version = "0.0.2";
in
stdenv.mkDerivation {
inherit pname version;
src = fetchFromGitHub {
owner = "rhasspy";
repo = "larynx2";
rev = "refs/tags/v${version}";
hash = "sha256-6SZ1T2A1DyVmBH2pJBHJdsnniRuLrI/dthRTRRyVSQQ=";
};
sourceRoot = "source/src/cpp";
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace "/usr/local/include/onnxruntime" "${onnxruntime}"
'';
nativeBuildInputs = [
cmake
pkgconfig
];
buildInputs = [
espeak-ng
onnxruntime
pcaudiolib
];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
install -m 0755 larynx $out/bin
runHook postInstall
'';
passthru.tests = {
inherit larynx-train;
};
meta = with lib; {
changelog = "https://github.com/rhasspy/larynx2/releases/tag/v${version}";
description = "A fast, local neural text to speech system";
homepage = "https://github.com/rhasspy/larynx2";
license = licenses.mit;
maintainers = with maintainers; [ hexa ];
};
}

View file

@ -9100,6 +9100,10 @@ with pkgs;
jump = callPackage ../tools/system/jump {};
larynx = callPackage ../tools/audio/larynx { };
larynx-train = with python3Packages; toPythonApplication larynx-train;
latex2html = callPackage ../tools/misc/latex2html { };
lazycli = callPackage ../tools/misc/lazycli { };

View file

@ -3045,6 +3045,8 @@ self: super: with self; {
eradicate = callPackage ../development/python-modules/eradicate { };
espeak-phonemizer = callPackage ../development/python-modules/espeak-phonemizer { };
esprima = callPackage ../development/python-modules/esprima { };
escapism = callPackage ../development/python-modules/escapism { };
@ -5154,6 +5156,8 @@ self: super: with self; {
lark = callPackage ../development/python-modules/lark { };
larynx-train = callPackage ../development/python-modules/larynx-train { };
latexcodec = callPackage ../development/python-modules/latexcodec { };
latexify-py = callPackage ../development/python-modules/latexify-py { };
@ -5390,6 +5394,8 @@ self: super: with self; {
lightning = callPackage ../development/python-modules/lightning { };
lightning-utilities = callPackage ../development/python-modules/lightning-utilities { };
lightparam = callPackage ../development/python-modules/lightparam { };
lightwave = callPackage ../development/python-modules/lightwave { };