summary refs log tree commit diff
path: root/pkgs/development/python-modules/gruut/default.nix
blob: 5078c6fdb39018705c8f046a6c56281425c1df35 (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
{ lib
, buildPythonPackage
, callPackage
, pythonOlder
, fetchFromGitHub
, Babel
, gruut-ipa
, dateparser
, jsonlines
, num2words
, python-crfsuite
, dataclasses
, python
, networkx
, glibcLocales
, pytestCheckHook
}:

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

  src = fetchFromGitHub {
    owner = "rhasspy";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-B5fPUW4YaMzDDXxncfrWwxGdUizuaxnPImNMf1ZZJ/I=";
  };

  postPatch = ''
    substituteInPlace requirements.txt \
      --replace "dateparser~=1.0.0" "dateparser" \
      --replace "gruut_lang_en~=2.0.0" "gruut_lang_en" \
      --replace "jsonlines~=1.2.0" "jsonlines"
  '';

  propagatedBuildInputs = [
    Babel
    gruut-ipa
    jsonlines
    num2words
    python-crfsuite
    dateparser
    networkx
  ] ++ lib.optionals (pythonOlder "3.7") [
    dataclasses
  ] ++ (map (lang: callPackage ./language-pack.nix {
    inherit lang version format src;
  }) langPkgs);

  checkInputs = [ glibcLocales pytestCheckHook ];

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

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

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

  pythonImportsCheck = [
    "gruut"
  ];

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