signalk-whisper 0.0.1 → 0.1.0

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.
package/README.md CHANGED
@@ -1,16 +1,151 @@
1
1
  # signalk-whisper
2
2
 
3
- > **Status: pre-release placeholder.** This package reserves the name nothing is functional yet. The design is under community review at **[hoeken/signalk-wyoming](https://github.com/hoeken/signalk-wyoming)** read the spec there and leave feedback.
3
+ > **Status: ALPHA** This SignalK Wyoming system is 100% vibecoded slop. I don't have the right hardware yet to test it, so I'm putting it out there for people to test in the meantime. It _should_ work. File issues for anything that doestn.
4
4
 
5
- [Wyoming](https://github.com/rhasspy/wyoming) [Whisper](https://github.com/rhasspy/wyoming-faster-whisper) speech-to-text service for [Signal K](https://signalk.org), running as a managed container. Part of the **signalk-wyoming** offline voice assistant family, but fully standalone: any Wyoming client (including Home Assistant) can use it.
5
+ Whisper speech-to-text for Signal K, speaking the [Wyoming
6
+ protocol](https://github.com/rhasspy/wyoming). The plugin runs the
7
+ [`rhasspy/wyoming-whisper`](https://hub.docker.com/r/rhasspy/wyoming-whisper)
8
+ image in a container managed through
9
+ [signalk-container](https://www.npmjs.com/package/signalk-container), waits
10
+ until the service actually answers a Wyoming `describe` request, keeps
11
+ health-checking it, and advertises it on the shared `wyoming-service`
12
+ discovery channel. It is the STT (ASR) building block of the
13
+ [signalk-wyoming voice-assistant family](https://github.com/hoeken/signalk-wyoming)
14
+ — install it together with the `signalk-wyoming` orchestrator to get voice
15
+ commands on your boat — but it works equally well as a standalone Wyoming
16
+ STT server for other consumers (e.g. Home Assistant).
6
17
 
7
- | Plugin | Role |
8
- |--------|------|
9
- | [signalk-wyoming](https://github.com/hoeken/signalk-wyoming) | Orchestrator spec and discussion live here |
10
- | **signalk-whisper** | Speech-to-text |
11
- | [signalk-piper](https://github.com/hoeken/signalk-piper) | Text-to-speech |
12
- | [signalk-openwakeword](https://github.com/hoeken/signalk-openwakeword) | Wake word detection |
18
+ ## Requirements
19
+
20
+ - Signal K server 2.x on **Node 24+**
21
+ - The **signalk-container** plugin with a working podman or docker runtime
22
+ (this plugin declares `"signalk": { "requires": ["signalk-container"] }`)
23
+ - RAM for the model: the default `tiny-int8` uses roughly **400–500 MB
24
+ resident** (`base-int8` ≈ 700 MB). The container is capped at 1 GB by
25
+ default so a misbehaving model cannot OOM the boat server. A TTS-only
26
+ voice install does not need this plugin at all; the full voice stack with
27
+ whisper is comfortable on a Pi 4/5 with 4 GB.
28
+
29
+ ## Install
30
+
31
+ Install **signalk-whisper** from the Signal K App Store (or `npm install
32
+ signalk-whisper` in your server directory), enable it in Plugin Config, and
33
+ enable the signalk-container plugin if you have not already.
34
+
35
+ ## Configuration
36
+
37
+ | Setting | Default | Notes |
38
+ | ------------------------ | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
39
+ | `model` | `tiny-int8` | One of `tiny-int8`, `base-int8`, `small-int8`, `medium-int8`, `tiny`, `tiny.en`, `base`, `base.en`, `small`, `small.en`, `medium.en`, `turbo`. int8 models are recommended (smaller + faster on CPU). `auto` is deliberately **not** offered: with this image it can silently switch to a ~0.6 B-parameter sherpa/Parakeet backend and download hundreds of MB. |
40
+ | `language` | `en` | Explicit language code. `auto` enables per-utterance detection but costs speed **and** accuracy on the small models — set it explicitly if you can. |
41
+ | `initialPrompt` | nautical word list | Passed as `--initial-prompt` to bias recognition toward your vocabulary — the cheapest accuracy win available. See below. Empty disables it. |
42
+ | `imageTag` | `auto` | `auto` runs the pinned, tested upstream release (**3.5.0**) and follows plugin updates. Set an explicit tag to pin something else. |
43
+ | `port` | `10300` | Host TCP port — only used with `bind: 0.0.0.0`, where the service is published on exactly this port. With the default loopback networking the setting is ignored: signalk-container assigns the host port automatically (10300, or the next free port if that is taken). |
44
+ | `advanced.bind` | `127.0.0.1` | `127.0.0.1` keeps whisper local to the boat server (recommended — the orchestrator is its only intended consumer). `0.0.0.0` publishes it on all interfaces, e.g. to share it with Home Assistant. See Security. |
45
+ | `advanced.memoryLimit` | `1g` | Hard container memory cap (swap capped to the same value). |
46
+ | `advanced.restartPolicy` | `unless-stopped` | Container runtime restart policy. |
47
+
48
+ ### Choosing a model
49
+
50
+ | Model | Download | Resident RAM | When |
51
+ | --------------------------------------- | -------------- | ------------ | ---------------------------------------------------------------------------- |
52
+ | `tiny-int8` | ≈ 43 MB | ≈ 400–500 MB | Default. Fine for short commands on a Pi 4. |
53
+ | `base-int8` | ≈ 80 MB | ≈ 700 MB | Recommended on a Pi 5 / x86 box — noticeably better accuracy. |
54
+ | `small-int8` / `medium-int8` | hundreds of MB | > 1 GB | Only with plenty of RAM/CPU; raise `memoryLimit`. |
55
+ | `tiny`–`small.en`, `medium.en`, `turbo` | larger (float) | more | The `.en` variants are English-only and slightly more accurate at each size. |
56
+
57
+ Transcription latency is the practical constraint: the signalk-wyoming
58
+ webapp's **Test screen** shows a per-transcription latency figure — use it
59
+ to decide whether your hardware can afford a bigger model.
60
+
61
+ ### The initial prompt
62
+
63
+ The shipped default biases Whisper toward sailing vocabulary:
64
+
65
+ > Genoa, jib, mainsail, spinnaker, windlass, gybe, tack, halyard, winch,
66
+ > anchor chain, rode, bilge, galley, helm, autopilot, waypoint, knots, port,
67
+ > starboard, bow, stern, leeward, windward, reef, furl, log position, anchor
68
+ > alarm, engine, throttle.
69
+
70
+ Customize it with words Whisper would otherwise mis-hear, for example:
71
+
72
+ - your **vessel name** ("Wildeling"),
73
+ - **local place and port names** ("Port Townsend, Deception Pass, Anacortes"),
74
+ - **boat-specific gear** ("watermaker, Hydrovane, staysail, preventer").
75
+
76
+ ## First start & offline behavior
77
+
78
+ On first start (and after a model change) the container downloads the model
79
+ into this plugin's Signal K data directory, mounted at `/data` — the
80
+ download survives container recreation and image updates. The plugin status
81
+ shows _"starting — first start downloads the model (tiny-int8 ≈ 43 MB,
82
+ base-int8 ≈ 80 MB)"_ until the service answers; the readiness deadline is
83
+ 10 minutes to allow slow connections. **Do the first start (and any model
84
+ change) while you have internet** — at sea with no connectivity a
85
+ never-downloaded model cannot load, and the plugin will report the failure
86
+ rather than sit silent.
87
+
88
+ ## How other software uses it
89
+
90
+ Once ready, the service is a plain Wyoming STT server at
91
+ `tcp://<host>:<port>` (normally `tcp://127.0.0.1:10300`):
92
+
93
+ - **signalk-wyoming** discovers it automatically: the plugin emits
94
+ `{ plugin: "signalk-whisper", type: "asr", uri, status }` on the
95
+ `wyoming-service` PropertyValues channel on every status change.
96
+ - **Home Assistant** (or any other Wyoming client) can use it as an STT
97
+ provider: set `advanced.bind` to `0.0.0.0` and point HA's Wyoming
98
+ integration at `tcp://<boat-ip>:10300`.
99
+
100
+ Status endpoint (any authenticated user):
101
+ `GET /plugins/signalk-whisper/api/status` →
102
+ `{ status, uri, tag, containerState, lastHealth, info }`. Admins can check
103
+ and apply image updates via `GET /plugins/signalk-whisper/api/update/check`
104
+ and `POST /plugins/signalk-whisper/api/update/apply`.
105
+
106
+ ## Health & notifications
107
+
108
+ After startup the plugin sends a Wyoming `describe` ping every 30 s. Three
109
+ consecutive failures raise the Signal K notification
110
+ **`notifications.voice.whisper`** with `state: "alarm"` (method `visual`
111
+ only — deliberately not `sound`, so notification-to-speech bridges don't
112
+ try to _speak_ the voice stack's own failure), set a plugin error, and mark
113
+ the service `error` on `wyoming-service`. When the service answers again
114
+ everything clears back to `ready`/`normal` automatically. Status flapping
115
+ is debounced (≥ 500 ms between emissions) and pathological churn is logged
116
+ instead of emitted.
117
+
118
+ ## Security
119
+
120
+ Wyoming has **no authentication**. Anyone who can reach the port can feed
121
+ audio to (and read transcripts from) the service. The default
122
+ `bind: 127.0.0.1` keeps it unreachable from the network — only the Signal K
123
+ host (and its containers) can use it. Only switch to `0.0.0.0` on a trusted
124
+ network, and prefer a firewall rule or VLAN that restricts the port to the
125
+ machines that need it (see the signalk-wyoming documentation for a
126
+ marina-wifi hardening recipe).
127
+
128
+ ## Development
129
+
130
+ ```sh
131
+ npm install
132
+ npm run build # tsc → dist/
133
+ npm test # typecheck + vitest (mock Wyoming server, fake container manager)
134
+ npm run ci-lint # eslint + prettier --check
135
+ npm run format # prettier + eslint --fix
136
+ ```
137
+
138
+ Tests run against the scriptable `MockWyomingServer` from the
139
+ [signalk-wyoming](https://github.com/hoeken/signalk-wyoming) package's
140
+ `signalk-wyoming/mock` export and a fake `signalk-container` manager —
141
+ no docker/podman or network access needed.
142
+
143
+ Production code has **no** runtime dependency on the orchestrator package:
144
+ the Wyoming `describe` handshake is a ~140-line embedded client
145
+ (`src/wyoming.ts`).
13
146
 
14
147
  ## License
15
148
 
16
- Apache-2.0
149
+ Apache-2.0 © hoeken. The upstream Whisper service is
150
+ [rhasspy/wyoming-faster-whisper](https://github.com/rhasspy/wyoming-faster-whisper)
151
+ (MIT).
@@ -0,0 +1,138 @@
1
+ /**
2
+ * signalk-whisper configuration: JSON schema, defaults, and the pure
3
+ * settings → ContainerConfig mapping consumed by signalk-container-helper.
4
+ */
5
+ import type { ContainerConfig } from "signalk-container-helper";
6
+ export declare const PLUGIN_ID = "signalk-whisper";
7
+ export declare const PLUGIN_NAME = "Whisper STT (Wyoming)";
8
+ export declare const SERVICE_TYPE = "asr";
9
+ /** Unprefixed container name; runs as `sk-whisper` on the host runtime. */
10
+ export declare const CONTAINER_NAME = "whisper";
11
+ export declare const IMAGE = "rhasspy/wyoming-whisper";
12
+ /** Pinned, tested upstream release; `imageTag: "auto"` resolves to this. */
13
+ export declare const PINNED_TAG = "3.5.0";
14
+ /**
15
+ * Container-side Wyoming port. The image bakes `--uri tcp://0.0.0.0:10300`
16
+ * into its entrypoint, so the container ALWAYS listens on 10300 internally.
17
+ */
18
+ export declare const WYOMING_PORT = 10300;
19
+ export declare const NOTIFICATION_PATH = "notifications.voice.whisper";
20
+ /** First-start model download sizes surfaced in plugin status / README. */
21
+ export declare const DOWNLOAD_HINT = "tiny-int8 \u2248 43 MB, base-int8 \u2248 80 MB";
22
+ /**
23
+ * Models accepted by the `--model` flag. NEVER "auto": with the 3.5.0 image
24
+ * `--model auto --language en` silently switches to a ~0.6B-parameter
25
+ * sherpa/Parakeet backend and downloads hundreds of MB — a disaster on a
26
+ * boat server. int8 models are the recommended choice.
27
+ */
28
+ export declare const WHISPER_MODELS: readonly ["tiny-int8", "base-int8", "small-int8", "medium-int8", "tiny", "tiny.en", "base", "base.en", "small", "small.en", "medium.en", "turbo"];
29
+ export type WhisperModel = (typeof WHISPER_MODELS)[number];
30
+ /**
31
+ * Default `--initial-prompt`: nautical vocabulary that biases Whisper toward
32
+ * sailing terms. The cheapest accuracy win available — user-editable.
33
+ */
34
+ export declare const NAUTICAL_PROMPT: string;
35
+ export interface AdvancedSettings {
36
+ bind: "127.0.0.1" | "0.0.0.0";
37
+ memoryLimit: string;
38
+ restartPolicy: "no" | "unless-stopped" | "always";
39
+ }
40
+ export interface WhisperSettings {
41
+ imageTag: string;
42
+ model: WhisperModel;
43
+ language: string;
44
+ initialPrompt: string;
45
+ port: number;
46
+ advanced: AdvancedSettings;
47
+ }
48
+ export declare function defaultSettings(): WhisperSettings;
49
+ /**
50
+ * Merge raw plugin config over the defaults. Signal K does NOT seed schema
51
+ * defaults into saved configurations, and hand-edited config files can hold
52
+ * anything — every field is validated and falls back to its default.
53
+ * Guarantees `model` is never "auto" (see WHISPER_MODELS).
54
+ */
55
+ export declare function applyDefaults(raw: unknown): WhisperSettings;
56
+ /** Maps the user-facing tag to the tag actually run: "auto" → pinned. */
57
+ export declare function resolveTag(requested: string): string;
58
+ /**
59
+ * Pure, deterministic settings → ContainerConfig mapping. Called on every
60
+ * start/update; the `command` array is always present and stable so
61
+ * signalk-container's drift detection never recreate-loops.
62
+ *
63
+ * Networking: by default the Wyoming port is declared via
64
+ * `signalkAccessiblePorts` (published on host loopback on bare metal; wired
65
+ * to the right network on containerized Signal K). `bind: "0.0.0.0"`
66
+ * switches to an explicit all-interfaces port publish (for sharing the
67
+ * service with e.g. Home Assistant) — the two mechanisms must never be
68
+ * combined on the same port.
69
+ */
70
+ export declare function buildContainerConfig(settings: WhisperSettings, tag: string): ContainerConfig;
71
+ export declare const CONFIG_SCHEMA: {
72
+ readonly type: "object";
73
+ readonly properties: {
74
+ readonly model: {
75
+ readonly type: "string";
76
+ readonly title: "Whisper model";
77
+ readonly enum: readonly ["tiny-int8", "base-int8", "small-int8", "medium-int8", "tiny", "tiny.en", "base", "base.en", "small", "small.en", "medium.en", "turbo"];
78
+ readonly default: "tiny-int8";
79
+ readonly description: string;
80
+ };
81
+ readonly language: {
82
+ readonly type: "string";
83
+ readonly title: "Language";
84
+ readonly default: "en";
85
+ readonly description: string;
86
+ };
87
+ readonly initialPrompt: {
88
+ readonly type: "string";
89
+ readonly title: "Initial prompt (vocabulary hint)";
90
+ readonly default: string;
91
+ readonly description: string;
92
+ };
93
+ readonly imageTag: {
94
+ readonly type: "string";
95
+ readonly title: "Image tag";
96
+ readonly default: "auto";
97
+ readonly description: string;
98
+ };
99
+ readonly port: {
100
+ readonly type: "number";
101
+ readonly title: "Host port";
102
+ readonly default: 10300;
103
+ readonly description: string;
104
+ };
105
+ readonly advanced: {
106
+ readonly type: "object";
107
+ readonly title: "Advanced";
108
+ readonly properties: {
109
+ readonly bind: {
110
+ readonly type: "string";
111
+ readonly title: "Bind address";
112
+ readonly enum: readonly ["127.0.0.1", "0.0.0.0"];
113
+ readonly default: "127.0.0.1";
114
+ readonly description: string;
115
+ };
116
+ readonly memoryLimit: {
117
+ readonly type: "string";
118
+ readonly title: "Memory limit";
119
+ readonly default: "1g";
120
+ readonly description: string;
121
+ };
122
+ readonly restartPolicy: {
123
+ readonly type: "string";
124
+ readonly title: "Restart policy";
125
+ readonly enum: readonly ["no", "unless-stopped", "always"];
126
+ readonly default: "unless-stopped";
127
+ readonly description: "Container runtime restart policy.";
128
+ };
129
+ };
130
+ };
131
+ };
132
+ };
133
+ export declare const UI_SCHEMA: {
134
+ readonly initialPrompt: {
135
+ readonly "ui:widget": "textarea";
136
+ };
137
+ };
138
+ //# sourceMappingUR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AO,GAAG,eAAe,CAkD3D;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,EACzB,GAAG,EAAE,MAAM,GACV,eAAe,CA4BjB;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2FhB,CAAC;AAEX,eAAO,MAAM,SAAS;;;;CAIZ,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,251 @@
1
+ /**
2
+ * signalk-whisper configuration: JSON schema, defaults, and the pure
3
+ * settings → ContainerConfig mapping consumed by signalk-container-helper.
4
+ */
5
+ export const PLUGIN_ID = "signalk-whisper";
6
+ export const PLUGIN_NAME = "Whisper STT (Wyoming)";
7
+ export const SERVICE_TYPE = "asr";
8
+ /** Unprefixed container name; runs as `sk-whisper` on the host runtime. */
9
+ export const CONTAINER_NAME = "whisper";
10
+ export const IMAGE = "rhasspy/wyoming-whisper";
11
+ /** Pinned, tested upstream release; `imageTag: "auto"` resolves to this. */
12
+ export const PINNED_TAG = "3.5.0";
13
+ /**
14
+ * Container-side Wyoming port. The image bakes `--uri tcp://0.0.0.0:10300`
15
+ * into its entrypoint, so the container ALWAYS listens on 10300 internally.
16
+ */
17
+ export const WYOMING_PORT = 10300;
18
+ export const NOTIFICATION_PATH = "notifications.voice.whisper";
19
+ /** First-start model download sizes surfaced in plugin status / README. */
20
+ export const DOWNLOAD_HINT = "tiny-int8 ≈ 43 MB, base-int8 ≈ 80 MB";
21
+ /**
22
+ * Models accepted by the `--model` flag. NEVER "auto": with the 3.5.0 image
23
+ * `--model auto --language en` silently switches to a ~0.6B-parameter
24
+ * sherpa/Parakeet backend and downloads hundreds of MB — a disaster on a
25
+ * boat server. int8 models are the recommended choice.
26
+ */
27
+ export const WHISPER_MODELS = [
28
+ "tiny-int8",
29
+ "base-int8",
30
+ "small-int8",
31
+ "medium-int8",
32
+ "tiny",
33
+ "tiny.en",
34
+ "base",
35
+ "base.en",
36
+ "small",
37
+ "small.en",
38
+ "medium.en",
39
+ "turbo",
40
+ ];
41
+ /**
42
+ * Default `--initial-prompt`: nautical vocabulary that biases Whisper toward
43
+ * sailing terms. The cheapest accuracy win available — user-editable.
44
+ */
45
+ export const NAUTICAL_PROMPT = "Genoa, jib, mainsail, spinnaker, windlass, gybe, tack, halyard, winch, " +
46
+ "anchor chain, rode, bilge, galley, helm, autopilot, waypoint, knots, " +
47
+ "port, starboard, bow, stern, leeward, windward, reef, furl, " +
48
+ "log position, anchor alarm, engine, throttle.";
49
+ export function defaultSettings() {
50
+ return {
51
+ imageTag: "auto",
52
+ model: "tiny-int8",
53
+ language: "en",
54
+ initialPrompt: NAUTICAL_PROMPT,
55
+ port: WYOMING_PORT,
56
+ advanced: {
57
+ bind: "127.0.0.1",
58
+ memoryLimit: "1g",
59
+ restartPolicy: "unless-stopped",
60
+ },
61
+ };
62
+ }
63
+ function isRecord(value) {
64
+ return typeof value === "object" && value !== null && !Array.isArray(value);
65
+ }
66
+ /**
67
+ * Merge raw plugin config over the defaults. Signal K does NOT seed schema
68
+ * defaults into saved configurations, and hand-edited config files can hold
69
+ * anything — every field is validated and falls back to its default.
70
+ * Guarantees `model` is never "auto" (see WHISPER_MODELS).
71
+ */
72
+ export function applyDefaults(raw) {
73
+ const defaults = defaultSettings();
74
+ if (!isRecord(raw))
75
+ return defaults;
76
+ const adv = isRecord(raw.advanced) ? raw.advanced : {};
77
+ const model = typeof raw.model === "string" &&
78
+ WHISPER_MODELS.includes(raw.model)
79
+ ? raw.model
80
+ : defaults.model;
81
+ const language = typeof raw.language === "string" && raw.language.trim() !== ""
82
+ ? raw.language.trim()
83
+ : defaults.language;
84
+ // Empty string is meaningful (disables --initial-prompt entirely).
85
+ const initialPrompt = typeof raw.initialPrompt === "string"
86
+ ? raw.initialPrompt
87
+ : defaults.initialPrompt;
88
+ const imageTag = typeof raw.imageTag === "string" && raw.imageTag.trim() !== ""
89
+ ? raw.imageTag.trim()
90
+ : defaults.imageTag;
91
+ const port = typeof raw.port === "number" &&
92
+ Number.isInteger(raw.port) &&
93
+ raw.port > 0 &&
94
+ raw.port <= 65535
95
+ ? raw.port
96
+ : defaults.port;
97
+ const bind = adv.bind === "0.0.0.0" ? "0.0.0.0" : defaults.advanced.bind;
98
+ const memoryLimit = typeof adv.memoryLimit === "string" && adv.memoryLimit.trim() !== ""
99
+ ? adv.memoryLimit.trim()
100
+ : defaults.advanced.memoryLimit;
101
+ const restartPolicy = adv.restartPolicy === "no" ||
102
+ adv.restartPolicy === "always" ||
103
+ adv.restartPolicy === "unless-stopped"
104
+ ? adv.restartPolicy
105
+ : defaults.advanced.restartPolicy;
106
+ return {
107
+ imageTag,
108
+ model,
109
+ language,
110
+ initialPrompt,
111
+ port,
112
+ advanced: { bind, memoryLimit, restartPolicy },
113
+ };
114
+ }
115
+ /** Maps the user-facing tag to the tag actually run: "auto" → pinned. */
116
+ export function resolveTag(requested) {
117
+ return requested === "auto" ? PINNED_TAG : requested;
118
+ }
119
+ /**
120
+ * Pure, deterministic settings → ContainerConfig mapping. Called on every
121
+ * start/update; the `command` array is always present and stable so
122
+ * signalk-container's drift detection never recreate-loops.
123
+ *
124
+ * Networking: by default the Wyoming port is declared via
125
+ * `signalkAccessiblePorts` (published on host loopback on bare metal; wired
126
+ * to the right network on containerized Signal K). `bind: "0.0.0.0"`
127
+ * switches to an explicit all-interfaces port publish (for sharing the
128
+ * service with e.g. Home Assistant) — the two mechanisms must never be
129
+ * combined on the same port.
130
+ */
131
+ export function buildContainerConfig(settings, tag) {
132
+ const prompt = settings.initialPrompt.trim();
133
+ const command = [
134
+ "--model",
135
+ settings.model,
136
+ "--language",
137
+ settings.language,
138
+ ...(prompt === "" ? [] : ["--initial-prompt", prompt]),
139
+ ];
140
+ const config = {
141
+ image: IMAGE,
142
+ tag,
143
+ command,
144
+ // Model downloads land in /data; mounting the plugin's Signal K data
145
+ // dir there makes them survive container recreation (offline-first).
146
+ signalkDataMount: "/data",
147
+ restart: settings.advanced.restartPolicy,
148
+ resources: {
149
+ memory: settings.advanced.memoryLimit,
150
+ memorySwap: settings.advanced.memoryLimit,
151
+ },
152
+ };
153
+ if (settings.advanced.bind === "0.0.0.0") {
154
+ config.ports = { [String(WYOMING_PORT)]: `0.0.0.0:${settings.port}` };
155
+ }
156
+ else {
157
+ config.signalkAccessiblePorts = [WYOMING_PORT];
158
+ }
159
+ return config;
160
+ }
161
+ export const CONFIG_SCHEMA = {
162
+ type: "object",
163
+ properties: {
164
+ model: {
165
+ type: "string",
166
+ title: "Whisper model",
167
+ enum: [...WHISPER_MODELS],
168
+ default: "tiny-int8",
169
+ description: "Speech-recognition model. The int8 models are recommended: " +
170
+ "tiny-int8 fits a Pi 4, base-int8 is noticeably more accurate on a " +
171
+ "Pi 5 / x86 box. Larger models are slower and use much more RAM — " +
172
+ "use the signalk-wyoming webapp's Test screen latency display to " +
173
+ "guide upgrades. Changing the model downloads it on first use " +
174
+ "(tiny-int8 ≈ 43 MB, base-int8 ≈ 80 MB).",
175
+ },
176
+ language: {
177
+ type: "string",
178
+ title: "Language",
179
+ default: "en",
180
+ description: "Spoken language code (e.g. en, de, fr). 'auto' enables per-utterance " +
181
+ "language detection but costs both speed and accuracy on the small " +
182
+ "models — set it explicitly if you can.",
183
+ },
184
+ initialPrompt: {
185
+ type: "string",
186
+ title: "Initial prompt (vocabulary hint)",
187
+ default: NAUTICAL_PROMPT,
188
+ description: "Text passed to Whisper as --initial-prompt to bias recognition " +
189
+ "toward your vocabulary. Ships with a nautical word list — add your " +
190
+ "vessel name, local port names, and boat-specific gear. Leave empty " +
191
+ "to disable.",
192
+ },
193
+ imageTag: {
194
+ type: "string",
195
+ title: "Image tag",
196
+ default: "auto",
197
+ description: `Docker image tag for ${IMAGE}. 'auto' runs the pinned, tested ` +
198
+ `release (${PINNED_TAG}) and follows this plugin's updates. Set an ` +
199
+ "explicit tag only if you need to pin a different upstream version.",
200
+ },
201
+ port: {
202
+ type: "number",
203
+ title: "Host port",
204
+ default: WYOMING_PORT,
205
+ description: "Host TCP port for the Wyoming service — only used with 'Bind " +
206
+ "address' 0.0.0.0, where the service is published on exactly this " +
207
+ "port. With the default loopback networking this setting is " +
208
+ "ignored: signalk-container assigns the host port automatically " +
209
+ "(normally 10300, the next free port if that is taken).",
210
+ },
211
+ advanced: {
212
+ type: "object",
213
+ title: "Advanced",
214
+ properties: {
215
+ bind: {
216
+ type: "string",
217
+ title: "Bind address",
218
+ enum: ["127.0.0.1", "0.0.0.0"],
219
+ default: "127.0.0.1",
220
+ description: "127.0.0.1 (default) keeps whisper reachable only from this " +
221
+ "machine — the signalk-wyoming orchestrator is its only " +
222
+ "intended consumer. 0.0.0.0 publishes it on all interfaces so " +
223
+ "other systems (e.g. Home Assistant) can share it. Wyoming has " +
224
+ "no authentication: only expose it on trusted networks (see the " +
225
+ "README security notes).",
226
+ },
227
+ memoryLimit: {
228
+ type: "string",
229
+ title: "Memory limit",
230
+ default: "1g",
231
+ description: "Hard container memory cap (docker syntax, e.g. 1g, 1536m). " +
232
+ "Swap is capped to the same value. Keeps a misbehaving model " +
233
+ "from taking down the boat server.",
234
+ },
235
+ restartPolicy: {
236
+ type: "string",
237
+ title: "Restart policy",
238
+ enum: ["no", "unless-stopped", "always"],
239
+ default: "unless-stopped",
240
+ description: "Container runtime restart policy.",
241
+ },
242
+ },
243
+ },
244
+ },
245
+ };
246
+ export const UI_SCHEMA = {
247
+ initialPrompt: {
248
+ "ui:widget": "textarea",
249
+ },
250
+ };
251
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,CAAC,MAAM,SAAS,GAAG,iBAAiB,CAAC;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAG,uBAAuB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S,GAAG;IACvB,aAAa,EAAE;QACb,WAAW,EAAE,UAAU;KACxB;CACO,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * signalk-whisper — Whisper speech-to-text (Wyoming protocol) for Signal K.
3
+ *
4
+ * Runs rhasspy/wyoming-whisper in a container managed via signalk-container
5
+ * (through signalk-container-helper), gates readiness on a Wyoming
6
+ * `describe` handshake, health-checks it, and advertises the service on the
7
+ * shared `wyoming-service` PropertyValues channel for the signalk-wyoming
8
+ * orchestrator (or any other consumer) to discover.
9
+ */
10
+ import type { Plugin, ServerAPI } from "@signalk/server-api";
11
+ import { ServiceRunner, type RunnerTiming } from "./service.js";
12
+ export type { RunnerTiming };
13
+ export { ServiceRunner };
14
+ export default function createPlugin(app: ServerAPI): Plugin;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQ7D,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEhE,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,CAAC;AAgBzB,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CA4F3D"}