about summary refs log tree commit diff
path: root/pkgs/development/python-modules/dragonfly/default.nix
blob: 74740aeffb7eede811adf615078b1e4a2a52b444 (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
{ lib
, buildPythonPackage
, fetchFromGitHub
, decorator
, packaging
, pynput
, regex
, lark
, enum34
, pyperclip
, six
, requests
, psutil
, json-rpc
, werkzeug
, kaldi-active-grammar
, sounddevice
, webrtcvad
, setuptools
, xdotool
, wmctrl
, xorg
}:

buildPythonPackage rec {
  pname = "dragonfly";
  version = "0.35.0";

  src = fetchFromGitHub {
    owner = "dictation-toolbox";
    repo = pname;
    rev = version;
    sha256 = "sha256-sqEEEr5/KG3cn4rmOGJt9zMNAjeLO6h3NJgg0EyewrM=";
  };

  postPatch = ''
    substituteInPlace setup.py --replace 'lark-parser == 0.8.*' 'lark'
    substituteInPlace dragonfly/actions/keyboard/_x11_xdotool.py \
      --replace 'xdotool = "xdotool"'${" "}'xdotool = "${xdotool}/bin/xdotool"'
    substituteInPlace dragonfly/windows/x11_window.py \
      --replace 'xdotool = "xdotool"'${" "}'xdotool = "${xdotool}/bin/xdotool"' \
      --replace 'xprop = "xprop"'${" "}'xprop = "${xorg.xprop}/bin/xprop"' \
      --replace 'wmctrl = "wmctrl"'${" "}'wmctrl = "${wmctrl}/bin/wmctrl"'
  '';

  propagatedBuildInputs = [
    decorator
    packaging
    pynput
    regex
    lark
    enum34
    pyperclip
    six
    requests
    psutil
    json-rpc
    werkzeug
    kaldi-active-grammar # for the Kaldi engine
    sounddevice
    webrtcvad
    setuptools # needs pkg_resources at runtime
  ];

  # Too many tests fail because of the unusual environment or
  # because of the missing dependencies for some of the engines.
  doCheck = false;

  pythonImportsCheck = [ "dragonfly" ];

  meta = with lib; {
    description = "Speech recognition framework allowing powerful Python-based scripting";
    homepage = "https://github.com/dictation-toolbox/dragonfly";
    license = licenses.lgpl3Plus;
    maintainers = with maintainers; [ ckie ];
  };
}