@celljs/ta-web 4.27.0 → 4.28.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 (264) hide show
  1. package/esm/browser/assistant/assistant-role.d.ts +9 -4
  2. package/esm/browser/assistant/assistant-role.js +17 -5
  3. package/esm/browser/assistant/assistant-task-util.d.ts +6 -0
  4. package/esm/browser/assistant/assistant-task-util.js +12 -1
  5. package/esm/browser/assistant/assistant-view.js +4 -1
  6. package/esm/browser/assistant/assistant.d.ts +2 -1
  7. package/esm/browser/assistant/assistant.js +9 -7
  8. package/esm/browser/assistant/call-conversing.d.ts +45 -0
  9. package/esm/browser/assistant/call-conversing.js +91 -0
  10. package/esm/browser/assistant/call-face.d.ts +13 -0
  11. package/esm/browser/assistant/call-face.js +81 -0
  12. package/esm/browser/assistant/call-keeper.d.ts +8 -4
  13. package/esm/browser/assistant/call-keeper.js +32 -11
  14. package/esm/browser/assistant/call-partnering.d.ts +37 -0
  15. package/esm/browser/assistant/call-partnering.js +79 -0
  16. package/esm/browser/assistant/call-scenes.d.ts +25 -0
  17. package/esm/browser/assistant/call-scenes.js +82 -0
  18. package/esm/browser/assistant/call-screen.d.ts +3 -0
  19. package/esm/browser/assistant/call-screen.js +15 -0
  20. package/esm/browser/assistant/mic-sense.d.ts +31 -0
  21. package/esm/browser/assistant/mic-sense.js +119 -0
  22. package/esm/browser/assistant/noise-gate.d.ts +32 -0
  23. package/esm/browser/assistant/noise-gate.js +66 -0
  24. package/esm/browser/assistant/pcm-util.d.ts +10 -0
  25. package/esm/browser/assistant/pcm-util.js +55 -0
  26. package/esm/browser/assistant/read-aloud.d.ts +2 -1
  27. package/esm/browser/assistant/realtime-voice-protocol.d.ts +84 -0
  28. package/esm/browser/assistant/realtime-voice-protocol.js +40 -0
  29. package/esm/browser/assistant/realtime-voice.d.ts +50 -62
  30. package/esm/browser/assistant/realtime-voice.js +213 -134
  31. package/esm/browser/assistant/spoken-timeline.d.ts +27 -0
  32. package/esm/browser/assistant/spoken-timeline.js +49 -0
  33. package/esm/browser/assistant/voice-call-bar.d.ts +9 -2
  34. package/esm/browser/assistant/voice-call-bar.js +81 -31
  35. package/esm/browser/assistant/voice-call-protocol.d.ts +61 -4
  36. package/esm/browser/assistant/voice-call.d.ts +16 -23
  37. package/esm/browser/assistant/voice-call.js +134 -117
  38. package/esm/browser/assistant/voice-reading.d.ts +83 -0
  39. package/esm/browser/assistant/voice-reading.js +150 -0
  40. package/esm/browser/avatar/dino-talk.d.ts +15 -0
  41. package/esm/browser/avatar/dino-talk.js +34 -0
  42. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  43. package/esm/browser/components/conversation-scroll-util.d.ts +8 -1
  44. package/esm/browser/components/conversation-scroll-util.js +21 -0
  45. package/esm/browser/components/conversation-scroll.js +10 -11
  46. package/esm/browser/components/gallery.js +28 -7
  47. package/esm/browser/components/host-view.d.ts +1 -1
  48. package/esm/browser/components/image-pull.d.ts +64 -0
  49. package/esm/browser/components/image-pull.js +202 -0
  50. package/esm/browser/components/kept-call-bar.js +2 -1
  51. package/esm/browser/components/lightbox.d.ts +1 -1
  52. package/esm/browser/components/lightbox.js +57 -2
  53. package/esm/browser/components/markdown.d.ts +3 -1
  54. package/esm/browser/components/markdown.js +8 -4
  55. package/esm/browser/components/partner-row.js +2 -1
  56. package/esm/browser/components/relay-services.d.ts +9 -3
  57. package/esm/browser/components/relay-services.js +73 -35
  58. package/esm/browser/components/session-view.js +4 -2
  59. package/esm/browser/components/settings-parts.js +2 -0
  60. package/esm/browser/components/ta-avatar.d.ts +15 -1
  61. package/esm/browser/components/ta-avatar.js +38 -5
  62. package/esm/browser/components/voice-services.js +6 -1
  63. package/esm/browser/extension/web-api-call.d.ts +64 -2
  64. package/esm/browser/extension/web-api-contributions.d.ts +1 -0
  65. package/esm/browser/extension/web-api-partners.d.ts +2 -0
  66. package/esm/browser/extension/web-extension-api.d.ts +6 -6
  67. package/esm/browser/extension/web-extension-context.js +1 -0
  68. package/esm/browser/extension/web-extension-protocol.d.ts +3 -1
  69. package/esm/browser/extension/web-extension-run.d.ts +3 -2
  70. package/esm/browser/extension/web-extension-run.js +2 -0
  71. package/esm/browser/i18n/locales.d.ts +24 -5
  72. package/esm/browser/i18n/messages-ja.js +25 -6
  73. package/esm/browser/i18n/messages-zh-tw.js +25 -6
  74. package/esm/browser/i18n/messages.d.ts +23 -4
  75. package/esm/browser/i18n/messages.js +50 -12
  76. package/esm/browser/markdown/code-renderers.d.ts +2 -0
  77. package/esm/browser/markdown/code-renderers.js +2 -0
  78. package/esm/browser/screen/page-answers.d.ts +2 -1
  79. package/esm/browser/screen/page-answers.js +7 -4
  80. package/esm/browser/settings/settings-protocol.d.ts +2 -0
  81. package/esm/browser/settings/settings-protocol.js +2 -0
  82. package/esm/browser/style/chat-list.d.ts +1 -1
  83. package/esm/browser/style/chat-list.js +1 -1
  84. package/esm/browser/style/conversation.d.ts +1 -1
  85. package/esm/browser/style/conversation.js +6 -1
  86. package/esm/browser/style/device.js +1 -0
  87. package/esm/browser/style/dialogs.d.ts +1 -1
  88. package/esm/browser/style/dialogs.js +1 -1
  89. package/esm/browser/style/layout.d.ts +1 -1
  90. package/esm/browser/style/layout.js +135 -57
  91. package/esm/browser/style/shell.d.ts +1 -1
  92. package/esm/browser/style/shell.js +8 -0
  93. package/esm/browser/style/video-call.d.ts +2 -0
  94. package/esm/browser/style/video-call.js +52 -0
  95. package/esm/browser/style.js +2 -0
  96. package/esm/browser/util/desktop.d.ts +10 -1
  97. package/esm/browser/util/desktop.js +10 -0
  98. package/esm/browser/util/image-pull.d.ts +61 -0
  99. package/esm/browser/util/image-pull.js +88 -0
  100. package/esm/browser/util/spoken.d.ts +3 -3
  101. package/esm/browser/util/spoken.js +4 -4
  102. package/esm/browser/video-call/call-camera.d.ts +59 -0
  103. package/esm/browser/video-call/call-camera.js +188 -0
  104. package/esm/browser/video-call/call-window.d.ts +19 -0
  105. package/esm/browser/video-call/call-window.js +80 -0
  106. package/esm/browser/video-call/clip-plan.d.ts +47 -0
  107. package/esm/browser/video-call/clip-plan.js +60 -0
  108. package/esm/browser/video-call/face-clips.d.ts +33 -0
  109. package/esm/browser/video-call/face-clips.js +93 -0
  110. package/esm/browser/video-call/face-files.d.ts +31 -0
  111. package/esm/browser/video-call/face-files.js +77 -0
  112. package/esm/browser/video-call/video-call-view.d.ts +19 -0
  113. package/esm/browser/video-call/video-call-view.js +214 -0
  114. package/esm/browser/video-call/video-face.d.ts +13 -0
  115. package/esm/browser/video-call/video-face.js +497 -0
  116. package/esm/browser/workbench-hosts.d.ts +1 -0
  117. package/esm/browser/workbench-protocol.d.ts +2 -0
  118. package/esm/browser/workbench-util.d.ts +5 -0
  119. package/esm/browser/workbench-util.js +18 -0
  120. package/esm/browser/workbench.d.ts +6 -0
  121. package/esm/browser/workbench.js +36 -5
  122. package/lib/browser/assistant/assistant-role.d.ts +9 -4
  123. package/lib/browser/assistant/assistant-role.js +17 -5
  124. package/lib/browser/assistant/assistant-task-util.d.ts +6 -0
  125. package/lib/browser/assistant/assistant-task-util.js +11 -0
  126. package/lib/browser/assistant/assistant-view.js +3 -0
  127. package/lib/browser/assistant/assistant.d.ts +2 -1
  128. package/lib/browser/assistant/assistant.js +9 -7
  129. package/lib/browser/assistant/call-conversing.d.ts +46 -0
  130. package/lib/browser/assistant/call-conversing.js +96 -0
  131. package/lib/browser/assistant/call-face.d.ts +14 -0
  132. package/lib/browser/assistant/call-face.js +117 -0
  133. package/lib/browser/assistant/call-keeper.d.ts +8 -4
  134. package/lib/browser/assistant/call-keeper.js +32 -11
  135. package/lib/browser/assistant/call-partnering.d.ts +38 -0
  136. package/lib/browser/assistant/call-partnering.js +83 -0
  137. package/lib/browser/assistant/call-scenes.d.ts +26 -0
  138. package/lib/browser/assistant/call-scenes.js +85 -0
  139. package/lib/browser/assistant/call-screen.d.ts +3 -0
  140. package/lib/browser/assistant/call-screen.js +15 -0
  141. package/lib/browser/assistant/mic-sense.d.ts +32 -0
  142. package/lib/browser/assistant/mic-sense.js +123 -0
  143. package/lib/browser/assistant/noise-gate.d.ts +33 -0
  144. package/lib/browser/assistant/noise-gate.js +71 -0
  145. package/lib/browser/assistant/pcm-util.d.ts +11 -0
  146. package/lib/browser/assistant/pcm-util.js +58 -0
  147. package/lib/browser/assistant/read-aloud.d.ts +2 -1
  148. package/lib/browser/assistant/realtime-voice-protocol.d.ts +85 -0
  149. package/lib/browser/assistant/realtime-voice-protocol.js +43 -0
  150. package/lib/browser/assistant/realtime-voice.d.ts +50 -62
  151. package/lib/browser/assistant/realtime-voice.js +217 -138
  152. package/lib/browser/assistant/spoken-timeline.d.ts +28 -0
  153. package/lib/browser/assistant/spoken-timeline.js +53 -0
  154. package/lib/browser/assistant/voice-call-bar.d.ts +9 -2
  155. package/lib/browser/assistant/voice-call-bar.js +81 -30
  156. package/lib/browser/assistant/voice-call-protocol.d.ts +61 -4
  157. package/lib/browser/assistant/voice-call.d.ts +16 -23
  158. package/lib/browser/assistant/voice-call.js +134 -117
  159. package/lib/browser/assistant/voice-reading.d.ts +84 -0
  160. package/lib/browser/assistant/voice-reading.js +156 -0
  161. package/lib/browser/avatar/dino-talk.d.ts +16 -0
  162. package/lib/browser/avatar/dino-talk.js +37 -0
  163. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  164. package/lib/browser/components/conversation-scroll-util.d.ts +8 -1
  165. package/lib/browser/components/conversation-scroll-util.js +21 -0
  166. package/lib/browser/components/conversation-scroll.js +10 -11
  167. package/lib/browser/components/gallery.js +28 -7
  168. package/lib/browser/components/host-view.d.ts +1 -1
  169. package/lib/browser/components/image-pull.d.ts +65 -0
  170. package/lib/browser/components/image-pull.js +206 -0
  171. package/lib/browser/components/kept-call-bar.js +2 -1
  172. package/lib/browser/components/lightbox.d.ts +1 -1
  173. package/lib/browser/components/lightbox.js +57 -2
  174. package/lib/browser/components/markdown.d.ts +3 -1
  175. package/lib/browser/components/markdown.js +7 -3
  176. package/lib/browser/components/partner-row.js +2 -1
  177. package/lib/browser/components/relay-services.d.ts +9 -3
  178. package/lib/browser/components/relay-services.js +71 -33
  179. package/lib/browser/components/session-view.js +3 -1
  180. package/lib/browser/components/settings-parts.js +2 -0
  181. package/lib/browser/components/ta-avatar.d.ts +15 -1
  182. package/lib/browser/components/ta-avatar.js +38 -5
  183. package/lib/browser/components/voice-services.js +5 -0
  184. package/lib/browser/extension/web-api-call.d.ts +64 -2
  185. package/lib/browser/extension/web-api-contributions.d.ts +1 -0
  186. package/lib/browser/extension/web-api-partners.d.ts +2 -0
  187. package/lib/browser/extension/web-extension-api.d.ts +6 -6
  188. package/lib/browser/extension/web-extension-context.js +1 -0
  189. package/lib/browser/extension/web-extension-protocol.d.ts +3 -1
  190. package/lib/browser/extension/web-extension-run.d.ts +3 -2
  191. package/lib/browser/extension/web-extension-run.js +2 -0
  192. package/lib/browser/i18n/locales.d.ts +24 -5
  193. package/lib/browser/i18n/messages-ja.js +25 -6
  194. package/lib/browser/i18n/messages-zh-tw.js +25 -6
  195. package/lib/browser/i18n/messages.d.ts +23 -4
  196. package/lib/browser/i18n/messages.js +50 -12
  197. package/lib/browser/markdown/code-renderers.d.ts +2 -0
  198. package/lib/browser/markdown/code-renderers.js +3 -1
  199. package/lib/browser/screen/page-answers.d.ts +2 -1
  200. package/lib/browser/screen/page-answers.js +7 -4
  201. package/lib/browser/settings/settings-protocol.d.ts +2 -0
  202. package/lib/browser/settings/settings-protocol.js +2 -0
  203. package/lib/browser/style/chat-list.d.ts +1 -1
  204. package/lib/browser/style/chat-list.js +1 -1
  205. package/lib/browser/style/conversation.d.ts +1 -1
  206. package/lib/browser/style/conversation.js +6 -1
  207. package/lib/browser/style/device.js +1 -0
  208. package/lib/browser/style/dialogs.d.ts +1 -1
  209. package/lib/browser/style/dialogs.js +1 -1
  210. package/lib/browser/style/layout.d.ts +1 -1
  211. package/lib/browser/style/layout.js +135 -57
  212. package/lib/browser/style/shell.d.ts +1 -1
  213. package/lib/browser/style/shell.js +8 -0
  214. package/lib/browser/style/video-call.d.ts +3 -0
  215. package/lib/browser/style/video-call.js +55 -0
  216. package/lib/browser/style.js +2 -0
  217. package/lib/browser/util/desktop.d.ts +10 -1
  218. package/lib/browser/util/desktop.js +10 -0
  219. package/lib/browser/util/image-pull.d.ts +62 -0
  220. package/lib/browser/util/image-pull.js +91 -0
  221. package/lib/browser/util/spoken.d.ts +3 -3
  222. package/lib/browser/util/spoken.js +4 -4
  223. package/lib/browser/video-call/call-camera.d.ts +60 -0
  224. package/lib/browser/video-call/call-camera.js +192 -0
  225. package/lib/browser/video-call/call-window.d.ts +20 -0
  226. package/lib/browser/video-call/call-window.js +83 -0
  227. package/lib/browser/video-call/clip-plan.d.ts +48 -0
  228. package/lib/browser/video-call/clip-plan.js +64 -0
  229. package/lib/browser/video-call/face-clips.d.ts +34 -0
  230. package/lib/browser/video-call/face-clips.js +96 -0
  231. package/lib/browser/video-call/face-files.d.ts +32 -0
  232. package/lib/browser/video-call/face-files.js +82 -0
  233. package/lib/browser/video-call/video-call-view.d.ts +20 -0
  234. package/lib/browser/video-call/video-call-view.js +250 -0
  235. package/lib/browser/video-call/video-face.d.ts +14 -0
  236. package/lib/browser/video-call/video-face.js +533 -0
  237. package/lib/browser/workbench-hosts.d.ts +1 -0
  238. package/lib/browser/workbench-protocol.d.ts +2 -0
  239. package/lib/browser/workbench-util.d.ts +5 -0
  240. package/lib/browser/workbench-util.js +18 -0
  241. package/lib/browser/workbench.d.ts +6 -0
  242. package/lib/browser/workbench.js +35 -4
  243. package/package.json +7 -7
  244. package/public/faces/README.md +27 -0
  245. package/public/faces/clap.mp4 +0 -0
  246. package/public/faces/dance.mp4 +0 -0
  247. package/public/faces/happy.mp4 +0 -0
  248. package/public/faces/heart.mp4 +0 -0
  249. package/public/faces/idle-1.mp4 +0 -0
  250. package/public/faces/idle-2.mp4 +0 -0
  251. package/public/faces/idle-3.mp4 +0 -0
  252. package/public/faces/laugh.mp4 +0 -0
  253. package/public/faces/lips.json +1 -0
  254. package/public/faces/listening.mp4 +0 -0
  255. package/public/faces/poster.jpg +0 -0
  256. package/public/faces/shy.mp4 +0 -0
  257. package/public/faces/sorry.mp4 +0 -0
  258. package/public/faces/stretch.mp4 +0 -0
  259. package/public/faces/surprised.mp4 +0 -0
  260. package/public/faces/talk-1.mp4 +0 -0
  261. package/public/faces/talk-2.mp4 +0 -0
  262. package/public/faces/think-2.mp4 +0 -0
  263. package/public/faces/thinking.mp4 +0 -0
  264. package/public/faces/wave.mp4 +0 -0
