summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/kanalizer/default.nix
blob: 5c2a696f3b1cf24399679aff4de9b67368e93e98 (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
{
  lib,
  buildPythonPackage,
  fetchurl,
  fetchFromGitHub,
  rustPlatform,
  pytestCheckHook,
}:

buildPythonPackage (finalAttrs: {
  pname = "kanalizer";
  version = "0.1.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "VOICEVOX";
    repo = "kanalizer";
    tag = finalAttrs.version;
    hash = "sha256-6GxTVlc0Ec80LYQoGgLVRVoi05u6vwt5WGkd4UYX2Lg=";
  };

  sourceRoot = "${finalAttrs.src.name}/infer";

  model =
    let
      modelTag = "v5";
    in
    fetchurl {
      url = "https://huggingface.co/VOICEVOX/kanalizer-model/resolve/${modelTag}/model/c2k.safetensors";
      hash = "sha256-sKhunAsN9Uwz2O1+eFQN8fh09eq67cFotTtLHsWJBRM=";
    };

  prePatch = ''
    substituteInPlace Cargo.toml \
      --replace-fail 'version = "0.0.0"' 'version = "${finalAttrs.version}"'

    ln -s "$model" crates/kanalizer-rs/models/model-c2k.safetensors
  '';

  cargoDeps = rustPlatform.fetchCargoVendor {
    inherit (finalAttrs)
      pname
      version
      src
      sourceRoot
      ;
    hash = "sha256-2vnld5ReLsjm0kRoRAXhm+d0yj7AjfEr83xXhuyPbOU=";
  };

  buildAndTestSubdir = "crates/kanalizer-py";

  nativeBuildInputs = [
    rustPlatform.cargoSetupHook
    rustPlatform.maturinBuildHook
  ];

  nativeCheckInputs = [ pytestCheckHook ];

  pythonImportsCheck = [ "kanalizer" ];

  meta = {
    description = "Library that guesses the Japanese pronounciation of English words";
    homepage = "https://github.com/VOICEVOX/kanalizer";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ tomasajt ];
    sourceProvenance = with lib.sourceTypes; [
      fromSource
      binaryNativeCode # the model file
    ];
  };
})