@celljs/ta-protocol 4.17.0 → 4.18.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.
Files changed (49) hide show
  1. package/esm/common/access-protocol.d.ts +41 -0
  2. package/esm/common/access-protocol.js +7 -0
  3. package/esm/common/app-protocol.d.ts +7 -2
  4. package/esm/common/app-protocol.js +14 -0
  5. package/esm/common/deployment-protocol.d.ts +13 -0
  6. package/esm/common/deployment-protocol.js +36 -0
  7. package/esm/common/index.d.ts +2 -0
  8. package/esm/common/index.js +2 -0
  9. package/esm/common/message-protocol.d.ts +43 -4
  10. package/esm/common/message-protocol.js +97 -12
  11. package/esm/common/room-protocol.d.ts +45 -0
  12. package/esm/common/said-protocol.d.ts +76 -0
  13. package/esm/common/said-protocol.js +239 -0
  14. package/esm/common/screen-share-protocol.d.ts +304 -0
  15. package/esm/common/screen-share-protocol.js +88 -0
  16. package/esm/common/settings-protocol.d.ts +8 -0
  17. package/esm/common/settings-protocol.js +2 -0
  18. package/esm/common/ta-extension-host.d.ts +33 -0
  19. package/esm/common/ta-extension-host.js +6 -0
  20. package/esm/common/ta-protocol.d.ts +3 -0
  21. package/esm/common/team-protocol.d.ts +13 -2
  22. package/esm/common/team-protocol.js +27 -2
  23. package/esm/common/voice-protocol.d.ts +45 -0
  24. package/esm/common/voice-protocol.js +54 -0
  25. package/lib/common/access-protocol.d.ts +41 -0
  26. package/lib/common/access-protocol.js +8 -1
  27. package/lib/common/app-protocol.d.ts +7 -2
  28. package/lib/common/app-protocol.js +14 -0
  29. package/lib/common/deployment-protocol.d.ts +13 -0
  30. package/lib/common/deployment-protocol.js +36 -0
  31. package/lib/common/index.d.ts +2 -0
  32. package/lib/common/index.js +2 -0
  33. package/lib/common/message-protocol.d.ts +43 -4
  34. package/lib/common/message-protocol.js +98 -13
  35. package/lib/common/room-protocol.d.ts +45 -0
  36. package/lib/common/said-protocol.d.ts +77 -0
  37. package/lib/common/said-protocol.js +242 -0
  38. package/lib/common/screen-share-protocol.d.ts +305 -0
  39. package/lib/common/screen-share-protocol.js +91 -0
  40. package/lib/common/settings-protocol.d.ts +8 -0
  41. package/lib/common/settings-protocol.js +3 -1
  42. package/lib/common/ta-extension-host.d.ts +33 -0
  43. package/lib/common/ta-extension-host.js +7 -1
  44. package/lib/common/ta-protocol.d.ts +3 -0
  45. package/lib/common/team-protocol.d.ts +13 -2
  46. package/lib/common/team-protocol.js +28 -3
  47. package/lib/common/voice-protocol.d.ts +45 -0
  48. package/lib/common/voice-protocol.js +55 -1
  49. package/package.json +1 -1
@@ -34,6 +34,47 @@ export interface TaVoices {
34
34
  types: TaVoiceTypeInfo[];
35
35
  /** voices.json in the agent directory, to edit by hand. */
36
36
  file: string;
37
+ /** When a sound stops what a service reads: voices.json `bargeIn` over the defaults. */
38
+ bargeIn: TaBargeIn;
39
+ }
40
+ /**
41
+ * When a sound heard while Ta reads is the user cutting in (voices.json `bargeIn`, docs/design/ta-voice.md): the reading
42
+ * first goes on lower, and stops only once the sound is speech long enough or words in its transcript.
43
+ */
44
+ export interface TaBargeIn {
45
+ /** How loud the reading goes on while a sound may be the user cutting in, 0 to 1. */
46
+ duck: number;
47
+ /** ms of speech that stop the reading: a cough, a knock, a cup set down is shorter. */
48
+ speechMs: number;
49
+ /** The level (RMS, 0 to 1) of the microphone, after its noise suppression, that counts as speech. */
50
+ level: number;
51
+ /** Letters or digits heard in the sound that stop the reading. */
52
+ words: number;
53
+ /** ms after which a sound not known as speech lets the reading go on loud again. */
54
+ waitMs: number;
55
+ /**
56
+ * Ta's own voice heard back: a sound of the microphone softer than this times what plays (after the lowering) is
57
+ * taken for its echo, not the user; nor are words heard while Ta plays with no such louder sound. 0: none is.
58
+ */
59
+ echo: number;
60
+ /** A sentence the service ended while the user's voice was heard this few ms before goes on: a short pause. */
61
+ joinMs: number;
62
+ /** Only a tap stops the reading: the user's voice never does. */
63
+ tap: boolean;
64
+ }
65
+ export declare namespace TaBargeIn {
66
+ const DEFAULTS: TaBargeIn;
67
+ /**
68
+ * The steps of the sensitivity of Settings, from the least to the most: how long and how loud speech must be to
69
+ * stop the reading. The middle one is the default.
70
+ */
71
+ const SENSITIVITY: Pick<TaBargeIn, 'speechMs' | 'level'>[];
72
+ /** The step of SENSITIVITY nearest to `bargeIn`, by how long speech must be. */
73
+ function sensitivity(bargeIn: TaBargeIn): number;
74
+ /** Of what is given, the keys of TaBargeIn of the right kind, numbers each kept in its range. */
75
+ function pick(value: unknown): Partial<TaBargeIn>;
76
+ /** What voices.json says, each value a number in its range, the default for one left out or wrong. */
77
+ function resolve(value: unknown): TaBargeIn;
37
78
  }