@@ -0,0 +1,38 @@
1
+ import type { CallDraft, CallOptions, CallPartner, CallState } from './voice-call-protocol';
2
+ /** What of a call (VoiceCall) its partner answers in. */
3
+ export interface PartneredCall {
4
+ /** Of the call now: what comes for a call hung up is let go. */
5
+ readonly calls: number;
6
+ readonly state: CallState;
7
+ set(change: Partial<CallState>): void;
8
+ /** The answer to say, as a turn's is. */
9
+ turnEnded(reply: string | undefined): void;
10
+ /** What the user said did not go: Ta listens again. */
11
+ unsent(): void;
12
+ announce(text: string): void;
13
+ }
14
+ /**
15
+ * Who answers in a call in place of the conversation (CallOptions.openPartner, docs/design/ta-call.md): it is asked
16
+ * what the user said, opened again once when it does not answer, and given way to the conversation when it cannot.
17
+ */
18
+ export declare class CallPartnering {
19
+ protected readonly call: PartneredCall;
20
+ protected readonly options: CallOptions;
21
+ partner?: CallPartner;
22
+ constructor(call: PartneredCall, options: CallOptions);
23
+ /** The partner of the call now: what it says by itself is said as news is, in a silence, and cut into as any answer. */
24
+ adopt(partner: CallPartner | undefined): void;
25
+ close(): void;
26
+ /** A partner opened for a voice service to answer, which does not: one that answers itself takes its place. */
27
+ unvoice(): void;
28
+ /** The partner answers what the user said; its reply is read as a turn's is. */
29
+ ask(text: string, sent?: boolean): void;
30
+ /** The user was done with the words of the draft: its answer is the reply; failing, the partner is asked as usual. */
31
+ kept(draft: CallDraft, said: string): void;
32
+ /**
33
+ * The partner did not answer (the Ta service restarted, its side of the call is gone): it opens again once and
34
+ * answers what was said; failing that, the conversation answers from then on. The call goes on either way.
35
+ */
36
+ protected reopen(failed: CallPartner, text: string, sent?: boolean): void;
37
+ }
38
+ //# sourceMappingURL=call-partnering.d.ts.map
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CallPartnering = void 0;
4
+ /**
5
+ * Who answers in a call in place of the conversation (CallOptions.openPartner, docs/design/ta-call.md): it is asked
6
+ * what the user said, opened again once when it does not answer, and given way to the conversation when it cannot.
7
+ */
8
+ class CallPartnering {
9
+ constructor(call, options) {
10
+ this.call = call;
11
+ this.options = options;
12
+ }
13
+ /** The partner of the call now: what it says by itself is said as news is, in a silence, and cut into as any answer. */
14
+ adopt(partner) {
15
+ var _a;
16
+ const calls = this.call.calls;
17
+ this.partner = partner;
18
+ (_a = partner === null || partner === void 0 ? void 0 : partner.news) === null || _a === void 0 ? void 0 : _a.call(partner, text => calls === this.call.calls && this.call.announce(text));
19
+ this.call.set({ partnered: !!partner });
20
+ }
21
+ close() {
22
+ var _a;
23
+ (_a = this.partner) === null || _a === void 0 ? void 0 : _a.close();
24
+ this.partner = undefined;
25
+ }
26
+ /** A partner opened for a voice service to answer, which does not: one that answers itself takes its place. */
27
+ unvoice() {
28
+ var _a, _b, _c, _d;
29
+ if (!((_a = this.partner) === null || _a === void 0 ? void 0 : _a.brain)) {
30
+ return;
31
+ }
32
+ const calls = this.call.calls;
33
+ this.close();
34
+ void ((_d = (_c = (_b = this.options).openPartner) === null || _c === void 0 ? void 0 : _c.call(_b, true)) === null || _d === void 0 ? void 0 : _d.then(partner => (calls === this.call.calls && this.call.state.active ? this.adopt(partner) : partner === null || partner === void 0 ? void 0 : partner.close()), () => calls === this.call.calls && this.call.set({ partnered: false })));
35
+ }
36
+ /** The partner answers what the user said; its reply is read as a turn's is. */
37
+ ask(text, sent) {
38
+ const calls = this.call.calls;
39
+ const partner = this.partner;
40
+ partner === null || partner === void 0 ? void 0 : partner.say(text, sent ? { sent } : undefined).then(reply => calls === this.call.calls && this.call.turnEnded(reply), () => calls === this.call.calls && this.call.state.active && this.reopen(partner, text, sent));
41
+ }
42
+ /** The user was done with the words of the draft: its answer is the reply; failing, the partner is asked as usual. */
43
+ kept(draft, said) {
44
+ const calls = this.call.calls;
45
+ const partner = this.partner;
46
+ draft.keep();
47
+ draft.reply.then(reply => calls === this.call.calls && this.call.turnEnded(reply), () => calls === this.call.calls && this.call.state.active && this.partner === partner && this.ask(said));
48
+ }
49
+ /**
50
+ * The partner did not answer (the Ta service restarted, its side of the call is gone): it opens again once and
51
+ * answers what was said; failing that, the conversation answers from then on. The call goes on either way.
52
+ */
53
+ reopen(failed, text, sent) {
54
+ var _a, _b, _c;
55
+ var _d;
56
+ const calls = this.call.calls;
57
+ if (this.partner !== failed) {
58
+ return;
59
+ }
60
+ this.close();
61
+ const again = (_d = (_c = (_b = (_a = this.options).openPartner) === null || _b === void 0 ? void 0 : _b.call(_a, true)) === null || _c === void 0 ? void 0 : _c.catch(() => undefined)) !== null && _d !== void 0 ? _d : Promise.resolve(undefined);
62
+ void again.then(partner => {
63
+ if (calls !== this.call.calls || !this.call.state.active) {
64
+ partner === null || partner === void 0 ? void 0 : partner.close();
65
+ return;
66
+ }
67
+ if (!partner) {
68
+ this.call.set({ partnered: false });
69
+ if (sent) {
70
+ this.call.unsent();
71
+ }
72
+ else {
73
+ this.options.send(text).catch(() => this.call.state.active && this.call.unsent());
74
+ }
75
+ return;
76
+ }
77
+ this.adopt(partner);
78
+ partner.say(text, sent ? { sent } : undefined).then(reply => calls === this.call.calls && this.call.turnEnded(reply), () => calls === this.call.calls && this.call.state.active && this.call.unsent());
79
+ });
80
+ }
81
+ }
82
+ exports.CallPartnering = CallPartnering;
83
+ //# sourceMappingURL=call-partnering.js.map
@@ -0,0 +1,26 @@
1
+ import { type TaCallScene, type TaCallView } from '@celljs/ta-protocol';
2
+ import type { VoiceCall } from './voice-call';
3
+ /** What the view of a call shows of it now (VideoCallView): the user's camera, and how the call shows. */
4
+ interface Shown {
5
+ camera?: boolean;
6
+ view?: TaCallView;
7
+ }
8
+ /**
9
+ * How a call is for the user (TaCallScene, docs/design/ta-call.md 13), from the call (video or voice, when it began),
10
+ * the device and what its view shows (the camera, full screen or small): given to the partner as the call opens and as
11
+ * it changes, and to the conversation itself in a direct call. The words are TaCallSceneUtil's alone.
12
+ */
13
+ export declare namespace CallScenes {
14
+ function of(call: VoiceCall, device: TaCallScene['device']): TaCallScene;
15
+ /** The view of the call shows this now. */
16
+ function show(call: VoiceCall, now: Shown): void;
17
+ /** Tells `changed` the scene of `call` as it changes and stays so a moment; until what it returns is called. */
18
+ function watch(call: VoiceCall, device: TaCallScene['device'], changed: (scene: TaCallScene) => void): () => void;
19
+ /**
20
+ * What a direct call tells the conversation with what the user said (SpokenReply.asked): what is new of the call
21
+ * since it last told it (TaCallSceneUtil.next). The conversation sees no picture of the camera.
22
+ */
23
+ function next(call: VoiceCall, device: TaCallScene['device']): string | undefined;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=call-scenes.d.ts.map
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CallScenes = void 0;
4
+ const ta_protocol_1 = require("@celljs/ta-protocol");
5
+ /** How long the scene must stay before it is told: a window that only passes (full, then small) is not. */
6
+ const SETTLE_MS = 800;
7
+ /**
8
+ * How a call is for the user (TaCallScene, docs/design/ta-call.md 13), from the call (video or voice, when it began),
9
+ * the device and what its view shows (the camera, full screen or small): given to the partner as the call opens and as
10
+ * it changes, and to the conversation itself in a direct call. The words are TaCallSceneUtil's alone.
11
+ */
12
+ var CallScenes;
13
+ (function (CallScenes) {
14
+ const shown = new WeakMap();
15
+ const listeners = new WeakMap();
16
+ /** What a direct call told its conversation, of the call that began then. */
17
+ const told = new WeakMap();
18
+ function of(call, device) {
19
+ var _a, _b;
20
+ const { camera, view } = (_a = shown.get(call)) !== null && _a !== void 0 ? _a : {};
21
+ return {
22
+ video: call.state.video === true,
23
+ ...(call.state.video && camera ? { camera } : {}),
24
+ ...(call.state.video && view ? { view } : {}),
25
+ ...(device ? { device } : {}),
26
+ since: (_b = call.state.since) !== null && _b !== void 0 ? _b : Date.now(),
27
+ };
28
+ }
29
+ CallScenes.of = of;
30
+ /** The view of the call shows this now. */
31
+ function show(call, now) {
32
+ var _a;
33
+ const before = shown.get(call);
34
+ if ((before === null || before === void 0 ? void 0 : before.camera) === now.camera && (before === null || before === void 0 ? void 0 : before.view) === now.view) {
35
+ return;
36
+ }
37
+ shown.set(call, now);
38
+ for (const listener of [...((_a = listeners.get(call)) !== null && _a !== void 0 ? _a : [])]) {
39
+ listener();
40
+ }
41
+ }
42
+ CallScenes.show = show;
43
+ /** Tells `changed` the scene of `call` as it changes and stays so a moment; until what it returns is called. */
44
+ function watch(call, device, changed) {
45
+ var _a;
46
+ let last = ta_protocol_1.TaCallSceneUtil.key(of(call, device));
47
+ let timer;
48
+ const look = () => {
49
+ clearTimeout(timer);
50
+ timer = setTimeout(() => {
51
+ const scene = of(call, device);
52
+ const key = ta_protocol_1.TaCallSceneUtil.key(scene);
53
+ if (call.state.active && key !== last) {
54
+ last = key;
55
+ changed(scene);
56
+ }
57
+ }, SETTLE_MS);
58
+ };
59
+ const own = (_a = listeners.get(call)) !== null && _a !== void 0 ? _a : new Set();
60
+ listeners.set(call, own);
61
+ own.add(look);
62
+ const offCall = call.subscribe(look);
63
+ return () => {
64
+ clearTimeout(timer);
65
+ own.delete(look);
66
+ offCall();
67
+ };
68
+ }
69
+ CallScenes.watch = watch;
70
+ /**
71
+ * What a direct call tells the conversation with what the user said (SpokenReply.asked): what is new of the call
72
+ * since it last told it (TaCallSceneUtil.next). The conversation sees no picture of the camera.
73
+ */
74
+ function next(call, device) {
75
+ const scene = of(call, device);
76
+ let was = told.get(call);
77
+ if ((was === null || was === void 0 ? void 0 : was.since) !== scene.since) {
78
+ was = { since: scene.since, told: {} };
79
+ told.set(call, was);
80
+ }
81
+ return ta_protocol_1.TaCallSceneUtil.next(scene, was.told, false, Date.now());
82
+ }
83
+ CallScenes.next = next;
84
+ })(CallScenes || (exports.CallScenes = CallScenes = {}));
85
+ //# sourceMappingURL=call-scenes.js.map
@@ -1,3 +1,4 @@
1
+ import type { Mood } from '../avatar/dino-avatar';
1
2
  import type { Translate } from '../i18n/use-t';
2
3
  import { type ScreenPartSpec, type TaScreen } from '../screen/screen-protocol';
3
4
  import type { CallPhase } from './voice-call-protocol';
@@ -32,6 +33,8 @@ export declare namespace CallScreen {
32
33
  }
33
34
  /** What the call is at, as its bar says. */
34
35
  function phase(t: Translate, seen: Pick<Seen, 'phase' | 'paused' | 'heard'>): string;
36
+ /** How Ta's face looks for what the call is at (CallFace). */
37
+ function mood(seen: Pick<Seen, 'phase' | 'paused'>): Mood;
35
38
  /** Presses the button of an action of the call where it shows, as the user would; else does what it does. */
36
39
  function press(screen: Pick<TaScreen, 'element'>, name: string, otherwise: () => void): void;
37
40
  /** The part of the screen of the call: its state in a line, and what its buttons do now. */
@@ -27,6 +27,21 @@ var CallScreen;
27
27
  }
