-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
134 lines (102 loc) · 3.5 KB
/
tasks.py
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from invoke import task
# =============== DEV Tasks ================
@task
def reformat(ctx):
"""Apply isort and ruff formatting"""
ctx.run("isort .")
ctx.run("ruff format .")
@task
def checks(ctx):
"""Run ruff and isort checks"""
ctx.run(
"""
echo "👀 Checking code formatting..."
ruff format --check .
echo "👀 Checking import formatting..."
isort --check .
echo "👀 Checking linting rules..."
ruff check .
"""
)
@task
def tests(ctx):
"""Run pytests"""
ctx.run("pytest --cov --spec -n 2")
# =============== Base Tasks ================
@task
def print_audio_devices(ctx):
"""List available audio devices"""
ctx.run("python -m respeaker print-audio-devices")
@task
def print_audio_cards(ctx):
"""List available audio devices"""
ctx.run("cat /proc/asound/cards")
ctx.run("arecord -L")
ctx.run("aplay -L")
@task
def build_nlu(ctx):
"""Build NLU docker image [jmrf/nlu-rpi]"""
from raspvan.version import __version__
print(f"🔨 Building image: jmrf/nlu-rpi:{__version__}")
ctx.run(
f"docker build --rm -t jmrf/nlu-rpi:{__version__}"
"-f ./nlu/dockerfiles/Dockerfile ./nlu"
)
@task
def pixels(ctx):
"""Run the Respeaker respeaker.pixels:__main__"""
ctx.run("python -m respeaker.pixels")
@task
def ble_server(ctx):
"""Start Redis and run the BLE (Bluetooth Low Energy) Server.
First starts REDIS and configured the 1st bluetooth device mode to
'Page and Inquiry Scan' to accept connections and scan for other devices.
"""
# Start Redis
ctx.run("docker-compose up -d redis")
# Set BT device 0 to 'Page and Inquiry Scan':
# Page: Respond to connection requests from other Bluetooth devices
# Inquiry Scan: Actively scan for nearby Bluetooth devices to discover them.
ctx.run("sudo hciconfig hci0 piscan")
# Start the BLE server
ctx.run("sudo python -m raspvan.ble_server")
@task
def relays(ctx):
"""Run the Relay worker"""
ctx.run("python -m raspvan.workers.relay")
@task
def hot_word(ctx):
"""[DEPRECATED] Start RabbitMQ and run the hotword detection worker and publishes to 'hotword.detected'"""
ctx.run("docker-compose up -d rabbit")
ctx.run("python -m raspvan.workers.hotword -pt hotword.detected")
@task
def asr(ctx):
"""[DEPRECATED] Start RabbitMQ and run the ASR worker service.
- Consuming from the topic 'hotword.detected'
- Publishes to 'asr.complete'
"""
ctx.run("docker-compose up -d rabbit asr-server")
ctx.run("python -m raspvan.workers.asr -ct hotword.detected -pt asr.complete")
@task
def nlu(ctx):
"""[DEPRECATED] Run the NLU worker service listening to the ASR.complete trigger"""
ctx.run("python -m raspvan.workers.nlu -ct asr.complete")
@task
def run(ctx, device: int = 5):
"""Run a simplified version of the system - no need for RabbitMQ"""
print("🧑🏭 Starting ASR, NLU and Redis docker containers...")
ctx.run("docker compose up -d asr nlu redis")
print("🚀 Starting voice assistant pipeline...")
ctx.run(f"source .venv/bin/activate; python -m raspvan -d {device}")
@task
def toc(ctx):
"""Gnerate a Table Of Contents for the README file"""
# https://github.com/ekalinin/github-markdown-toc
ctx.run(
"find . "
"! -path '.venv/*' "
"! -path './kaldi/*' "
"! -path './external/*' "
"! -path './hotword/mycroft-precise/*' "
r"-name README.md -exec gh-md-toc --insert {} \;"
)