Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

120 lines
3.0 KiB
Nix
Raw Permalink Normal View History

2024-06-12 23:43:26 +02:00
{
lib,
fetchFromGitHub,
python3Packages,
voicevox-core,
}:
python3Packages.buildPythonApplication rec {
pname = "voicevox-engine";
2025-07-10 08:47:21 +02:00
version = "0.24.1";
2024-06-12 23:43:26 +02:00
pyproject = true;
src = fetchFromGitHub {
owner = "VOICEVOX";
repo = "voicevox_engine";
2024-12-21 13:08:17 +01:00
tag = version;
2025-07-10 08:47:21 +02:00
hash = "sha256-WoHTv4VjLFJPIi47WETMQM8JmgBctAWlue8yKmi1+6A=";
2024-06-12 23:43:26 +02:00
};
patches = [
2025-06-26 19:48:36 +02:00
# this patch makes the package installable via hatchling
./make-installable.patch
2024-06-12 23:43:26 +02:00
];
build-system = with python3Packages; [
2025-06-26 19:48:36 +02:00
hatchling
2024-06-12 23:43:26 +02:00
];
dependencies = [
passthru.pyopenjtalk
]
++ (with python3Packages; [
fastapi
jinja2
2025-06-26 19:48:36 +02:00
kanalizer
numpy
platformdirs
pydantic
2024-06-12 23:43:26 +02:00
python-multipart
pyworld
2025-06-26 19:48:36 +02:00
pyyaml
2024-06-12 23:43:26 +02:00
semver
2025-06-26 19:48:36 +02:00
setuptools
soundfile
2024-06-12 23:43:26 +02:00
soxr
starlette
2025-06-26 19:48:36 +02:00
uvicorn
2024-06-12 23:43:26 +02:00
]);
pythonRemoveDeps = [
# upstream wants fastapi-slim, but we provide fastapi instead
"fastapi-slim"
];
preConfigure = ''
# copy demo metadata to temporary directory
mv resources/character_info test_character_info
# populate the `character_info` directory with the actual model metadata instead of the demo metadata
cp -r --no-preserve=all ${passthru.resources}/character_info resources/character_info
# the `character_info` directory copied from `resources` doesn't exactly have the expected format,
# so we transform them to be acceptable by `voicevox-engine`
pushd resources/character_info
for dir in *; do
# remove unused large files
rm $dir/*/*.png_large
# rename directory from "$name_$uuid" to "$uuid"
mv $dir ''${dir#*"_"}
done
popd
'';
makeWrapperArgs = [
''--add-flags "--voicelib_dir=${voicevox-core}/lib"''
];
preCheck = ''
# some tests assume $HOME actually exists
export HOME=$(mktemp -d)
# since the actual metadata files have been installed to `$out` by this point,
# we can move the demo metadata back to its place for the tests to succeed
rm -r resources/character_info
mv test_character_info resources/character_info
'';
nativeCheckInputs = with python3Packages; [
pytestCheckHook
syrupy
httpx
];
passthru = {
resources = fetchFromGitHub {
2024-12-21 13:08:17 +01:00
name = "voicevox-resource-${version}"; # this contains ${version} to invalidate the hash upon updating the package
2024-06-12 23:43:26 +02:00
owner = "VOICEVOX";
repo = "voicevox_resource";
2024-12-21 13:08:17 +01:00
tag = version;
2025-07-10 08:47:21 +02:00
hash = "sha256-4D9b5MjJQq+oCqSv8t7CILgFcotbNBH3m2F/up12pPE=";
2024-06-12 23:43:26 +02:00
};
pyopenjtalk = python3Packages.callPackage ./pyopenjtalk.nix { };
};
meta = {
2024-12-21 13:08:17 +01:00
changelog = "https://github.com/VOICEVOX/voicevox_engine/releases/tag/${src.tag}";
2024-06-12 23:43:26 +02:00
description = "Engine for the VOICEVOX speech synthesis software";
homepage = "https://github.com/VOICEVOX/voicevox_engine";
license = lib.licenses.lgpl3Only;
mainProgram = "voicevox-engine";
2024-12-21 13:08:17 +01:00
maintainers = with lib.maintainers; [
tomasajt
eljamm
];
2024-06-12 23:43:26 +02:00
platforms = lib.platforms.linux ++ lib.platforms.darwin;
};
}