38
79
  /** A voice opened for a call (TaVoiceServer.openVoice). */
39
80
  export interface TaVoiceSession {
@@ -43,6 +84,8 @@ export interface TaVoiceSession {
43
84
  /** The rate of the PCM16 mono of `audio` events. */
44
85
  outputRate: number;
45
86
  speaks: boolean;
87
+ /** When a sound stops the reading: voices.json `bargeIn` over the defaults. */
88
+ bargeIn?: TaBargeIn;
46
89
  }
47
90
  /** What a voice opened by a connection tells it (TaClient.onVoiceEvent). */
48
91
  export type TaVoiceEvent =
@@ -90,6 +133,8 @@ export interface TaVoiceServer {
90
133
  removeVoice(id: string): Promise<void>;
91
134
  /** The service calls use from now on; null for the voice of the device. */
92
135
  chooseVoice(id: string | null): Promise<void>;
136
+ /** Sets keys of `bargeIn` in voices.json, the others kept; the next call goes by it. */
137
+ setBargeIn(bargeIn: Partial<TaBargeIn>): Promise<void>;
93
138
  /** Opens the service in use for a call of this connection; it closes as the connection does. */
94
139
  openVoice(options: {
95
140
  language: string;
@@ -1,6 +1,60 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TA_VOICE_SERVICE = exports.TaVoiceServer = void 0;
3
+ exports.TaBargeIn = exports.TA_VOICE_SERVICE = exports.TaVoiceServer = void 0;
4
4
  exports.TaVoiceServer = Symbol('TaVoiceServer');
5
5
  exports.TA_VOICE_SERVICE = 'TaVoiceServer';
6
+ var TaBargeIn;
7
+ (function (TaBargeIn) {
8
+ TaBargeIn.DEFAULTS = { duck: 0.2, speechMs: 500, level: 0.02, words: 2, waitMs: 1500, echo: 0.3, joinMs: 300, tap: false };
9
+ /**
10
+ * The steps of the sensitivity of Settings, from the least to the most: how long and how loud speech must be to
11
+ * stop the reading. The middle one is the default.
12
+ */
13
+ TaBargeIn.SENSITIVITY = [
14
+ { speechMs: 1000, level: 0.05 },
15
+ { speechMs: 750, level: 0.035 },
16
+ { speechMs: TaBargeIn.DEFAULTS.speechMs, level: TaBargeIn.DEFAULTS.level },
17
+ { speechMs: 300, level: 0.012 },
18
+ { speechMs: 150, level: 0.006 },
19
+ ];
20
+ /** The step of SENSITIVITY nearest to `bargeIn`, by how long speech must be. */
21
+ function sensitivity(bargeIn) {
22
+ let nearest = 0;
23
+ TaBargeIn.SENSITIVITY.forEach((step, index) => {
24
+ if (Math.abs(step.speechMs - bargeIn.speechMs) < Math.abs(TaBargeIn.SENSITIVITY[nearest].speechMs - bargeIn.speechMs)) {
25
+ nearest = index;
26
+ }
27
+ });
28
+ return nearest;
29
+ }
30
+ TaBargeIn.sensitivity = sensitivity;
31
+ /** Of what is given, the keys of TaBargeIn of the right kind, numbers each kept in its range. */
32
+ function pick(value) {
33
+ const given = value && typeof value === 'object' ? value : {};
34
+ const out = typeof given.tap === 'boolean' ? { tap: given.tap } : {};
35
+ for (const key of Object.keys(RANGES)) {
36
+ const number = given[key];
37
+ if (typeof number === 'number' && Number.isFinite(number)) {
38
+ const [min, max] = RANGES[key];
39
+ out[key] = Math.min(max, Math.max(min, number));
40
+ }
41
+ }
42
+ return out;
43
+ }
44
+ TaBargeIn.pick = pick;
45
+ const RANGES = {
46
+ duck: [0, 1],
47
+ speechMs: [0, 5000],
48
+ level: [0, 1],
49
+ words: [1, 50],
50
+ waitMs: [100, 10000],
51
+ echo: [0, 4],
52
+ joinMs: [0, 3000],
53
+ };
54
+ /** What voices.json says, each value a number in its range, the default for one left out or wrong. */
55
+ function resolve(value) {
56
+ return { ...TaBargeIn.DEFAULTS, ...pick(value) };
57
+ }
58
+ TaBargeIn.resolve = resolve;
59
+ })(TaBargeIn || (exports.TaBargeIn = TaBargeIn = {}));
6
60
  //# sourceMappingURL=voice-protocol.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-protocol",
3
- "version": "4.17.0",
3
+ "version": "4.18.0",
4
4
  "description": "The protocol between ta serve and its clients",
5
5
  "homepage": "https://github.com/cellbang/ta",
6
6
  "bugs": {