1{
2 lib,
3 buildPythonPackage,
4 decorator,
5 fetchFromGitHub,
6 json-rpc,
7 kaldi-active-grammar,
8 lark,
9 packaging,
10 psutil,
11 pynput,
12 pyperclip,
13 pythonOlder,
14 regex,
15 requests,
16 setuptools,
17 six,
18 sounddevice,
19 webrtcvad,
20 werkzeug,
21 wmctrl,
22 xdotool,
23 xorg,
24}:
25
26buildPythonPackage rec {
27 pname = "dragonfly";
28 version = "0.35.0";
29 pyproject = true;
30
31 disabled = pythonOlder "3.7";
32
33 src = fetchFromGitHub {
34 owner = "dictation-toolbox";
35 repo = "dragonfly";
36 tag = version;
37 hash = "sha256-sqEEEr5/KG3cn4rmOGJt9zMNAjeLO6h3NJgg0EyewrM=";
38 };
39
40 postPatch = ''
41 substituteInPlace dragonfly/actions/keyboard/_x11_xdotool.py \
42 --replace-fail 'xdotool = "xdotool"'${" "}'xdotool = "${xdotool}/bin/xdotool"'
43 substituteInPlace dragonfly/windows/x11_window.py \
44 --replace-fail 'xdotool = "xdotool"'${" "}'xdotool = "${xdotool}/bin/xdotool"' \
45 --replace-fail 'xprop = "xprop"'${" "}'xprop = "${xorg.xprop}/bin/xprop"' \
46 --replace-fail 'wmctrl = "wmctrl"'${" "}'wmctrl = "${wmctrl}/bin/wmctrl"'
47 '';
48
49 pythonRemoveDeps = [ "lark-parser" ];
50
51 propagatedBuildInputs = [
52 decorator
53 json-rpc
54 lark
55 packaging
56 psutil
57 pynput
58 pyperclip
59 regex
60 requests
61 setuptools # needs pkg_resources at runtime
62 six
63 werkzeug
64 ];
65
66 optional-dependencies = {
67 kaldi = [
68 kaldi-active-grammar
69 sounddevice
70 webrtcvad
71 ];
72 };
73
74 # Too many tests fail because of the unusual environment or
75 # because of the missing dependencies for some of the engines.
76 doCheck = false;
77
78 pythonImportsCheck = [ "dragonfly" ];
79
80 meta = with lib; {
81 description = "Speech recognition framework allowing powerful Python-based scripting";
82 homepage = "https://github.com/dictation-toolbox/dragonfly";
83 changelog = "https://github.com/dictation-toolbox/dragonfly/blob/${version}/CHANGELOG.rst";
84 license = licenses.lgpl3Plus;
85 maintainers = [ ];
86 };
87}