about summary refs log tree commit diff
path: root/pkgs/development/python-modules/gruut/default.nix
blob: e5ad36e1b19b58a54135514a62ba5d76cb13027f (plain) (blame)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{
  lib,
  buildPythonPackage,
  callPackage,
  fetchFromGitHub,

  # build-system
  setuptools,

  # dependencies
  babel,
  dateparser,
  gruut-ipa,
  jsonlines,
  networkx,
  num2words,
  numpy,
  python-crfsuite,

  # optional dependencies
  pydub,
  rapidfuzz,

  # checks
  glibcLocales,
  pytestCheckHook,
}:

let
  langPkgs = [
    "ar"
    "ca"
    "cs"
    "de"
    "en"
    "es"
    "fa"
    "fr"
    "it"
    "lb"
    "nl"
    "pt"
    "ru"
    "sv"
    "sw"
  ];
in
buildPythonPackage rec {
  pname = "gruut";
  version = "2.4.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "rhasspy";
    repo = "gruut";
    rev = "refs/tags/v${version}";
    hash = "sha256-iwde6elsAbICZ+Rc7CPgcZTOux1hweVZc/gf4K+hP9M=";
  };

  pythonRelaxDeps = true;

  build-system = [ setuptools ];

  dependencies = [
    babel
    dateparser
    gruut-ipa
    jsonlines
    networkx
    num2words
    numpy
    python-crfsuite
  ] ++ optional-dependencies.en;

  optional-dependencies =
    {
      train = [
        pydub
        rapidfuzz
      ];
    }
    // lib.genAttrs langPkgs (lang: [
      (callPackage ./language-pack.nix {
        inherit
          lang
          version
          src
          build-system
          ;
      })
    ]);

  nativeCheckInputs = [
    glibcLocales
    pytestCheckHook
  ] ++ lib.flatten (lib.attrValues optional-dependencies);

  disabledTests = [
    # https://github.com/rhasspy/gruut/issues/25
    "test_lexicon_external"

    # requires mishkal library
    "test_fa"
    "test_ar"
  ];

  preCheck = ''
    export LC_ALL=en_US.utf-8
  '';

  pythonImportsCheck = [ "gruut" ];

  meta = with lib; {
    description = "Tokenizer, text cleaner, and phonemizer for many human languages";
    mainProgram = "gruut";
    homepage = "https://github.com/rhasspy/gruut";
    license = licenses.mit;
    maintainers = teams.tts.members;
  };
}