clavarium 0.2.103-beta.1 → 0.2.104-beta.1

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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.103-beta.1",
3
+ "version": "0.2.104-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.103-beta.1",
9
+ "version": "0.2.104-beta.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.103-beta.1",
3
+ "version": "0.2.104-beta.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
package/server/boxes.mjs CHANGED
@@ -199,6 +199,7 @@ export class Boxes {
199
199
  },
200
200
  };
201
201
  this.#links.set(box.id, link);
202
+ this.#log(`voice box ${box.name}: connected`);
202
203
  let sentence = null; let size = 0;
203
204
  const seen = () => { try { this.#change(box.id, { seenAt: new Date(this.#now()).toISOString() }); } catch { /* withdrawn meanwhile */ } };
204
205
  seen();
@@ -228,18 +229,22 @@ export class Boxes {
228
229
  }
229
230
  if ((m.t === 'ack' || m.t === 'wifi.scan.result') && typeof m.id === 'string') { link.waiting.get(m.id)?.(m); link.waiting.delete(m.id); }
230
231
  });
231
- socket.on('close', () => { if (this.#links.get(box.id) === link) this.#links.delete(box.id); });
232
+ socket.on('close', () => { if (this.#links.get(box.id) === link) { this.#links.delete(box.id); this.#log(`voice box ${box.name}: disconnected`); } });
232
233
  socket.on('error', () => {});
233
234
  }
234
235
 
236
+ /* Each step said in the server's log, never what was said: its length only. */
235
237
  async #heard(link, pcm) {
236
- if (pcm.length < 16_000) { link.send({ t: 'cue', name: 'done' }); return; } /* under half a second: a press, not a sentence */
238
+ const box0 = link.box();
239
+ const seconds = (pcm.length / 32_000).toFixed(1);
240
+ if (pcm.length < 16_000) { this.#log(`voice box ${box0.name}: ${seconds} s heard, too short for a sentence`); link.send({ t: 'cue', name: 'done' }); return; } /* under half a second: a press, not a sentence */
237
241
  link.send({ t: 'cue', name: 'thinking' });
238
242
  let text;
239
- try { text = String(await this.#hear(wavOf(pcm)) ?? '').trim(); } catch (error) { this.#log(`voice box: dictation failed (${error.message})`); link.send({ t: 'cue', name: 'error' }); return; }
240
- if (!text) { link.send({ t: 'cue', name: 'error' }); return; }
243
+ try { text = String(await this.#hear(wavOf(pcm)) ?? '').trim(); } catch (error) { this.#log(`voice box ${box0.name}: ${seconds} s heard, dictation failed (${error.message})`); link.send({ t: 'cue', name: 'error' }); return; }
244
+ if (!text) { this.#log(`voice box ${box0.name}: ${seconds} s heard, nothing recognised (silence?)`); link.send({ t: 'cue', name: 'error' }); return; }
241
245
  const box = link.box();
242
- try { await this.#say(box.conversation, text, { id: box.id, name: box.name, ...(box.place ? { place: box.place } : {}) }); } catch (error) { this.#log(`voice box: not said in ${box.conversation} (${error.message})`); link.send({ t: 'cue', name: 'error' }); return; }
246
+ try { await this.#say(box.conversation, text, { id: box.id, name: box.name, ...(box.place ? { place: box.place } : {}) }); } catch (error) { this.#log(`voice box ${box.name}: ${seconds} s heard and dictated, but not said in ${box.conversation} (${error.message})`); link.send({ t: 'cue', name: 'error' }); return; }
247
+ this.#log(`voice box ${box.name}: ${seconds} s heard, said in ${box.conversation}`);
243
248
  link.heardAt = this.#now();
244
249
  }
245
250