28
28
  }
29
29
  CallScreen.phase = phase;
30
+ /** How Ta's face looks for what the call is at (CallFace). */
31
+ function mood(seen) {
32
+ if (seen.paused) {
33
+ return 'sleeping';
34
+ }
35
+ switch (seen.phase) {
36
+ case 'speaking':
37
+ return 'speaking';
38
+ case 'listening':
39
+ return 'listening';
40
+ default:
41
+ return 'thinking';
42
+ }
43
+ }
44
+ CallScreen.mood = mood;
30
45
  /** Presses the button of an action of the call where it shows, as the user would; else does what it does. */
31
46
  function press(screen, name, otherwise) {
32
47
  const button = screen.element(CallScreen.PART, undefined, name);
@@ -0,0 +1,32 @@
1
+ import type { TaBargeIn } from '@celljs/ta-protocol';
2
+ import { type Doubt } from './realtime-voice-protocol';
3
+ /** What a piece of the microphone is (MicSense.measure). */
4
+ export interface MicPiece {
5
+ /** How loud (RMS, 0 to 1). */
6
+ level: number;
7
+ /** Periodic at the pitch of a voice: a vowel of someone speaking, not a cough, a knock, a fan. */
8
+ voiced: boolean;
9
+ }
10
+ /**
11
+ * What the microphone hears, piece by piece (docs/design/ta-voice.md 10): whether a piece is voiced, and the floor of
12
+ * the room, as minimum statistics do: it falls at once to a quieter piece, and rises only to what is not voiced (a fan,
13
+ * the hum of a room), so that the user speaking on and on never becomes the room.
14
+ */
15
+ export declare class MicSense {
16
+ /** The floor of the room: the quietest it was lately, of what is not speech. */
17
+ floor: number;
18
+ measure(samples: Float32Array, rate: number): MicPiece;
19
+ /**
20
+ * A piece of the microphone while Ta reads and a sound may be the user cutting in (docs/design/ta-voice.md 10):
21
+ * voiced speech louder than `speech` in a run (gaps under GAP_MS) lowers the reading after DUCK_MS ('duck') and cuts
22
+ * in after speechMs ('cut'), unless it is no louder than `echo` (Ta's own voice heard back). What is not voiced (a
23
+ * cough, a knock) only counts as a gap.
24
+ */
25
+ static weigh(doubt: Doubt, piece: MicPiece, ms: number, speech: number, echo: number, barge: TaBargeIn): 'duck' | 'cut' | undefined;
26
+ /**
27
+ * How periodic `samples` are at the pitch of a voice: the highest normalized autocorrelation over the lags of
28
+ * PITCH_LOW to PITCH_HIGH, on samples averaged down to about VOICING_RATE; 0 for silence or noise, near 1 for a vowel.
29
+ */
30
+ static voicing(samples: Float32Array, rate: number): number;
31
+ }
32
+ //# sourceMappingURL=mic-sense.d.ts.map
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MicSense = void 0;
4
+ const pcm_util_1 = require("./pcm-util");
5
+ const realtime_voice_protocol_1 = require("./realtime-voice-protocol");
6
+ /**
7
+ * How fast the floor of the room rises, a step of 100 ms, to a piece louder than it that is not voiced: a fan turned on
8
+ * is the room in about two seconds. A voiced piece (someone speaking) never raises it.
9
+ */
10
+ const RISE = 1.15;
11
+ /** The floor as a call begins: a quiet room, until the microphone says otherwise. */
12
+ const FLOOR = 0.003;
13
+ /** Normalized autocorrelation at the pitch of a voice above which a piece is voiced: vowels are, a cough or a knock not. */
14
+ const VOICED = 0.5;
15
+ /** The pitch a voice may have, in Hz. */
16
+ const PITCH_LOW = 70;
17
+ const PITCH_HIGH = 400;
18
+ /** The rate voicing is reckoned at: enough for a pitch, little to compute. */
19
+ const VOICING_RATE = 8000;
20
+ /**
21
+ * What the microphone hears, piece by piece (docs/design/ta-voice.md 10): whether a piece is voiced, and the floor of
22
+ * the room, as minimum statistics do: it falls at once to a quieter piece, and rises only to what is not voiced (a fan,
23
+ * the hum of a room), so that the user speaking on and on never becomes the room.
24
+ */
25
+ class MicSense {
26
+ constructor() {
27
+ /** The floor of the room: the quietest it was lately, of what is not speech. */
28
+ this.floor = FLOOR;
29
+ }
30
+ measure(samples, rate) {
31
+ const level = pcm_util_1.PcmUtil.rms(samples);
32
+ const voiced = MicSense.voicing(samples, rate) >= VOICED;
33
+ if (level < this.floor) {
34
+ this.floor = this.floor * 0.6 + level * 0.4;
35
+ }
36
+ else if (!voiced) {
37
+ this.floor = Math.min(level, this.floor * RISE ** ((samples.length / rate) * 10));
38
+ }
39
+ return { level, voiced };
40
+ }
41
+ /**
42
+ * A piece of the microphone while Ta reads and a sound may be the user cutting in (docs/design/ta-voice.md 10):
43
+ * voiced speech louder than `speech` in a run (gaps under GAP_MS) lowers the reading after DUCK_MS ('duck') and cuts
44
+ * in after speechMs ('cut'), unless it is no louder than `echo` (Ta's own voice heard back). What is not voiced (a
45
+ * cough, a knock) only counts as a gap.
46
+ */
47
+ static weigh(doubt, piece, ms, speech, echo, barge) {
48
+ const loud = piece.level >= speech;
49
+ if (loud && piece.level < echo) {
50
+ doubt.echoed = true;
51
+ return undefined;
52
+ }
53
+ if (!loud || !piece.voiced) {
54
+ doubt.quiet += ms;
55
+ if (doubt.quiet >= realtime_voice_protocol_1.GAP_MS) {
56
+ doubt.loud = 0;
57
+ }
58
+ return undefined;
59
+ }
60
+ doubt.quiet = 0;
61
+ doubt.voiced = true;
62
+ doubt.loud += ms;
63
+ if (doubt.loud >= barge.speechMs) {
64
+ return 'cut';
65
+ }
66
+ if (!doubt.ducked && doubt.loud >= Math.min(realtime_voice_protocol_1.DUCK_MS, barge.speechMs)) {
67
+ doubt.ducked = true;
68
+ return 'duck';
69
+ }
70
+ return undefined;
71
+ }
72
+ /**
73
+ * How periodic `samples` are at the pitch of a voice: the highest normalized autocorrelation over the lags of
74
+ * PITCH_LOW to PITCH_HIGH, on samples averaged down to about VOICING_RATE; 0 for silence or noise, near 1 for a vowel.
75
+ */
76
+ static voicing(samples, rate) {
77
+ const step = Math.max(1, Math.floor(rate / VOICING_RATE));
78
+ const n = Math.floor(samples.length / step);
79
+ if (n < 64) {
80
+ return 0;
81
+ }
82
+ const x = new Float32Array(n);
83
+ let mean = 0;
84
+ for (let i = 0; i < n; i++) {
85
+ let sum = 0;
86
+ for (let j = 0; j < step; j++) {
87
+ sum += samples[i * step + j];
88
+ }
89
+ x[i] = sum / step;
90
+ mean += x[i];
91
+ }
92
+ mean /= n;
93
+ let energy = 0;
94
+ for (let i = 0; i < n; i++) {
95
+ x[i] -= mean;
96
+ energy += x[i] * x[i];
97
+ }
98
+ if (energy < 1e-8) {
99
+ return 0;
100
+ }
101
+ const at = rate / step;
102
+ const low = Math.max(1, Math.floor(at / PITCH_HIGH));
103
+ const high = Math.min(n - 32, Math.ceil(at / PITCH_LOW));
104
+ let best = 0;
105
+ for (let lag = low; lag <= high; lag++) {
106
+ let cross = 0;
107
+ let a = 0;
108
+ let b = 0;
109
+ for (let i = 0; i + lag < n; i++) {
110
+ cross += x[i] * x[i + lag];
111
+ a += x[i] * x[i];
112
+ b += x[i + lag] * x[i + lag];
113
+ }
114
+ const r = a && b ? cross / Math.sqrt(a * b) : 0;
115
+ if (r > best) {
116
+ best = r;
117
+ }
118
+ }
119
+ return best;
120
+ }
121
+ }
122
+ exports.MicSense = MicSense;
123
+ //# sourceMappingURL=mic-sense.js.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * What of the microphone a voice service hears (docs/design/ta-voice.md 9): speech, the sound louder than the room for
3
+ * two pieces at least, with the piece before it (its first sound) and HANG pieces after (the gaps between words); the
4
+ * rest goes as silence, so that the service neither answers a noise nor hears a knock or a cough as the user, and still
5
+ * hears them stop. Each piece waits for the next to be known, one piece of delay.
6
+ */
7
+ export declare class NoiseGate {
8
+ protected readonly hang: number;
9
+ protected pending?: Uint8Array;
10
+ protected wasLoud: boolean;
11
+ protected index: number;
12
+ protected lastVoiced: number;
13
+ constructor(hang?: number);
14
+ /** A piece of PCM16, `loud` when louder than the room: the piece before it as it should go, once known. */
15
+ push(pcm: Uint8Array, loud: boolean): Uint8Array | undefined;
16
+ /** The user is known to speak now (they cut in): what comes goes as it is, a while. */
17
+ open(): void;
18
+ /** What was heard is not to go (the service's own answer played): it begins again. */
19
+ reset(): void;
20
+ }
21
+ /**
22
+ * What of the microphone goes to a voice service (docs/design/ta-voice.md 9): speech alone (NoiseGate), and nothing
23
+ * while what plays is its own answer, which it would hear and answer: that is held, and goes only once the user cuts in.
24
+ */
25
+ export declare class MicFilter {
26
+ protected held: Uint8Array[];
27
+ protected readonly gate: NoiseGate;
28
+ /** A piece of the microphone: what to send now. `playing`: its own answer plays, or just did. */
29
+ take(pcm: Uint8Array, loud: boolean, playing: boolean): Uint8Array | undefined;
30
+ /** The user cut in: what was held of them, from the start of their words, to send now; then all they say. */
31
+ cutIn(): Uint8Array[];
32
+ }
33
+ //# sourceMappingURL=noise-gate.d.ts.map
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MicFilter = exports.NoiseGate = void 0;
4
+ const realtime_voice_protocol_1 = require("./realtime-voice-protocol");
5
+ /**
6
+ * What of the microphone a voice service hears (docs/design/ta-voice.md 9): speech, the sound louder than the room for
7
+ * two pieces at least, with the piece before it (its first sound) and HANG pieces after (the gaps between words); the
8
+ * rest goes as silence, so that the service neither answers a noise nor hears a knock or a cough as the user, and still
9
+ * hears them stop. Each piece waits for the next to be known, one piece of delay.
10
+ */
11
+ class NoiseGate {
12
+ constructor(hang = 4) {
13
+ this.hang = hang;
14
+ this.wasLoud = false;
15
+ this.index = 0;
16
+ this.lastVoiced = Number.NEGATIVE_INFINITY;
17
+ }
18
+ /** A piece of PCM16, `loud` when louder than the room: the piece before it as it should go, once known. */
19
+ push(pcm, loud) {
20
+ const at = this.index++;
21
+ if (loud && this.wasLoud) {
22
+ this.lastVoiced = at;
23
+ }
24
+ this.wasLoud = loud;
25
+ const pending = this.pending;
26
+ this.pending = pcm;
27
+ if (!pending) {
28
+ return undefined;
29
+ }
30
+ return this.lastVoiced >= at - 1 - this.hang ? pending : new Uint8Array(pending.length);
31
+ }
32
+ /** The user is known to speak now (they cut in): what comes goes as it is, a while. */
33
+ open() {
34
+ this.lastVoiced = this.index;
35
+ }
36
+ /** What was heard is not to go (the service's own answer played): it begins again. */
37
+ reset() {
38
+ this.pending = undefined;
39
+ this.wasLoud = false;
40
+ }
41
+ }
42
+ exports.NoiseGate = NoiseGate;
43
+ /**
44
+ * What of the microphone goes to a voice service (docs/design/ta-voice.md 9): speech alone (NoiseGate), and nothing
45
+ * while what plays is its own answer, which it would hear and answer: that is held, and goes only once the user cuts in.
46
+ */
47
+ class MicFilter {
48
+ constructor() {
49
+ this.held = [];
50
+ this.gate = new NoiseGate();
51
+ }
52
+ /** A piece of the microphone: what to send now. `playing`: its own answer plays, or just did. */
53
+ take(pcm, loud, playing) {
54
+ if (playing) {
55
+ this.held.push(pcm);
56
+ this.held.splice(0, Math.max(0, this.held.length - realtime_voice_protocol_1.HELD_MS / realtime_voice_protocol_1.CHUNK_MS));
57
+ this.gate.reset();
58
+ return undefined;
59
+ }
60
+ // What was held was the room while it played, not the user.
61
+ this.held.length = 0;
62
+ return this.gate.push(pcm, loud);
63
+ }
64
+ /** The user cut in: what was held of them, from the start of their words, to send now; then all they say. */
65
+ cutIn() {
66
+ this.gate.open();
67
+ return this.held.splice(0);
68
+ }
69
+ }
70
+ exports.MicFilter = MicFilter;
71
+ //# sourceMappingURL=noise-gate.js.map
@@ -0,0 +1,11 @@
1
+ /** The samples of a microphone, made PCM16 mono at another rate. */
2
+ export declare namespace PcmUtil {
3
+ /** Linear resampling of mono float samples to `to` Hz, as PCM16 little-endian. */
4
+ function toPcm16(samples: Float32Array, from: number, to: number): Uint8Array;
5
+ function toFloat(pcm: Uint8Array): Float32Array;
6
+ function base64(bytes: Uint8Array): string;
7
+ /** How loud samples are (RMS, 0 to 1). */
8
+ function rms(samples: Float32Array): number;
9
+ function bytes(base64: string): Uint8Array;
10
+ }
11
+ //# sourceMappingURL=pcm-util.d.ts.map
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PcmUtil = void 0;
4
+ /** The samples of a microphone, made PCM16 mono at another rate. */
5
+ var PcmUtil;
6
+ (function (PcmUtil) {
7
+ /** Linear resampling of mono float samples to `to` Hz, as PCM16 little-endian. */
8
+ function toPcm16(samples, from, to) {
9
+ const ratio = from / to;
10
+ const length = Math.floor(samples.length / ratio);
11
+ const out = new DataView(new ArrayBuffer(length * 2));
12
+ for (let i = 0; i < length; i++) {
13
+ const at = i * ratio;
14
+ const low = Math.floor(at);
15
+ const high = Math.min(low + 1, samples.length - 1);
16
+ const value = samples[low] + (samples[high] - samples[low]) * (at - low);
17
+ out.setInt16(i * 2, Math.max(-1, Math.min(1, value)) * 0x7fff, true);
18
+ }
19
+ return new Uint8Array(out.buffer);
20
+ }
21
+ PcmUtil.toPcm16 = toPcm16;
22
+ function toFloat(pcm) {
23
+ const view = new DataView(pcm.buffer, pcm.byteOffset, pcm.byteLength);
24
+ const out = new Float32Array(Math.floor(pcm.byteLength / 2));
25
+ for (let i = 0; i < out.length; i++) {
26
+ out[i] = view.getInt16(i * 2, true) / 0x8000;
27
+ }
28
+ return out;
29
+ }
30
+ PcmUtil.toFloat = toFloat;
31
+ function base64(bytes) {
32
+ let text = '';
33
+ for (let i = 0; i < bytes.length; i += 0x8000) {
34
+ text += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
35
+ }
36
+ return btoa(text);
37
+ }
38
+ PcmUtil.base64 = base64;
39
+ /** How loud samples are (RMS, 0 to 1). */
40
+ function rms(samples) {
41
+ let sum = 0;
42
+ for (const sample of samples) {
43
+ sum += sample * sample;
44
+ }
45
+ return Math.sqrt(sum / (samples.length || 1));
46
+ }
47
+ PcmUtil.rms = rms;
48
+ function bytes(base64) {
49
+ const text = atob(base64);
50
+ const out = new Uint8Array(text.length);
51
+ for (let i = 0; i < text.length; i++) {
52
+ out[i] = text.charCodeAt(i);
53
+ }
54
+ return out;
55
+ }
56
+ PcmUtil.bytes = bytes;
57
+ })(PcmUtil || (exports.PcmUtil = PcmUtil = {}));
58
+ //# sourceMappingURL=pcm-util.js.map
@@ -1,4 +1,5 @@
1
- import { RealtimeVoice, type RealtimeVoiceHost } from './realtime-voice';
1
+ import { RealtimeVoice } from './realtime-voice';
2
+ import type { RealtimeVoiceHost } from './realtime-voice-protocol';
2
3
  import type { CallVoice } from './voice-call-protocol';
3
4
  /** How long a voice service opened to read stays open after it read, ready for the next reply. */
4
5
  export declare const READ_IDLE_MS = 60000;