heystella 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
heystella/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """Hey Stella host: listens for words and drives an Atari 2600 joystick port."""
heystella/__main__.py ADDED
@@ -0,0 +1,184 @@
1
+ """Command line for the Hey Stella host.
2
+
3
+ python -m heystella pitfall listen on the microphone, print actions
4
+ python -m heystella pitfall --input text type phrases instead of speaking
5
+ python -m heystella pitfall --backend keys press keys in the Stella emulator
6
+ python -m heystella pitfall --backend serial:/dev/tty.usbmodem101
7
+ python -m heystella pitfall --input wav:take.wav run a recording and report latency
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import argparse
13
+ import queue
14
+ import sys
15
+ import threading
16
+ import time
17
+ import wave
18
+
19
+ from . import backends
20
+ from .engine import Engine
21
+ from .profiles import PROFILE_DIR, ProfileError, load, profile_paths
22
+ from .recognise import SAMPLE_RATE
23
+
24
+ CHUNK = SAMPLE_RATE // 20 # 50 ms of audio
25
+ DONE = object()
26
+
27
+
28
+ def version() -> str:
29
+ from importlib.metadata import PackageNotFoundError, version as installed
30
+
31
+ try:
32
+ return installed("heystella")
33
+ except PackageNotFoundError:
34
+ return "(running from a checkout)"
35
+
36
+
37
+ def warn_missing(listener) -> None:
38
+ if listener.missing:
39
+ print("These words are not in the speech model and will never be heard: " + ", ".join(listener.missing))
40
+
41
+
42
+ def run_live(engine: Engine, items: queue.Queue, to_phrases) -> None:
43
+ """Take microphone audio or typed lines from a queue until it ends."""
44
+ ending = False
45
+ while True:
46
+ deadline = engine.next_deadline()
47
+ if ending and deadline is None:
48
+ return
49
+ wait = 0.05 if deadline is None else max(0.0, min(0.05, deadline - time.monotonic()))
50
+ try:
51
+ item = items.get(timeout=wait)
52
+ except queue.Empty:
53
+ item = None
54
+ if item is DONE:
55
+ ending = True
56
+ elif item is not None:
57
+ for phrase in to_phrases(item):
58
+ if engine.say(phrase):
59
+ print(f"heard: {phrase}")
60
+ else:
61
+ print(f"not in this profile: {phrase}")
62
+ engine.tick()
63
+
64
+
65
+ def run_text(engine: Engine) -> None:
66
+ items: queue.Queue = queue.Queue()
67
+
68
+ def read_lines():
69
+ for line in sys.stdin:
70
+ if line.strip():
71
+ items.put(line.strip().lower())
72
+ items.put(DONE)
73
+
74
+ threading.Thread(target=read_lines, daemon=True).start()
75
+ print("Type a phrase and press Return. Ctrl-D to finish.")
76
+ run_live(engine, items, lambda line: [line])
77
+
78
+
79
+ def run_mic(engine: Engine, listener) -> None:
80
+ import sounddevice
81
+
82
+ items: queue.Queue = queue.Queue()
83
+ stream = sounddevice.RawInputStream(
84
+ samplerate=SAMPLE_RATE, blocksize=CHUNK, dtype="int16", channels=1,
85
+ callback=lambda data, frames, when, status: items.put(bytes(data)),
86
+ )
87
+ with stream:
88
+ print("Listening. Ctrl-C to stop.")
89
+ run_live(engine, items, listener.accept)
90
+
91
+
92
+ def run_wav(engine: Engine, listener, path: str) -> None:
93
+ """Play a recording through the recogniser, using the audio's own clock."""
94
+ with wave.open(path, "rb") as wav:
95
+ if (wav.getframerate(), wav.getnchannels(), wav.getsampwidth()) != (SAMPLE_RATE, 1, 2):
96
+ sys.exit(f"{path} must be 16 kHz, mono, 16-bit. Convert it first.")
97
+ audio = wav.readframes(wav.getnframes())
98
+ audio += bytes(SAMPLE_RATE * 2) # a second of silence so the last word is finished off
99
+ for start in range(0, len(audio), CHUNK * 2):
100
+ for phrase in listener.accept(audio[start:start + CHUNK * 2]):
101
+ print(f"{listener.heard_s:7.2f}s heard: {phrase}")
102
+ engine.say(phrase)
103
+ engine.tick()
104
+ if listener.latencies:
105
+ print("\nSeconds from the end of a word to acting on it:")
106
+ for phrase, seconds in listener.latencies:
107
+ print(f" {phrase:<16} {seconds:5.2f}")
108
+ values = sorted(s for _, s in listener.latencies)
109
+ print(f" median {values[len(values) // 2]:.2f}, worst {values[-1]:.2f}, {len(values)} phrases")
110
+
111
+
112
+ def main(argv=None) -> int:
113
+ parser = argparse.ArgumentParser(prog="heystella", description="Voice control for the Atari 2600.")
114
+ parser.add_argument("profile", nargs="?", help="profile name such as pitfall, or a path to a .toml file")
115
+ parser.add_argument("--backend", default="print", help="print, keys, or serial:<device>. Default print")
116
+ parser.add_argument("--input", default="mic", help="mic, text, or wav:<file>. Default mic")
117
+ parser.add_argument("--model", help="Vosk model name or folder. Default is the small English model")
118
+ parser.add_argument("--list", action="store_true", help="list the profiles and stop")
119
+ parser.add_argument("--version", action="version", version=f"heystella {version()}")
120
+ args = parser.parse_args(argv)
121
+
122
+ if args.list or not args.profile:
123
+ for path in profile_paths(PROFILE_DIR):
124
+ if path.stem != "_template":
125
+ print(path.stem)
126
+ if not args.list:
127
+ print("\nPick one, for example: heystella pitfall --input text")
128
+ return 0
129
+
130
+ try:
131
+ profile = load(args.profile)
132
+ except ProfileError as error:
133
+ print(error)
134
+ return 1
135
+ print(f"{profile.title}: {', '.join(profile.phrases)}")
136
+
137
+ try:
138
+ listener = None
139
+ clock = time.monotonic
140
+ if args.input != "text":
141
+ from .recognise import VoskListener
142
+
143
+ listener = VoskListener(profile.phrases, args.model)
144
+ warn_missing(listener)
145
+ if args.input.startswith("wav:"):
146
+ clock = lambda: listener.heard_s # noqa: E731
147
+
148
+ if args.backend == "print" and args.input.startswith("wav:"):
149
+ backend = backends.PrintBackend(out=lambda text: print(f"{clock():7.2f}s{text}"))
150
+ else:
151
+ backend = backends.make(args.backend, profile.port)
152
+ engine = Engine(profile, backend, clock)
153
+ except ImportError as error:
154
+ extra = {"vosk": "voice", "sounddevice": "voice", "pynput": "keys", "serial": "serial"}.get(error.name or "", "all")
155
+ print(f"That needs an extra package ({error.name}). Install it with: pip install 'heystella[{extra}]'")
156
+ return 1
157
+ except (ValueError, OSError) as error:
158
+ # An unknown backend name, or a serial device that would not open.
159
+ print(error)
160
+ return 1
161
+
162
+ try:
163
+ if args.input == "text":
164
+ run_text(engine)
165
+ elif args.input == "mic":
166
+ run_mic(engine, listener)
167
+ elif args.input.startswith("wav:"):
168
+ run_wav(engine, listener, args.input.split(":", 1)[1])
169
+ else:
170
+ print(f"unknown input {args.input!r}. Use mic, text or wav:<file>")
171
+ return 1
172
+ except KeyboardInterrupt:
173
+ print()
174
+ except ImportError as error:
175
+ print(f"That needs an extra package ({error.name}). Install it with: pip install 'heystella[voice]'")
176
+ return 1
177
+ finally:
178
+ engine.release_all()
179
+ backend.close()
180
+ return 0
181
+
182
+
183
+ if __name__ == "__main__":
184
+ sys.exit(main())
heystella/backends.py ADDED
@@ -0,0 +1,168 @@
1
+ """Where joystick states and tokens go: the screen, an emulator, or the dongle.
2
+
3
+ Every backend has set_state(mask), send_token(token), idle(now) and close().
4
+ The mask uses the bits in engine.py: up 1, down 2, left 4, right 8, fire 16.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import time
10
+
11
+ from .engine import DOWN, FIRE, LEFT, RIGHT, UP, lines_of
12
+
13
+
14
+ def nibble_mask(nibble: int) -> int:
15
+ """Direction lines for one half of a token. See docs/token-spec.md."""
16
+ mask = 0
17
+ if nibble & 8:
18
+ mask |= RIGHT
19
+ if nibble & 4:
20
+ mask |= LEFT
21
+ if nibble & 2:
22
+ mask |= DOWN
23
+ if nibble & 1:
24
+ mask |= UP
25
+ return mask
26
+
27
+
28
+ def token_timeline(token: int) -> list[tuple[int, int]]:
29
+ """The joystick states that send one token, as (milliseconds, mask) steps."""
30
+ steps = []
31
+ at = 0
32
+ for nibble in (token >> 4, token & 0x0F):
33
+ lines = nibble_mask(nibble)
34
+ steps.append((at, lines)) # directions first
35
+ steps.append((at + 5, lines | FIRE)) # then fire, the "read now" signal
36
+ steps.append((at + 55, lines)) # fire off before the directions move
37
+ steps.append((at + 60, 0))
38
+ at += 110
39
+ return steps
40
+
41
+
42
+ class PrintBackend:
43
+ """Shows what would be sent. For trying a profile with nothing plugged in."""
44
+
45
+ def __init__(self, out=print):
46
+ self.out = out
47
+
48
+ def set_state(self, mask: int) -> None:
49
+ self.out(" joystick: " + (" + ".join(lines_of(mask)) or "released"))
50
+
51
+ def send_token(self, token: int) -> None:
52
+ self.out(f" token: ${token:02X}")
53
+
54
+ def idle(self, now: float) -> None:
55
+ pass
56
+
57
+ def close(self) -> None:
58
+ pass
59
+
60
+
61
+ class RecordBackend:
62
+ """Remembers everything it is sent. For tests."""
63
+
64
+ def __init__(self):
65
+ self.states: list[int] = []
66
+ self.tokens: list[int] = []
67
+
68
+ def set_state(self, mask: int) -> None:
69
+ self.states.append(mask)
70
+
71
+ def send_token(self, token: int) -> None:
72
+ self.tokens.append(token)
73
+
74
+ def idle(self, now: float) -> None:
75
+ pass
76
+
77
+ def close(self) -> None:
78
+ pass
79
+
80
+
81
+ class KeysBackend:
82
+ """Presses keys in whichever window has focus. Meant for the Stella emulator.
83
+
84
+ The keys are Stella 7's defaults: arrows and Space for the left joystick,
85
+ Y H G J and F for the right. macOS asks for Accessibility permission the
86
+ first time.
87
+ """
88
+
89
+ def __init__(self, port: str = "left"):
90
+ from pynput.keyboard import Controller, Key
91
+
92
+ self.keyboard = Controller()
93
+ if port == "left":
94
+ self.keys = {UP: Key.up, DOWN: Key.down, LEFT: Key.left, RIGHT: Key.right, FIRE: Key.space}
95
+ else:
96
+ self.keys = {UP: "y", DOWN: "h", LEFT: "g", RIGHT: "j", FIRE: "f"}
97
+ self.mask = 0
98
+
99
+ def set_state(self, mask: int) -> None:
100
+ for bit, key in self.keys.items():
101
+ if mask & bit and not self.mask & bit:
102
+ self.keyboard.press(key)
103
+ elif self.mask & bit and not mask & bit:
104
+ self.keyboard.release(key)
105
+ self.mask = mask
106
+
107
+ def send_token(self, token: int) -> None:
108
+ # The dongle does this timing in firmware. Here the computer does it, which
109
+ # is accurate enough for an emulator.
110
+ self.set_state(0)
111
+ time.sleep(0.1)
112
+ start = time.monotonic()
113
+ for at_ms, mask in token_timeline(token):
114
+ time.sleep(max(0.0, start + at_ms / 1000 - time.monotonic()))
115
+ self.set_state(mask)
116
+
117
+ def idle(self, now: float) -> None:
118
+ pass
119
+
120
+ def close(self) -> None:
121
+ self.set_state(0)
122
+
123
+
124
+ class SerialBackend:
125
+ """Sends J and T commands to the dongle. See docs/token-spec.md."""
126
+
127
+ KEEPALIVE_S = 1.0
128
+
129
+ def __init__(self, device: str, baud: int = 115200):
130
+ import serial
131
+
132
+ self.port = serial.Serial(device, baud, timeout=0.2, write_timeout=0.5)
133
+ self.mask = 0
134
+ self.last_sent = 0.0
135
+
136
+ def _send(self, line: str) -> None:
137
+ # No flush here. Waiting for the bytes to drain can block the whole loop
138
+ # if the dongle stops reading, and a stuck host is worse than a late byte.
139
+ self.port.write((line + "\n").encode("ascii"))
140
+ self.last_sent = time.monotonic()
141
+
142
+ def set_state(self, mask: int) -> None:
143
+ self.mask = mask
144
+ self._send(f"J{mask:02X}")
145
+
146
+ def send_token(self, token: int) -> None:
147
+ self._send(f"T{token:02X}")
148
+
149
+ def idle(self, now: float) -> None:
150
+ # The dongle lets go of everything if it hears nothing for 5 seconds, so
151
+ # repeat the state while anything is held.
152
+ if self.mask and time.monotonic() - self.last_sent >= self.KEEPALIVE_S:
153
+ self._send(f"J{self.mask:02X}")
154
+
155
+ def close(self) -> None:
156
+ self._send("J00")
157
+ self.port.close()
158
+
159
+
160
+ def make(spec: str, port: str = "left"):
161
+ """Build a backend from a command-line value: print, keys, or serial:/dev/..."""
162
+ if spec == "print":
163
+ return PrintBackend()
164
+ if spec == "keys":
165
+ return KeysBackend(port)
166
+ if spec.startswith("serial:"):
167
+ return SerialBackend(spec.split(":", 1)[1])
168
+ raise ValueError(f"unknown backend {spec!r}. Use print, keys or serial:<device>")
heystella/engine.py ADDED
@@ -0,0 +1,103 @@
1
+ """Turns spoken phrases into joystick states over time.
2
+
3
+ The engine knows nothing about audio or hardware. Give it a profile, a backend
4
+ and a clock. Call say() when a phrase is heard and tick() often.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import time
10
+ from typing import Callable
11
+
12
+ from .profiles import Profile
13
+
14
+ UP, DOWN, LEFT, RIGHT, FIRE = 1, 2, 4, 8, 16
15
+ LINE_BITS = {"up": UP, "down": DOWN, "left": LEFT, "right": RIGHT, "fire": FIRE}
16
+ OPPOSITE = {"left": "right", "right": "left", "up": "down", "down": "up"}
17
+
18
+
19
+ def mask_of(lines) -> int:
20
+ mask = 0
21
+ for line in lines:
22
+ mask |= LINE_BITS[line]
23
+ return mask
24
+
25
+
26
+ def lines_of(mask: int) -> list[str]:
27
+ return [name for name, bit in LINE_BITS.items() if mask & bit]
28
+
29
+
30
+ class Engine:
31
+ def __init__(self, profile: Profile, backend, clock: Callable[[], float] = time.monotonic):
32
+ self.profile = profile
33
+ self.backend = backend
34
+ self.clock = clock
35
+ self.held: set[str] = set()
36
+ # Timed presses as (start, end, lines), in the order they were asked for.
37
+ self.pulses: list[tuple[float, float, tuple[str, ...]]] = []
38
+ self.last_mask = 0
39
+
40
+ def say(self, phrase: str) -> bool:
41
+ """Act on a phrase. Returns False if the profile does not know it."""
42
+ entry = self.profile.spoken.get(phrase)
43
+ if entry is None:
44
+ return False
45
+ now = self.clock()
46
+ if "token" in entry:
47
+ self.backend.send_token(entry["token"])
48
+ elif "tap" in entry:
49
+ ms = entry.get("ms", self.profile.tap_ms)
50
+ self.pulses.append((now, now + ms / 1000, tuple(entry["tap"])))
51
+ elif "hold" in entry:
52
+ for line in entry["hold"]:
53
+ self.held.discard(OPPOSITE.get(line, ""))
54
+ self.held.add(line)
55
+ elif "release" in entry:
56
+ if entry["release"] == "all":
57
+ self.held.clear()
58
+ self.pulses.clear()
59
+ else:
60
+ self.held.difference_update(entry["release"])
61
+ elif "sequence" in entry:
62
+ at = now
63
+ for step in entry["sequence"]:
64
+ if "wait" in step:
65
+ at += step["wait"] / 1000
66
+ else:
67
+ end = at + step["ms"] / 1000
68
+ self.pulses.append((at, end, tuple(step["press"])))
69
+ at = end
70
+ self.tick()
71
+ return True
72
+
73
+ def mask(self, now: float) -> int:
74
+ pressed = set(self.held)
75
+ for start, end, lines in self.pulses:
76
+ if start <= now < end:
77
+ # A timed press wins over a held opposite, and a later press over an
78
+ # earlier one. Left and right are never down together.
79
+ for line in lines:
80
+ pressed.discard(OPPOSITE.get(line, ""))
81
+ pressed.update(lines)
82
+ return mask_of(pressed)
83
+
84
+ def tick(self) -> None:
85
+ """Send the current state to the backend if it has changed."""
86
+ now = self.clock()
87
+ self.pulses = [p for p in self.pulses if p[1] > now]
88
+ mask = self.mask(now)
89
+ if mask != self.last_mask:
90
+ self.backend.set_state(mask)
91
+ self.last_mask = mask
92
+ self.backend.idle(now)
93
+
94
+ def next_deadline(self) -> float | None:
95
+ """When tick() next needs to run, or None if nothing is scheduled."""
96
+ now = self.clock()
97
+ times = [t for start, end, _ in self.pulses for t in (start, end) if t > now]
98
+ return min(times) if times else None
99
+
100
+ def release_all(self) -> None:
101
+ self.held.clear()
102
+ self.pulses.clear()
103
+ self.tick()
@@ -0,0 +1,73 @@
1
+ # Game profiles
2
+
3
+ A profile tells the dongle what each spoken word does in one game. One TOML file per game.
4
+
5
+ ## A complete example
6
+
7
+ ```toml
8
+ [game]
9
+ title = "Space Invaders"
10
+ publisher = "Atari"
11
+ year = 1980
12
+
13
+ [profile]
14
+ author = "your-github-name"
15
+ mode = "joystick"
16
+ port = "left"
17
+ tested_on = ["stella"]
18
+ notes = "Say stop before you fire if you want to aim."
19
+
20
+ [defaults]
21
+ tap_ms = 120
22
+
23
+ [words]
24
+ left = { hold = ["left"] }
25
+ right = { hold = ["right"] }
26
+ stop = { release = "all" }
27
+ fire = { tap = ["fire"], aliases = ["shoot"] }
28
+ "step left" = { tap = ["left"] }
29
+ ```
30
+
31
+ ## Words
32
+
33
+ The name on the left is what the player says. Use one to four words in lower-case letters. No digits or punctuation, because the on-device recogniser rejects them. Write "two", not "2".
34
+
35
+ `aliases` lists other things the player can say for the same action.
36
+
37
+ Good words are short, common and sound different from each other. In testing, "halt" was heard as "hold" for British and Australian voices. Made-up words do not work at all, because the recognisers look words up in a pronunciation dictionary. The host warns you at start-up if a word is not in its dictionary.
38
+
39
+ ## Actions
40
+
41
+ Each word has exactly one action. The lines are `up`, `down`, `left`, `right` and `fire`.
42
+
43
+ | Action | Example | What it does |
44
+ | --- | --- | --- |
45
+ | `tap` | `{ tap = ["fire"] }` | Presses, waits `tap_ms`, lets go. Lines that are already held stay held, so you can jump while running. Add `ms = 300` to change the time for one word. |
46
+ | `hold` | `{ hold = ["left"] }` | Presses and keeps pressed. Holding left lets go of right, and the same for up and down. |
47
+ | `release` | `{ release = "all" }` | Lets go of everything, or of the lines you list. |
48
+ | `sequence` | `{ sequence = [ { press = ["down"], ms = 200 }, { wait = 100 }, { press = ["fire"], ms = 150 } ] }` | Runs steps in order, for moves that need timing. |
49
+ | `token` | `{ token = 0x10 }` | Data mode only. Sends a number to a homebrew game. See [../docs/token-spec.md](../docs/token-spec.md). |
50
+
51
+ A profile that uses `hold` must have a word that uses `release`. Otherwise the player cannot stop.
52
+
53
+ Left and right can never be pressed together, and neither can up and down. A real joystick cannot do it and some games break.
54
+
55
+ ## Check your profile
56
+
57
+ ```
58
+ python3 tools/validate_profiles.py
59
+ ```
60
+
61
+ It prints `ok` or a list of what to fix for each file.
62
+
63
+ ## Trying it out
64
+
65
+ The host program in [../host/](../host/) plays a profile. From the `host` folder:
66
+
67
+ ```
68
+ python3 -m heystella space-invaders --input text
69
+ ```
70
+
71
+ That lets you type phrases and see what the joystick would do, with nothing to install. Speaking and driving Stella need a few packages, and [../host/README.md](../host/README.md) has the steps.
72
+
73
+ The five starter profiles have not been played by a person yet, so their `tested_on` is empty.
@@ -0,0 +1,31 @@
1
+ # Copy this file, rename it after the game (lower case, hyphens, .toml),
2
+ # and edit. Full guide: profiles/README.md
3
+ # Check your work: python3 tools/validate_profiles.py
4
+
5
+ [game]
6
+ title = "Game Title"
7
+ publisher = "Publisher"
8
+ year = 1982
9
+
10
+ [profile]
11
+ author = "your-github-name"
12
+ mode = "joystick" # "joystick" for existing games, "data" for homebrew that reads tokens
13
+ port = "left" # which console port the dongle plugs into
14
+ tested_on = [] # add "stella" or "console" once you have played it this way
15
+ notes = "Anything a player should know."
16
+
17
+ [defaults]
18
+ tap_ms = 150 # how long a tap holds the button
19
+
20
+ [words]
21
+ # tap: press, wait tap_ms, let go. Lines that are already held stay held.
22
+ fire = { tap = ["fire"], aliases = ["shoot"] }
23
+
24
+ # hold: press and keep pressed. Holding left lets go of right, and so on.
25
+ left = { hold = ["left"] }
26
+ right = { hold = ["right"] }
27
+ up = { hold = ["up"] }
28
+ down = { hold = ["down"] }
29
+
30
+ # release: let go of the named lines, or "all".
31
+ stop = { release = "all" }
@@ -0,0 +1,25 @@
1
+ # Slow and forgiving, so a good first game to play by voice.
2
+ # The fire button drops whatever you are carrying.
3
+
4
+ [game]
5
+ title = "Adventure"
6
+ publisher = "Atari"
7
+ year = 1980
8
+
9
+ [profile]
10
+ author = "michael-borck"
11
+ mode = "joystick"
12
+ port = "left"
13
+ tested_on = []
14
+ notes = "Untested draft."
15
+
16
+ [defaults]
17
+ tap_ms = 150
18
+
19
+ [words]
20
+ north = { hold = ["up"], aliases = ["up"] }
21
+ south = { hold = ["down"], aliases = ["down"] }
22
+ west = { hold = ["left"], aliases = ["left"] }
23
+ east = { hold = ["right"], aliases = ["right"] }
24
+ stop = { release = "all", aliases = ["wait"] }
25
+ drop = { tap = ["fire"] }
@@ -0,0 +1,28 @@
1
+ # A starting point for any one-button joystick game.
2
+ # Directions latch until you say "stop". "Tap left" nudges once.
3
+
4
+ [game]
5
+ title = "Generic joystick"
6
+
7
+ [profile]
8
+ author = "michael-borck"
9
+ mode = "joystick"
10
+ port = "left"
11
+ tested_on = []
12
+ notes = "Use this when a game has no profile of its own, then copy it and tune the words."
13
+
14
+ [defaults]
15
+ tap_ms = 150
16
+
17
+ [words]
18
+ left = { hold = ["left"] }
19
+ right = { hold = ["right"] }
20
+ up = { hold = ["up"] }
21
+ down = { hold = ["down"] }
22
+ stop = { release = "all" }
23
+ fire = { tap = ["fire"], aliases = ["shoot"] }
24
+ "hold fire" = { hold = ["fire"] }
25
+ "tap left" = { tap = ["left"] }
26
+ "tap right" = { tap = ["right"] }
27
+ "tap up" = { tap = ["up"] }
28
+ "tap down" = { tap = ["down"] }
@@ -0,0 +1,26 @@
1
+ # Run with "left" or "right", then call "jump" as you reach a pit.
2
+ # The run keeps going through the jump, as it would with a joystick.
3
+
4
+ [game]
5
+ title = "Pitfall!"
6
+ publisher = "Activision"
7
+ year = 1982
8
+
9
+ [profile]
10
+ author = "michael-borck"
11
+ mode = "joystick"
12
+ port = "left"
13
+ tested_on = []
14
+ notes = "Untested draft. Jump timing depends on measured latency, so expect to call jumps early."
15
+
16
+ [defaults]
17
+ tap_ms = 150
18
+
19
+ [words]
20
+ left = { hold = ["left"] }
21
+ right = { hold = ["right"] }
22
+ stop = { release = "all" }
23
+ jump = { tap = ["fire"], aliases = ["hop"] }
24
+ climb = { hold = ["up"] }
25
+ down = { hold = ["down"], aliases = ["descend"] }
26
+ drop = { tap = ["down"] }
@@ -0,0 +1,24 @@
1
+ # "Left" and "right" slide until "stop". "Step left" nudges the cannon one tap.
2
+
3
+ [game]
4
+ title = "Space Invaders"
5
+ publisher = "Atari"
6
+ year = 1980
7
+
8
+ [profile]
9
+ author = "michael-borck"
10
+ mode = "joystick"
11
+ port = "left"
12
+ tested_on = []
13
+ notes = "Untested draft."
14
+
15
+ [defaults]
16
+ tap_ms = 120
17
+
18
+ [words]
19
+ left = { hold = ["left"] }
20
+ right = { hold = ["right"] }
21
+ stop = { release = "all" }
22
+ fire = { tap = ["fire"], aliases = ["shoot"] }
23
+ "step left" = { tap = ["left"] }
24
+ "step right" = { tap = ["right"] }
@@ -0,0 +1,26 @@
1
+ # Data-mode example. The game receives the token, not a joystick movement.
2
+ # The word list is a placeholder until the game design settles in phase 3.
3
+
4
+ [game]
5
+ title = "Spell Caster"
6
+ publisher = "Retroverse Studios"
7
+
8
+ [profile]
9
+ author = "michael-borck"
10
+ mode = "data"
11
+ port = "left"
12
+ tested_on = []
13
+ notes = "Homebrew demo for this project. Spell names are real English words so the recognisers can hear them."
14
+
15
+ [words]
16
+ start = { token = 0x09 }
17
+ yes = { token = 0x07 }
18
+ no = { token = 0x08 }
19
+ ember = { token = 0x10 }
20
+ frost = { token = 0x11 }
21
+ thunder = { token = 0x12 }
22
+ shield = { token = 0x13 }
23
+ mirror = { token = 0x14 }
24
+ shadow = { token = 0x15 }
25
+ heal = { token = 0x16 }
26
+ banish = { token = 0x17 }
heystella/profiles.py ADDED
@@ -0,0 +1,266 @@
1
+ """Game profiles: the rules for a valid profile, and loading one for play.
2
+
3
+ tools/validate_profiles.py runs main() from here, so the validator and the
4
+ host cannot disagree about what a profile means. Standard library only.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import argparse
10
+ import json
11
+ import re
12
+ import sys
13
+ import tomllib
14
+ from dataclasses import dataclass, field
15
+ from pathlib import Path
16
+
17
+ # An installed copy carries the profiles inside the package. A checkout of the
18
+ # repo keeps them in profiles/ at the top, two folders up from here.
19
+ _PACKAGED = Path(__file__).resolve().parent / "profiles"
20
+ PROFILE_DIR = _PACKAGED if _PACKAGED.is_dir() else Path(__file__).resolve().parents[2] / "profiles"
21
+
22
+ LINES = {"up", "down", "left", "right", "fire"}
23
+ OPPOSITES = [{"left", "right"}, {"up", "down"}]
24
+ ACTIONS = ("tap", "hold", "release", "sequence", "token")
25
+ MODES = {"joystick", "data"}
26
+ PORTS = {"left", "right"}
27
+ TESTED_ON = {"stella", "console"}
28
+
29
+ # Core tokens are the same in every game. Keep in step with docs/token-spec.md.
30
+ CORE_TOKENS = {
31
+ "up": 0x01, "down": 0x02, "left": 0x03, "right": 0x04, "fire": 0x05,
32
+ "stop": 0x06, "yes": 0x07, "no": 0x08, "start": 0x09, "pause": 0x0A,
33
+ }
34
+ GAME_TOKEN_MIN, GAME_TOKEN_MAX = 0x10, 0x7F
35
+
36
+ # Lower-case letters only. The on-device recogniser rejects digits and symbols.
37
+ PHRASE = re.compile(r"^[a-z]+( [a-z]+){0,3}$")
38
+ FILENAME = re.compile(r"^(_template|[a-z0-9]+(-[a-z0-9]+)*)\.toml$")
39
+
40
+
41
+ def check_lines(value, where: str, errors: list[str]) -> None:
42
+ if not isinstance(value, list) or not value:
43
+ errors.append(f"{where}: expected a list such as [\"left\"]")
44
+ return
45
+ unknown = [v for v in value if v not in LINES]
46
+ if unknown:
47
+ errors.append(f"{where}: unknown line {unknown[0]!r}, use one of {sorted(LINES)}")
48
+ for pair in OPPOSITES:
49
+ if pair <= set(value):
50
+ a, b = sorted(pair)
51
+ errors.append(f"{where}: {a} and {b} cannot be pressed together")
52
+
53
+
54
+ def check_ms(value, where: str, errors: list[str]) -> None:
55
+ if not isinstance(value, int) or isinstance(value, bool) or not 30 <= value <= 5000:
56
+ errors.append(f"{where}: expected a whole number of milliseconds from 30 to 5000")
57
+
58
+
59
+ def check_word(phrase: str, entry, mode: str, errors: list[str]) -> None:
60
+ where = f"words.{phrase!r}"
61
+ if not isinstance(entry, dict):
62
+ errors.append(f"{where}: expected a table such as {{ tap = [\"fire\"] }}")
63
+ return
64
+ present = [a for a in ACTIONS if a in entry]
65
+ if len(present) != 1:
66
+ errors.append(f"{where}: needs exactly one of {', '.join(ACTIONS)}")
67
+ return
68
+ action = present[0]
69
+ extra = set(entry) - {action, "aliases", "ms"}
70
+ if extra:
71
+ errors.append(f"{where}: unknown key {sorted(extra)[0]!r}")
72
+
73
+ if mode == "data" and action != "token":
74
+ errors.append(f"{where}: a data-mode profile only uses token")
75
+ if mode == "joystick" and action == "token":
76
+ errors.append(f"{where}: token only works in a data-mode profile")
77
+
78
+ value = entry[action]
79
+ if action in ("tap", "hold"):
80
+ check_lines(value, where, errors)
81
+ elif action == "release":
82
+ if value != "all":
83
+ check_lines(value, where, errors)
84
+ elif action == "sequence":
85
+ if not isinstance(value, list) or not value:
86
+ errors.append(f"{where}: sequence needs a list of steps")
87
+ else:
88
+ for i, step in enumerate(value):
89
+ step_where = f"{where} step {i + 1}"
90
+ if not isinstance(step, dict):
91
+ errors.append(f"{step_where}: expected a table")
92
+ elif set(step) == {"wait"}:
93
+ check_ms(step["wait"], step_where, errors)
94
+ elif set(step) == {"press", "ms"}:
95
+ check_lines(step["press"], step_where, errors)
96
+ check_ms(step["ms"], step_where, errors)
97
+ else:
98
+ errors.append(f"{step_where}: use {{ press = [...], ms = 150 }} or {{ wait = 100 }}")
99
+ elif action == "token":
100
+ if not isinstance(value, int) or isinstance(value, bool):
101
+ errors.append(f"{where}: token must be a number such as 0x10")
102
+ elif phrase in CORE_TOKENS:
103
+ if value != CORE_TOKENS[phrase]:
104
+ errors.append(f"{where}: this is a core word, its token is 0x{CORE_TOKENS[phrase]:02X}")
105
+ elif not GAME_TOKEN_MIN <= value <= GAME_TOKEN_MAX:
106
+ errors.append(f"{where}: game tokens run from 0x10 to 0x7F")
107
+
108
+ if "ms" in entry:
109
+ if action != "tap":
110
+ errors.append(f"{where}: ms only applies to tap")
111
+ else:
112
+ check_ms(entry["ms"], where, errors)
113
+
114
+
115
+ def validate(path: Path) -> tuple[dict | None, list[str]]:
116
+ errors: list[str] = []
117
+ if not FILENAME.match(path.name):
118
+ errors.append("file name must be lower case with hyphens, such as space-invaders.toml")
119
+ try:
120
+ data = tomllib.loads(path.read_text(encoding="utf-8"))
121
+ except (tomllib.TOMLDecodeError, UnicodeDecodeError) as exc:
122
+ return None, errors + [f"not valid TOML: {exc}"]
123
+
124
+ game = data.get("game", {})
125
+ if not isinstance(game.get("title"), str) or not game.get("title", "").strip():
126
+ errors.append("game.title is missing")
127
+ if "year" in game and not (isinstance(game["year"], int) and 1977 <= game["year"] <= 2100):
128
+ errors.append("game.year should be a year such as 1982")
129
+
130
+ profile = data.get("profile", {})
131
+ if not isinstance(profile.get("author"), str) or not profile.get("author", "").strip():
132
+ errors.append("profile.author is missing")
133
+ mode = profile.get("mode")
134
+ if mode not in MODES:
135
+ errors.append("profile.mode must be \"joystick\" or \"data\"")
136
+ if profile.get("port", "left") not in PORTS:
137
+ errors.append("profile.port must be \"left\" or \"right\"")
138
+ tested = profile.get("tested_on", [])
139
+ if not isinstance(tested, list) or set(tested) - TESTED_ON:
140
+ errors.append(f"profile.tested_on may contain {sorted(TESTED_ON)}")
141
+
142
+ if "tap_ms" in data.get("defaults", {}):
143
+ check_ms(data["defaults"]["tap_ms"], "defaults.tap_ms", errors)
144
+
145
+ words = data.get("words")
146
+ if not isinstance(words, dict) or not words:
147
+ return data, errors + ["no [words] section, or it is empty"]
148
+
149
+ seen: dict[str, str] = {}
150
+ tokens: dict[int, str] = {}
151
+ holds = releases = False
152
+ for phrase, entry in words.items():
153
+ check_word(phrase, entry, mode, errors)
154
+ if not isinstance(entry, dict):
155
+ continue
156
+ holds = holds or "hold" in entry
157
+ releases = releases or "release" in entry
158
+ aliases = entry.get("aliases", [])
159
+ if not isinstance(aliases, list):
160
+ errors.append(f"words.{phrase!r}: aliases must be a list")
161
+ aliases = []
162
+ for spoken in [phrase, *aliases]:
163
+ if not isinstance(spoken, str) or not PHRASE.match(spoken):
164
+ errors.append(f"{spoken!r}: use one to four words, lower-case letters only")
165
+ elif spoken in seen:
166
+ errors.append(f"{spoken!r} is used for both {seen[spoken]!r} and {phrase!r}")
167
+ else:
168
+ seen[spoken] = phrase
169
+ token = entry.get("token")
170
+ if isinstance(token, int) and not isinstance(token, bool):
171
+ if token in tokens:
172
+ errors.append(f"token 0x{token:02X} is used for both {tokens[token]!r} and {phrase!r}")
173
+ tokens[token] = phrase
174
+
175
+ if holds and not releases:
176
+ errors.append("a word uses hold but nothing uses release, so the player could never stop. Add a stop word.")
177
+ return data, errors
178
+
179
+
180
+ @dataclass
181
+ class Profile:
182
+ """A validated profile, ready to play."""
183
+
184
+ name: str
185
+ title: str
186
+ mode: str
187
+ port: str
188
+ tap_ms: int
189
+ # What the player says, mapped to the word entry it triggers. Includes aliases.
190
+ spoken: dict[str, dict] = field(default_factory=dict)
191
+
192
+ @property
193
+ def phrases(self) -> list[str]:
194
+ return sorted(self.spoken)
195
+
196
+
197
+ class ProfileError(ValueError):
198
+ pass
199
+
200
+
201
+ def load(name_or_path: str | Path) -> Profile:
202
+ """Load a profile by name ("pitfall") or by path. Raises ProfileError if it is not valid."""
203
+ path = Path(name_or_path)
204
+ if path.suffix != ".toml":
205
+ path = PROFILE_DIR / f"{name_or_path}.toml"
206
+ if not path.is_file():
207
+ known = ", ".join(sorted(p.stem for p in profile_paths(PROFILE_DIR) if p.stem != "_template"))
208
+ raise ProfileError(f"no profile at {path}. Known profiles: {known}")
209
+ data, errors = validate(path)
210
+ if errors:
211
+ raise ProfileError(f"{path.name} is not valid:\n " + "\n ".join(errors))
212
+ profile = Profile(
213
+ name=path.stem,
214
+ title=data["game"]["title"],
215
+ mode=data["profile"]["mode"],
216
+ port=data["profile"].get("port", "left"),
217
+ tap_ms=data.get("defaults", {}).get("tap_ms", 150),
218
+ )
219
+ for phrase, entry in data["words"].items():
220
+ for said in [phrase, *entry.get("aliases", [])]:
221
+ profile.spoken[said] = entry
222
+ return profile
223
+
224
+
225
+ def profile_paths(directory: Path) -> list[Path]:
226
+ # macOS leaves "._name" shadow files on exFAT drives. They are not profiles.
227
+ return sorted(p for p in directory.glob("*.toml") if not p.name.startswith("._"))
228
+
229
+
230
+ def main() -> int:
231
+ parser = argparse.ArgumentParser(description="Check every game profile and optionally bundle them as JSON.")
232
+ parser.add_argument("--dir", type=Path, default=PROFILE_DIR)
233
+ parser.add_argument("--bundle", type=Path, help="write all valid profiles to this JSON file")
234
+ args = parser.parse_args()
235
+
236
+ paths = profile_paths(args.dir)
237
+ if not paths:
238
+ print(f"no profiles found in {args.dir}")
239
+ return 1
240
+
241
+ bundle: dict[str, dict] = {}
242
+ failed = 0
243
+ for path in paths:
244
+ data, errors = validate(path)
245
+ if errors:
246
+ failed += 1
247
+ print(f"FAIL {path.name}")
248
+ for error in errors:
249
+ print(f" {error}")
250
+ else:
251
+ print(f"ok {path.name}")
252
+ if path.stem != "_template":
253
+ bundle[path.stem] = data
254
+
255
+ print(f"\n{len(paths) - failed} of {len(paths)} profiles pass")
256
+ if failed:
257
+ return 1
258
+ if args.bundle:
259
+ args.bundle.parent.mkdir(parents=True, exist_ok=True)
260
+ args.bundle.write_text(json.dumps(bundle, indent=2) + "\n", encoding="utf-8")
261
+ print(f"wrote {args.bundle}")
262
+ return 0
263
+
264
+
265
+ if __name__ == "__main__":
266
+ sys.exit(main())
heystella/recognise.py ADDED
@@ -0,0 +1,125 @@
1
+ """Speech to phrases, using Vosk limited to the words in one profile."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+
7
+ SAMPLE_RATE = 16000
8
+ UNKNOWN = "[unk]"
9
+ DEFAULT_MODEL = "vosk-model-small-en-us-0.15"
10
+
11
+
12
+ class PhraseMatcher:
13
+ """Finds profile phrases in the recogniser's running guess.
14
+
15
+ Vosk reports a partial guess many times a second while someone is talking,
16
+ then a final result when they pause. Acting on partials saves the length of
17
+ that pause, which is most of the delay. The one case that has to wait is a
18
+ phrase that begins a longer one: after "tap" we cannot act until we know
19
+ whether "tap left" is coming.
20
+ """
21
+
22
+ def __init__(self, phrases):
23
+ self.phrases = set(phrases)
24
+ self.longest = max((len(p.split()) for p in self.phrases), default=1)
25
+ self.prefixes = set()
26
+ for phrase in self.phrases:
27
+ words = phrase.split()
28
+ for n in range(1, len(words)):
29
+ self.prefixes.add(" ".join(words[:n]))
30
+ self.consumed = 0
31
+ # (phrase, index after its last word) for this utterance, for latency timing.
32
+ self.spans: list[tuple[str, int]] = []
33
+
34
+ def feed(self, words: list[str], final: bool) -> list[str]:
35
+ """Take the words heard so far in this utterance. Return phrases to act on."""
36
+ if len(words) < self.consumed:
37
+ # The recogniser changed its mind about words we already used.
38
+ self.consumed = len(words)
39
+ found = []
40
+ while self.consumed < len(words):
41
+ rest = words[self.consumed:]
42
+ if rest[0] == UNKNOWN:
43
+ self.consumed += 1
44
+ continue
45
+ match = 0
46
+ for n in range(min(self.longest, len(rest)), 0, -1):
47
+ if " ".join(rest[:n]) in self.phrases:
48
+ match = n
49
+ break
50
+ # Everything left could still be the start of something longer.
51
+ could_grow = len(rest) < self.longest and " ".join(rest) in self.prefixes
52
+ if not final and could_grow:
53
+ break
54
+ if match:
55
+ self.consumed += match
56
+ phrase = " ".join(rest[:match])
57
+ self.spans.append((phrase, self.consumed))
58
+ found.append(phrase)
59
+ else:
60
+ self.consumed += 1
61
+ if final:
62
+ self.consumed = 0
63
+ self.spans = []
64
+ return found
65
+
66
+
67
+ class VoskListener:
68
+ """Feed it 16 kHz mono 16-bit audio. It returns the phrases it hears."""
69
+
70
+ def __init__(self, phrases, model: str | None = None):
71
+ import vosk
72
+
73
+ vosk.SetLogLevel(-1)
74
+ # A path loads that folder. A name downloads the model once to ~/.cache/vosk.
75
+ if model and ("/" in model or model.startswith(".")):
76
+ self.model = vosk.Model(model_path=model)
77
+ else:
78
+ self.model = vosk.Model(model_name=model or DEFAULT_MODEL)
79
+ words = sorted({w for p in phrases for w in p.split()})
80
+ self.missing = [w for w in words if self.model.vosk_model_find_word(w) < 0]
81
+ grammar = json.dumps(sorted(phrases) + [UNKNOWN])
82
+ self.recogniser = vosk.KaldiRecognizer(self.model, SAMPLE_RATE, grammar)
83
+ self.recogniser.SetWords(True)
84
+ self.matcher = PhraseMatcher(phrases)
85
+ self.heard_s = 0.0
86
+ self.pending: list[tuple[str, int, float]] = []
87
+ # (phrase, seconds between the end of the word and acting on it)
88
+ self.latencies: list[tuple[str, float]] = []
89
+
90
+ def accept(self, audio: bytes) -> list[str]:
91
+ self.heard_s += len(audio) / 2 / SAMPLE_RATE
92
+ if self.recogniser.AcceptWaveform(audio):
93
+ result = json.loads(self.recogniser.Result())
94
+ words = result.get("text", "").split()
95
+ found = self.matcher.feed(words, final=True)
96
+ self._time_phrases(result.get("result", []), words, found)
97
+ return found
98
+ words = json.loads(self.recogniser.PartialResult()).get("partial", "").split()
99
+ before = len(self.matcher.spans)
100
+ found = self.matcher.feed(words, final=False)
101
+ for phrase, end_index in self.matcher.spans[before:]:
102
+ self.pending.append((phrase, end_index, self.heard_s))
103
+ return found
104
+
105
+ def _time_phrases(self, timed_words, words, found_at_final) -> None:
106
+ # Vosk only gives word times in the final result, so latency is worked
107
+ # out after the fact: when we acted, minus when the last word ended.
108
+ def ended(phrase, end_index):
109
+ size = len(phrase.split())
110
+ if end_index > len(timed_words) or " ".join(words[end_index - size:end_index]) != phrase:
111
+ return None
112
+ return timed_words[end_index - 1]["end"]
113
+
114
+ for phrase, end_index, acted_at in self.pending:
115
+ word_end = ended(phrase, end_index)
116
+ if word_end is not None:
117
+ self.latencies.append((phrase, acted_at - word_end))
118
+ # Phrases first heard at the pause sit at the end of the word list.
119
+ end_index = len(words)
120
+ for phrase in reversed(found_at_final):
121
+ word_end = ended(phrase, end_index)
122
+ if word_end is not None:
123
+ self.latencies.append((phrase, self.heard_s - word_end))
124
+ end_index -= len(phrase.split())
125
+ self.pending = []
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.5
2
+ Name: heystella
3
+ Version: 0.1.0
4
+ Summary: Voice control for the Atari 2600. Say a word and the console sees a joystick move.
5
+ Project-URL: Homepage, https://github.com/retroverse-studios/hey-stella
6
+ Project-URL: Repository, https://github.com/retroverse-studios/hey-stella
7
+ Project-URL: Issues, https://github.com/retroverse-studios/hey-stella/issues
8
+ Author: Michael Borck
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: accessibility,atari,atari-2600,joystick,retro,speech-recognition,stella,voice-control
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: End Users/Desktop
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Games/Entertainment
21
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
22
+ Classifier: Topic :: System :: Hardware
23
+ Requires-Python: >=3.11
24
+ Provides-Extra: all
25
+ Requires-Dist: pynput>=1.7; extra == 'all'
26
+ Requires-Dist: pyserial>=3.5; extra == 'all'
27
+ Requires-Dist: sounddevice>=0.4; extra == 'all'
28
+ Requires-Dist: vosk>=0.3.44; extra == 'all'
29
+ Provides-Extra: keys
30
+ Requires-Dist: pynput>=1.7; extra == 'keys'
31
+ Provides-Extra: serial
32
+ Requires-Dist: pyserial>=3.5; extra == 'serial'
33
+ Provides-Extra: voice
34
+ Requires-Dist: sounddevice>=0.4; extra == 'voice'
35
+ Requires-Dist: vosk>=0.3.44; extra == 'voice'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # Hey Stella
39
+
40
+ Voice control for the Atari 2600. Say "left" and the console sees a joystick pushed left.
41
+
42
+ This package is the host program. It listens to a microphone, recognises the words in a game profile, and turns them into joystick actions. Those go to the Stella emulator as key presses, or to a small build-it-yourself dongle that plugs into a real console's joystick port.
43
+
44
+ **Early software.** It works with typed input and recorded speech. It has not been tried with a live microphone yet, no dongle has been built, and nothing has touched a real console. Expect rough edges and please report them.
45
+
46
+ ## Install
47
+
48
+ ```
49
+ pipx install "heystella[all]"
50
+ ```
51
+
52
+ or with pip:
53
+
54
+ ```
55
+ pip install "heystella[all]"
56
+ ```
57
+
58
+ Python 3.11 or newer. The extras are optional:
59
+
60
+ | Extra | Adds | For |
61
+ | --- | --- | --- |
62
+ | `voice` | vosk, sounddevice | Speech recognition from a microphone |
63
+ | `keys` | pynput | Pressing keys in the Stella emulator |
64
+ | `serial` | pyserial | Talking to the dongle over USB |
65
+
66
+ A plain `pip install heystella` has no dependencies and can still run profiles from typed input. On Linux the microphone needs PortAudio, for example `sudo apt install libportaudio2`.
67
+
68
+ ## Use
69
+
70
+ ```
71
+ heystella --list # the game profiles that come with it
72
+ heystella pitfall --input text # type phrases, see what the joystick does
73
+ heystella pitfall # speak, see what the joystick does
74
+ heystella pitfall --backend keys # speak, and press keys in Stella
75
+ heystella pitfall --backend serial:/dev/ttyACM0 # speak, and drive the dongle
76
+ heystella my-game.toml --input wav:take.wav # test your own profile against a recording
77
+ ```
78
+
79
+ The first spoken run downloads a 40MB speech model to `~/.cache/vosk`. After that everything runs offline.
80
+
81
+ ## Game profiles
82
+
83
+ A profile is a short TOML file that says what each spoken word does in one game.
84
+
85
+ ```toml
86
+ [game]
87
+ title = "Space Invaders"
88
+
89
+ [profile]
90
+ author = "your-name"
91
+ mode = "joystick"
92
+
93
+ [words]
94
+ left = { hold = ["left"] }
95
+ right = { hold = ["right"] }
96
+ stop = { release = "all" }
97
+ fire = { tap = ["fire"], aliases = ["shoot"] }
98
+ ```
99
+
100
+ Five starter profiles are included. To write your own, pass the path to your `.toml` file in place of a profile name.
101
+
102
+ ## More
103
+
104
+ The hardware design, the token protocol for homebrew games, a test ROM and the project plan are in the repository.
105
+
106
+ MIT licence. Atari and Atari 2600 are trademarks of their owner. Stella is also the name of an emulator, which this project works with and is not part of. No connection to either.
@@ -0,0 +1,18 @@
1
+ heystella/__init__.py,sha256=ET1yFWJ1_XRTIr8JIVmn5Gi45V4EHUyL-0pKY1i3XeY,81
2
+ heystella/__main__.py,sha256=Crn_I_BSKr5zn9jwCxnPy6FZp8KbL7MwptU4KXEbiRI,6948
3
+ heystella/backends.py,sha256=08Ybu5N23KTpXdBsL_ttjiMGH6tm-ndgF7ZuXqVIZlA,5203
4
+ heystella/engine.py,sha256=ysj3_pEzcYicwoEnfS96LmPz7mmYml9vze227IRPeQc,3639
5
+ heystella/profiles.py,sha256=WdYRhgmnwS5IYbGhO5SIEGCaGmZsmwGBiffp35glI2k,10494
6
+ heystella/recognise.py,sha256=5yNOmgPWtGUk8eBvjfLSWznV8HdsqvcxqsyK-TCXsgw,5348
7
+ heystella/profiles/README.md,sha256=9m5m_Sq448qMhDTJu_YsXK888r0RF-5LTXBTWQ_LQMg,2800
8
+ heystella/profiles/_template.toml,sha256=mOpdKv-1yU4mCiV7I-vPzDilAu4fkk0KZHUByJY5B2Y,1032
9
+ heystella/profiles/adventure.toml,sha256=tAqJwPeTdgrvMjaOY8L8ZRiG_CNhnVbC2BrARN6EDfM,576
10
+ heystella/profiles/generic-joystick.toml,sha256=oxw56lLUFnBmUU9sdNifVIdF1plq5H00SDCGsmo2RfE,701
11
+ heystella/profiles/pitfall.toml,sha256=WkxzMAVqaCC8ZL5uX9-MUoirNY0AbPVX0Kpj2hwi0Po,645
12
+ heystella/profiles/space-invaders.toml,sha256=3IJrK6c-DbmxmvuAM292UAvvFm7rZmekZ7hrgHEF3F8,486
13
+ heystella/profiles/spell-caster.toml,sha256=tWAe8n9HNUpjqm-9GFvsTjwsgRWQnEoZOyb4pLc7SFA,688
14
+ heystella-0.1.0.dist-info/METADATA,sha256=T9BoEP4JX8B9j7u0nt1L4D7wUVCa8xf-EPnHwkIv8ko,4121
15
+ heystella-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
16
+ heystella-0.1.0.dist-info/entry_points.txt,sha256=4IOp1nJVCcksqh8NpINguKBAz55h9JcqHPt3QdilUy4,54
17
+ heystella-0.1.0.dist-info/licenses/LICENSE,sha256=MYAlkmTyVWlba5RJ-1fS_OHHL1apYX9LlC1JuIU7ab4,1070
18
+ heystella-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ heystella = heystella.__main__:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 michael-borck
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.