1{
2 lib,
3 buildPythonPackage,
4 fetchurl,
5 fetchFromGitHub,
6 rustPlatform,
7 pytestCheckHook,
8}:
9
10buildPythonPackage rec {
11 pname = "kanalizer";
12 version = "0.1.1";
13 pyproject = true;
14
15 src = fetchFromGitHub {
16 owner = "VOICEVOX";
17 repo = "kanalizer";
18 tag = version;
19 hash = "sha256-6GxTVlc0Ec80LYQoGgLVRVoi05u6vwt5WGkd4UYX2Lg=";
20 };
21
22 sourceRoot = "${src.name}/infer";
23
24 model =
25 let
26 modelTag = "v5";
27 in
28 fetchurl {
29 url = "https://huggingface.co/VOICEVOX/kanalizer-model/resolve/${modelTag}/model/c2k.safetensors";
30 hash = "sha256-sKhunAsN9Uwz2O1+eFQN8fh09eq67cFotTtLHsWJBRM=";
31 };
32
33 prePatch = ''
34 substituteInPlace Cargo.toml \
35 --replace-fail 'version = "0.0.0"' 'version = "${version}"'
36
37 ln -s "$model" crates/kanalizer-rs/models/model-c2k.safetensors
38 '';
39
40 cargoDeps = rustPlatform.fetchCargoVendor {
41 inherit
42 pname
43 version
44 src
45 sourceRoot
46 ;
47 hash = "sha256-2vnld5ReLsjm0kRoRAXhm+d0yj7AjfEr83xXhuyPbOU=";
48 };
49
50 buildAndTestSubdir = "crates/kanalizer-py";
51
52 nativeBuildInputs = [
53 rustPlatform.cargoSetupHook
54 rustPlatform.maturinBuildHook
55 ];
56
57 nativeCheckInputs = [ pytestCheckHook ];
58
59 pythonImportsCheck = [ "kanalizer" ];
60
61 meta = {
62 description = "Library that guesses the Japanese pronounciation of English words";
63 homepage = "https://github.com/VOICEVOX/kanalizer";
64 license = lib.licenses.mit;
65 maintainers = with lib.maintainers; [ tomasajt ];
66 sourceProvenance = with lib.sourceTypes; [
67 fromSource
68 binaryNativeCode # the model file
69 ];
70 };
71}