@bevyra/avatar 1.0.1 → 1.0.4

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
@@ -23,9 +23,16 @@ const session = await client.connect('noora');
23
23
  const clauseId = session.sendAudio(pcm16At16kHz);
24
24
  for await (const event of session.events()) {
25
25
  // clause.audio precedes binary PCM; clause.frame precedes binary JPEG.
26
+ // idle.frame precedes binary JPEG; idle.done ends each requested batch.
26
27
  // Frame N is scheduled at audio time N * 40 ms.
27
28
  if (event.type === 'clause.done' && event.clauseId === clauseId) break;
28
29
  }
30
+ // Request recorded silence once the speech clause has finished.
31
+ session.idle(4);
32
+ for await (const event of session.events()) {
33
+ // idle.frame precedes its binary JPEG; present frames 40 ms apart.
34
+ if (event.type === 'idle.done') break;
35
+ }
29
36
  session.close(); client.close();
30
37
  ```
31
38
 
package/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare class AvatarClient {
12
12
  }
13
13
  export declare class AvatarSession {
14
14
  sendAudio(pcm: Buffer | Int16Array): number;
15
+ idle(count?: number): void;
15
16
  interrupt(): void;
16
17
  close(): void;
17
18
  events(): AsyncIterable<AvatarEvent>;
package/index.js CHANGED
@@ -6,7 +6,7 @@ import path from "node:path";
6
6
  import readline from "node:readline";
7
7
  import WebSocket from "ws";
8
8
 
9
- const VERSION = "1.0.1";
9
+ const VERSION = "1.0.4";
10
10
 
11
11
  function python() {
12
12
  if (process.env.BEVYRA_PYTHON) return { executable: process.env.BEVYRA_PYTHON, prefix: [] };
@@ -95,6 +95,11 @@ export class AvatarSession {
95
95
  this.socket.send(JSON.stringify({ type: "clause.end", clauseId }));
96
96
  return clauseId;
97
97
  }
98
+ idle(count = 4) {
99
+ if (!Number.isInteger(count) || count < 1 || count > 9)
100
+ throw new RangeError("Idle request must contain 1–9 recorded frames");
101
+ this.socket.send(JSON.stringify({ type: "session.idle", count }));
102
+ }
98
103
  interrupt() { this.generation++; this.socket.send(JSON.stringify({ type: "session.interrupt", generation: this.generation })); }
99
104
  close() { this.socket.close(); }
100
105
  async *events() { while (!this.closed || this.pending.length) { const event = this.pending.length ? this.pending.shift() : await new Promise(resolve => this.waiters.push(resolve)); if (event === null) return; yield event; } }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bevyra/avatar",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "API-authorized local BeVyra avatar service for Node.js",
5
5
  "homepage": "https://bevyra.ai/docs",
6
6
  "bugs": {"url": "https://bevyra.ai/docs"},