@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
@@ -1,62 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RealtimeVoice = exports.PcmUtil = exports.REALTIME_SILENCE_MS = void 0;
3
+ exports.RealtimeVoice = void 0;
4
4
  const ta_protocol_1 = require("@celljs/ta-protocol");
5
5
  const turn_end_1 = require("../util/turn-end");
6
6
  const voice_1 = require("../util/voice");
7
- /** How long a listen waits for a sentence before it counts as silence. */
8
- exports.REALTIME_SILENCE_MS = 12000;
9
- /** The audio sent at once, in ms of sound. */
10
- const CHUNK_MS = 100;
11
- /** Speech that cuts in is at least this many times as loud as the sound around it (noise, what is left of Ta's echo). */
12
- const ABOVE_NOISE = 2;
13
- /** The sound around the user counts at most this loud: in a din, the level of BargeIn.level times this is speech. */
14
- const NOISE_CAP = 0.08;
15
- /** The samples of a microphone, made PCM16 mono at another rate. */
16
- var PcmUtil;
17
- (function (PcmUtil) {
18
- /** Linear resampling of mono float samples to `to` Hz, as PCM16 little-endian. */
19
- function toPcm16(samples, from, to) {
20
- const ratio = from / to;
21
- const length = Math.floor(samples.length / ratio);
22
- const out = new DataView(new ArrayBuffer(length * 2));
23
- for (let i = 0; i < length; i++) {
24
- const at = i * ratio;
25
- const low = Math.floor(at);
26
- const high = Math.min(low + 1, samples.length - 1);
27
- const value = samples[low] + (samples[high] - samples[low]) * (at - low);
28
- out.setInt16(i * 2, Math.max(-1, Math.min(1, value)) * 0x7fff, true);
29
- }
30
- return new Uint8Array(out.buffer);
31
- }
32
- PcmUtil.toPcm16 = toPcm16;
33
- function toFloat(pcm) {
34
- const view = new DataView(pcm.buffer, pcm.byteOffset, pcm.byteLength);
35
- const out = new Float32Array(Math.floor(pcm.byteLength / 2));
36
- for (let i = 0; i < out.length; i++) {
37
- out[i] = view.getInt16(i * 2, true) / 0x8000;
38
- }
39
- return out;
40
- }
41
- PcmUtil.toFloat = toFloat;
42
- function base64(bytes) {
43
- let text = '';
44
- for (let i = 0; i < bytes.length; i += 0x8000) {
45
- text += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
46
- }
47
- return btoa(text);
48
- }
49
- PcmUtil.base64 = base64;
50
- function bytes(base64) {
51
- const text = atob(base64);
52
- const out = new Uint8Array(text.length);
53
- for (let i = 0; i < text.length; i++) {
54
- out[i] = text.charCodeAt(i);
55
- }
56
- return out;
57
- }
58
- PcmUtil.bytes = bytes;
59
- })(PcmUtil || (exports.PcmUtil = PcmUtil = {}));
7
+ const mic_sense_1 = require("./mic-sense");
8
+ const noise_gate_1 = require("./noise-gate");
9
+ const pcm_util_1 = require("./pcm-util");
10
+ const realtime_voice_protocol_1 = require("./realtime-voice-protocol");
11
+ const voice_reading_1 = require("./voice-reading");
60
12
  /**
61
13
  * A voice of a service of voices.json for a call (docs/design/ta-voice.md 5): the microphone goes to ta serve as PCM
62
14
  * while Ta listens or reads (so the service hears the user cut in), and what the service reads plays here. A service
@@ -76,19 +28,30 @@ class RealtimeVoice {
76
28
  this.closed = false;
77
29
  /** stop() let go of the microphone and the service. */
78
30
  this.stopped = false;
79
- /** How loud the sound around the user is (noise, what is left of Ta's echo), as the microphone hears it. */
80
- this.noise = 0;
31
+ /** Of a voice that thinks: nothing is sent until the microphone's clock is here, as its answer dies away. */
32
+ this.quietUntil = 0;
33
+ /** What of the microphone the service hears: speech alone, and none of a voice that thinks playing its answer. */
34
+ this.mic = new noise_gate_1.MicFilter();
35
+ /** The sound of what it reads, for the face of a video call, and how long each reading is held for it. */
36
+ this.tap = new voice_reading_1.VoiceSoundTap();
37
+ this.onSound = this.tap.on;
38
+ this.hold = this.tap.hold;
39
+ /** The floor of the room, and whether what the microphone hears is voiced. */
40
+ this.sense = new mic_sense_1.MicSense();
81
41
  /** ms of sound the microphone gave, and where in it the user's voice was last heard while Ta listens. */
82
42
  this.clock = 0;
83
43
  this.voiceAt = Number.NEGATIVE_INFINITY;
84
44
  }
85
- /** Opens the service and, unless `hear` is false, the microphone; rejects with why one of them is not there. */
45
+ /**
46
+ * Opens the service and, unless `hear` is false, the microphone; rejects with why one of them is not there. With
47
+ * `brain`, a service that thinks answers by itself (thinks).
48
+ */
86
49
  async open(language, options = {}) {
87
50
  var _a, _b;
88
51
  var _c;
89
52
  this.offEvents = this.host.onVoiceEvent(event => this.take(event));
90
53
  try {
91
- this.session = await this.host.voice.openVoice({ language });
54
+ this.session = await this.host.voice.openVoice({ language, ...(options.brain ? { brain: options.brain } : {}) });
92
55
  this.offState = (_b = (_a = this.host).subscribe) === null || _b === void 0 ? void 0 : _b.call(_a, state => state.status !== 'online' && this.lose('disconnected'));
93
56
  const Context = (_c = globalThis.AudioContext) !== null && _c !== void 0 ? _c : globalThis.webkitAudioContext;
94
57
  if (options.hear === false) {
@@ -141,6 +104,20 @@ class RealtimeVoice {
141
104
  get cutsIn() {
142
105
  return !this.barge.tap;
143
106
  }
107
+ /** Its own model answers the call: it hears, thinks and speaks by itself. */
108
+ get thinks() {
109
+ var _a;
110
+ return this.isOpen && !!((_a = this.session) === null || _a === void 0 ? void 0 : _a.thinks);
111
+ }
112
+ converse(talk) {
113
+ this.endHearing();
114
+ this.talking = { talk, cut: 0, muted: false };
115
+ }
116
+ mute(muted) {
117
+ if (this.talking) {
118
+ this.talking.muted = muted;
119
+ }
120
+ }
144
121
  /** It reads with the voice of the service, not with that of the device. */
145
122
  get speaks() {
146
123
  var _a;
@@ -148,6 +125,7 @@ class RealtimeVoice {
148
125
  }
149
126
  speak(text, language, onEnd, voice, onPiece) {
150
127
  var _a, _b;
128
+ var _c;
151
129
  this.hush();
152
130
  if (!((_a = this.session) === null || _a === void 0 ? void 0 : _a.speaks) || this.closed) {
153
131
  this.device.speak(text, language, onEnd, voice, onPiece);
@@ -158,32 +136,30 @@ class RealtimeVoice {
158
136
  onEnd();
159
137
  return;
160
138
  }
161
- // The service reads it whole: its captions are the whole answer, as it is read.
162
- onPiece === null || onPiece === void 0 ? void 0 : onPiece([words], 0);
163
139
  // Says are counted on both sides alike: the audio of this one may come before the call answers.
164
140
  const say = ++this.says;
165
- this.reading = { say, onEnd, said: false };
141
+ const reading = { say, onEnd, said: false };
142
+ // Its captions follow its sound, a sentence as it is heard (VoiceReading); without a clock, the whole answer at once.
143
+ reading.clock = (_c = this.clockOf(reading, voice_1.Voice.sentences(words), onPiece)) !== null && _c !== void 0 ? _c : void (onPiece === null || onPiece === void 0 ? void 0 : onPiece([words], 0));
144
+ this.reading = reading;
166
145
  this.playAt = 0;
167
146
  // Suspended while the page had no tap since it opened the voice: a tap since lets it play.
168
147
  void ((_b = this.context) === null || _b === void 0 ? void 0 : _b.resume().catch(() => undefined));
169
148
  this.host.voice.sayVoice(this.session.voiceId, words).catch(() => this.finishReading(say));
170
149
  }
171
150
  hush() {
151
+ var _a;
172
152
  this.device.hush();
173
153
  this.clearDoubt();
154
+ this.quietUntil = 0;
174
155
  const reading = this.reading;
175
156
  this.reading = undefined;
176
- for (const node of this.playing) {
177
- node.onended = null;
178
- try {
179
- node.stop();
180
- }
181
- catch (_a) {
182
- // Ended already.
183
- }
157
+ this.stopPlaying();
158
+ if (this.talking) {
159
+ // What it says now goes, and what comes of it late is not played.
160
+ this.talking.cut = Math.max(this.talking.cut, (_a = reading === null || reading === void 0 ? void 0 : reading.say) !== null && _a !== void 0 ? _a : 0, this.says);
184
161
  }
185
- this.playing.clear();
186
- if (reading && this.session && !this.closed) {
162
+ if ((reading || this.talking) && this.session && !this.closed) {
187
163
  void this.host.voice.hushVoice(this.session.voiceId).catch(() => undefined);
188
164
  }
189
165
  }
@@ -194,9 +170,8 @@ class RealtimeVoice {
194
170
  stop() {
195
171
  var _a, _b, _c, _d;
196
172
  var _e;
197
- if (this.stopped) {
173
+ if (this.stopped)
198
174
  return;
199
- }
200
175
  const gone = this.closed;
201
176
  this.stopped = true;
202
177
  this.closed = true;
@@ -219,7 +194,8 @@ class RealtimeVoice {
219
194
  }
220
195
  /** Sound of the microphone: sent while Ta listens or reads, in pieces of CHUNK_MS. */
221
196
  captured(samples) {
222
- if (this.closed || !this.session || !this.context || (!this.hearing && !this.reading)) {
197
+ const sending = this.talking ? !this.talking.muted : !!(this.hearing || this.reading);
198
+ if (this.closed || !this.session || !this.context || !sending) {
223
199
  this.buffered = [];
224
200
  this.bufferedLength = 0;
225
201
  return;
@@ -227,7 +203,7 @@ class RealtimeVoice {
227
203
  this.measure(samples, this.context.sampleRate);
228
204
  this.buffered.push(new Float32Array(samples));
229
205
  this.bufferedLength += samples.length;
230
- if (this.bufferedLength < (this.context.sampleRate * CHUNK_MS) / 1000) {
206
+ if (this.bufferedLength < (this.context.sampleRate * realtime_voice_protocol_1.CHUNK_MS) / 1000) {
231
207
  return;
232
208
  }
233
209
  const all = new Float32Array(this.bufferedLength);
@@ -238,8 +214,23 @@ class RealtimeVoice {
238
214
  }
239
215
  this.buffered = [];
240
216
  this.bufferedLength = 0;
241
- const pcm = PcmUtil.toPcm16(all, this.context.sampleRate, this.session.inputRate);
242
- void this.host.voice.sendVoice(this.session.voiceId, PcmUtil.base64(pcm)).catch(() => undefined);
217
+ const pcm = pcm_util_1.PcmUtil.toPcm16(all, this.context.sampleRate, this.session.inputRate);
218
+ // Louder than the floor of the room: what may be speech goes as it is, the rest as silence (NoiseGate).
219
+ const level = pcm_util_1.PcmUtil.rms(all);
220
+ const loud = level >= Math.max(realtime_voice_protocol_1.GATE_LEVEL, this.sense.floor * realtime_voice_protocol_1.GATE_ABOVE) || (level >= realtime_voice_protocol_1.GATE_LEVEL && mic_sense_1.MicSense.voicing(all, this.context.sampleRate) >= 0.5);
221
+ const heard = this.mic.take(pcm, loud, !!this.talking && this.gated);
222
+ if (heard) {
223
+ this.send(heard);
224
+ }
225
+ }
226
+ send(pcm) {
227
+ if (this.session && !this.closed) {
228
+ void this.host.voice.sendVoice(this.session.voiceId, pcm_util_1.PcmUtil.base64(pcm)).catch(() => undefined);
229
+ }
230
+ }
231
+ /** Of a voice that thinks: its answer plays, or just did; the microphone is held (MicFilter). */
232
+ get gated() {
233
+ return !!this.reading || this.clock < this.quietUntil;
243
234
  }
244
235
  take(event) {
245
236
  var _a, _b, _c;
@@ -247,6 +238,10 @@ class RealtimeVoice {
247
238
  if (!this.session || event.voiceId !== this.session.voiceId || this.closed) {
248
239
  return;
249
240
  }
241
+ if (this.talking && event.type !== 'closed') {
242
+ this.thought(this.talking, event);
243
+ return;
244
+ }
250
245
  switch (event.type) {
251
246
  case 'speech':
252
247
  // A sound while Ta reads: it may be the user cutting in, or a noise of theirs; the reading goes on
@@ -262,8 +257,8 @@ class RealtimeVoice {
262
257
  case 'text': {
263
258
  // Words, not a breath nor the "嗯" of someone listening, cut in; not those of Ta's own voice heard back,
264
259
  // when all the sound was no louder than it.
265
- const echo = ((_a = this.doubt) === null || _a === void 0 ? void 0 : _a.echoed) && !this.doubt.voiced;
266
- if (this.doubt && !echo && turn_end_1.TurnEnd.words(event.text) >= this.barge.words) {
260
+ // Only once some of the sound was voiced speech louder than Ta's echo: not a cough heard as a word.
261
+ if (((_a = this.doubt) === null || _a === void 0 ? void 0 : _a.voiced) && turn_end_1.TurnEnd.words(event.text) >= this.barge.words) {
267
262
  this.bargeIn();
268
263
  }
269
264
  const hearing = this.hearing;
@@ -291,12 +286,12 @@ class RealtimeVoice {
291
286
  }
292
287
  case 'audio':
293
288
  if (((_b = this.reading) === null || _b === void 0 ? void 0 : _b.say) === event.say) {
294
- this.play(PcmUtil.toFloat(PcmUtil.bytes(event.data)));
289
+ this.heard(event.say, event.data);
295
290
  }
296
291
  return;
297
292
  case 'said':
298
293
  if (((_c = this.reading) === null || _c === void 0 ? void 0 : _c.say) === event.say) {
299
- this.reading.said = true;
294
+ this.allCame(this.reading);
300
295
  if (!this.playing.size) {
301
296
  this.finishReading(event.say);
302
297
  }
@@ -307,18 +302,66 @@ class RealtimeVoice {
307
302
  return;
308
303
  }
309
304
  }
310
- /** The service is gone: the listen and the reading going on end, the listen with `error`. */
311
- lose(error) {
312
- if (this.closed) {
313
- return;
305
+ /**
306
+ * An event of a voice that thinks: the user speaking stops its answer (the service stopped it too), its answers
307
+ * play as they come, each a say of its own, and the call is told.
308
+ */
309
+ thought(talking, event) {
310
+ var _a, _b, _c, _d;
311
+ var _e;
312
+ const { talk } = talking;
313
+ switch (event.type) {
314
+ case 'speech':
315
+ talking.cut = Math.max(talking.cut, (_e = (_a = this.reading) === null || _a === void 0 ? void 0 : _a.say) !== null && _e !== void 0 ? _e : 0, this.says);
316
+ this.silence();
317
+ talk.cut();
318
+ return;
319
+ case 'text':
320
+ talk.heard(event.text, event.final);
321
+ return;
322
+ case 'reply':
323
+ if (event.say > talking.cut) {
324
+ talk.replying(event.text, !!this.context);
325
+ realtime_voice_protocol_1.Talking.reply(talking, event.say, event.text, (_b = this.reading) === null || _b === void 0 ? void 0 : _b.clock);
326
+ }
327
+ return;
328
+ case 'audio':
329
+ if (event.say <= talking.cut) {
330
+ return;
331
+ }
332
+ this.says = Math.max(this.says, event.say);
333
+ if (((_c = this.reading) === null || _c === void 0 ? void 0 : _c.say) !== event.say) {
334
+ this.silence();
335
+ this.playAt = 0;
336
+ this.reading = { say: event.say, said: false, onEnd: () => talk.replied(false) };
337
+ this.reading.clock = this.clockOf(this.reading, [...realtime_voice_protocol_1.Talking.pieces(talking, event.say)], (pieces, at) => { var _a; return (_a = talk.reading) === null || _a === void 0 ? void 0 : _a.call(talk, pieces, at); });
338
+ }
339
+ this.heard(event.say, event.data);
340
+ return;
341
+ case 'said':
342
+ if (((_d = this.reading) === null || _d === void 0 ? void 0 : _d.say) === event.say) {
343
+ const reading = this.reading;
344
+ if (event.end) {
345
+ reading.onEnd = () => talk.replied(true);
346
+ }
347
+ this.allCame(reading);
348
+ if (!this.playing.size) {
349
+ this.finishReading(event.say);
350
+ }
351
+ }
352
+ else if (event.end) {
353
+ // It hung up with nothing said.
354
+ talk.replied(true);
355
+ }
356
+ return;
314
357
  }
315
- this.closed = true;
316
- this.clearDoubt();
317
- const hearing = this.hearing;
318
- this.endHearing();
319
- hearing === null || hearing === void 0 ? void 0 : hearing.onEnd(error);
320
- const reading = this.reading;
358
+ }
359
+ /** What plays now stops, here only: the service stopped it, or will drop it. */
360
+ silence() {
321
361
  this.reading = undefined;
362
+ this.stopPlaying();
363
+ }
364
+ stopPlaying() {
322
365
  for (const node of this.playing) {
323
366
  node.onended = null;
324
367
  try {
@@ -329,10 +372,28 @@ class RealtimeVoice {
329
372
  }
330
373
  }
331
374
  this.playing.clear();
375
+ }
376
+ /** The service is gone: the listen and the reading going on end, the listen with `error`. */
377
+ lose(error) {
378
+ if (this.closed)
379
+ return;
380
+ this.closed = true;
381
+ this.clearDoubt();
382
+ const hearing = this.hearing;
383
+ this.endHearing();
384
+ hearing === null || hearing === void 0 ? void 0 : hearing.onEnd(error);
385
+ const reading = this.reading;
386
+ this.reading = undefined;
387
+ this.stopPlaying();
388
+ if (this.talking) {
389
+ this.talking.talk.lost(error);
390
+ return;
391
+ }
332
392
  reading === null || reading === void 0 ? void 0 : reading.onEnd();
333
393
  }
334
394
  play(samples) {
335
395
  var _a;
396
+ var _b;
336
397
  const context = this.context;
337
398
  const reading = this.reading;
338
399
  if (!context || !reading || !samples.length || !this.session) {
@@ -342,10 +403,13 @@ class RealtimeVoice {
342
403
  buffer.copyToChannel(samples, 0);
343
404
  const node = context.createBufferSource();
344
405
  node.buffer = buffer;
345
- node.connect((_a = this.gain) !== null && _a !== void 0 ? _a : context.destination);
346
- const at = Math.max(this.playAt, context.currentTime + 0.05);
406
+ node.connect((_b = this.gain) !== null && _b !== void 0 ? _b : context.destination);
407
+ // A reading waits as long as it is held at first, and again once what is left to play ran low: the mouth is drawn.
408
+ const soon = context.currentTime + 0.05;
409
+ const at = this.playAt - soon >= this.tap.holdS / 2 && this.playAt > 0 ? this.playAt : soon + this.tap.holdS;
347
410
  node.start(at);
348
411
  this.playAt = at + buffer.duration;
412
+ (_a = reading.clock) === null || _a === void 0 ? void 0 : _a.heard(at, buffer.duration);
349
413
  this.playing.add(node);
350
414
  node.onended = () => {
351
415
  this.playing.delete(node);
@@ -359,6 +423,9 @@ class RealtimeVoice {
359
423
  if ((reading === null || reading === void 0 ? void 0 : reading.say) === say) {
360
424
  this.reading = undefined;
361
425
  this.clearDoubt();
426
+ if (this.talking) {
427
+ this.quietUntil = this.clock + realtime_voice_protocol_1.ECHO_TAIL_MS;
428
+ }
362
429
  reading.onEnd();
363
430
  }
364
431
  }
@@ -370,7 +437,7 @@ class RealtimeVoice {
370
437
  this.endHearing();
371
438
  hearing.onEnd();
372
439
  }
373
- }, exports.REALTIME_SILENCE_MS);
440
+ }, realtime_voice_protocol_1.REALTIME_SILENCE_MS);
374
441
  }
375
442
  endHearing() {
376
443
  if (this.hearing) {
@@ -391,66 +458,84 @@ class RealtimeVoice {
391
458
  this.played.fftSize = 2048;
392
459
  this.gain.connect(this.played);
393
460
  }
394
- /** How loud what plays now is (RMS, 0 to 1). */
395
- playedLevel() {
396
- if (!this.played || !this.reading) {
461
+ /** How loud what plays now is (RMS, 0 to 1), its own answers too (thinks); `samples` made once, read every frame by the face of a call. */
462
+ level() {
463
+ var _a;
464
+ if (!this.played || !this.playing.size)
397
465
  return 0;
398
- }
399
- const samples = new Float32Array(this.played.fftSize);
400
- this.played.getFloatTimeDomainData(samples);
401
- return RealtimeVoice.rms(samples);
466
+ (_a = this.samples) !== null && _a !== void 0 ? _a : (this.samples = new Float32Array(this.played.fftSize));
467
+ this.played.getFloatTimeDomainData(this.samples);
468
+ return pcm_util_1.PcmUtil.rms(this.samples);
469
+ }
470
+ nowReading() {
471
+ var _a;
472
+ return (_a = this.reading) === null || _a === void 0 ? void 0 : _a.clock;
473
+ }
474
+ /** Sound of the reading `say` came: told to who listens (the face of a video call), and played. */
475
+ heard(say, data) {
476
+ var _a;
477
+ const pcm = pcm_util_1.PcmUtil.bytes(data);
478
+ this.tap.tell(say, pcm, (_a = this.session) === null || _a === void 0 ? void 0 : _a.outputRate);
479
+ this.play(pcm_util_1.PcmUtil.toFloat(pcm));
480
+ }
481
+ /** All the sound of a reading came: it ends once played, and who listens knows. */
482
+ allCame(reading) {
483
+ var _a, _b;
484
+ reading.said = true;
485
+ (_a = reading.clock) === null || _a === void 0 ? void 0 : _a.said();
486
+ this.tap.tell(reading.say, undefined, (_b = this.session) === null || _b === void 0 ? void 0 : _b.outputRate);
487
+ }
488
+ clockOf(reading, pieces, onPiece) {
489
+ return this.context && new voice_reading_1.VoiceReading(reading.say, pieces, this.context, this.tap.holdS, () => this.reading === reading, onPiece);
402
490
  }
403
491
  /** A sound began while Ta reads: the reading goes on lower until the sound is known as speech, or not. */
404
492
  suspect() {
405
- if (this.doubt) {
493
+ if (this.doubt)
406
494
  return;
407
- }
408
- this.doubt = { loud: 0, timer: setTimeout(() => this.clearDoubt(), this.barge.waitMs) };
409
- this.loudness(this.barge.duck);
495
+ // Not lower yet: only once it is voiced speech a while (weigh), so that a cough or a knock never cuts the voice.
496
+ this.doubt = { loud: 0, quiet: 0, timer: setTimeout(() => this.clearDoubt(), this.barge.waitMs) };
410
497
  }
411
498
  /**
412
499
  * Microphone samples: while in doubt, speech long enough is the user cutting in; else, while no one speaks, they
413
500
  * are the sound around, which speech must be louder than.
414
501
  */
415
502
  measure(samples, rate) {
416
- const level = RealtimeVoice.rms(samples);
503
+ const { level, voiced } = this.sense.measure(samples, rate);
417
504
  const ms = (samples.length / rate) * 1000;
418
505
  this.clock += ms;
419
506
  if (this.hearing && level >= this.speechLevel) {
420
507
  this.voiceAt = this.clock;
421
508
  }
422
- if (this.doubt) {
423
- this.weigh(level, ms);
509
+ // A voice that thinks hears nothing while its answer plays (gated): Ta itself hears the user begin to cut in.
510
+ if (this.talking && this.reading && this.cutsIn && !this.doubt && voiced && level >= this.speechLevel && level >= this.level() * this.barge.echo) {
511
+ this.suspect();
424
512
  }
425
- else if (this.reading || (this.hearing && !this.hearing.speaking)) {
426
- this.noise = this.noise ? this.noise * 0.9 + level * 0.1 : level;
513
+ // A cough, a knock, a cup set down is not voiced, and does not count (MicSense.weigh).
514
+ const echo = (this.reading ? this.level() : 0) * this.barge.echo;
515
+ const weighed = this.doubt && mic_sense_1.MicSense.weigh(this.doubt, { level, voiced }, ms, this.speechLevel, echo, this.barge);
516
+ if (weighed === 'duck') {
517
+ this.loudness(this.barge.duck);
427
518
  }
428
- }
429
- /** The level that counts as speech: BargeIn.level, or louder than the sound around. */
430
- get speechLevel() {
431
- return Math.max(this.barge.level, Math.min(this.noise, NOISE_CAP) * ABOVE_NOISE);
432
- }
433
- /**
434
- * A piece of the microphone while in doubt: speech long enough is the user cutting in, unless it is no louder than
435
- * Ta's own voice heard back (what plays, times TaBargeIn.echo).
436
- */
437
- weigh(level, ms) {
438
- if (!this.doubt || level < this.speechLevel) {
439
- return;
440
- }
441
- if (level < this.playedLevel() * this.barge.echo) {
442
- this.doubt.echoed = true;
443
- return;
444
- }
445
- this.doubt.voiced = true;
446
- this.doubt.loud += ms;
447
- if (this.doubt.loud >= this.barge.speechMs) {
519
+ else if (weighed === 'cut') {
448
520
  this.bargeIn();
449
521
  }
450
522
  }
523
+ /** The level that counts as speech: BargeIn.level, or louder than the floor of the room. */
524
+ get speechLevel() {
525
+ return Math.max(this.barge.level, Math.min(this.sense.floor, realtime_voice_protocol_1.NOISE_CAP) * realtime_voice_protocol_1.ABOVE_NOISE);
526
+ }
451
527
  /** The user cut in: the call stops the reading and listens, and this listen hears the sentence begun. */
452
528
  bargeIn() {
453
529
  this.clearDoubt();
530
+ if (this.talking) {
531
+ // Its answer stops, and the service hears the user from the start of their words.
532
+ const held = this.mic.cutIn();
533
+ this.hush();
534
+ this.talking.talk.cut();
535
+ for (const pcm of held) {
536
+ this.send(pcm);
537
+ }
538
+ }
454
539
  for (const listener of this.speechListeners) {
455
540
  listener();
456
541
  }
@@ -468,15 +553,9 @@ class RealtimeVoice {
468
553
  }
469
554
  loudness(value) {
470
555
  if (this.gain && this.context) {
471
- this.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.05);
472
- }
473
- }
474
- static rms(samples) {
475
- let sum = 0;
476
- for (const sample of samples) {
477
- sum += sample * sample;
556
+ // Gently: lower over about a third of a second, never at once.
557
+ this.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.1);
478
558
  }
479
- return Math.sqrt(sum / (samples.length || 1));
480
559
  }
481
560
  }
482
561
  exports.RealtimeVoice = RealtimeVoice;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * When each sentence of what a voice service reads is heard (docs/design/ta-call.md 12): its words are known at once,
3
+ * its sound comes as the service makes it, and how long it lasts only once all of it came. The sentence at a moment
4
+ * is guessed from where its words are in the whole, on the length the sound will have (what came, or what the words
5
+ * take at their pace, whichever is longer), and kept once asked: the captions, the clip of the person and the frames of
6
+ * her mouth all ask it for the same moments, so that they never disagree.
7
+ */
8
+ export declare class SpokenTimeline {
9
+ readonly pieces: readonly string[];
10
+ /** How many characters a second the voice reads, about. */
11
+ protected readonly pace: number;
12
+ /** Seconds of sound that came so far. */
13
+ received: number;
14
+ /** All of it came. */
15
+ said: boolean;
16
+ /** When each sentence asked for begins, in seconds of the reading: the first at 0. */
17
+ protected readonly starts: number[];
18
+ protected readonly before: number[];
19
+ protected readonly chars: number;
20
+ constructor(pieces: readonly string[],
21
+ /** How many characters a second the voice reads, about. */
22
+ pace: number);
23
+ /** The sentence heard `seconds` into the reading; what was asked once stays. */
24
+ at(seconds: number): number;
25
+ /** Characters a second a voice reads in a language, about: Chinese and Japanese by characters, others by letters. */
26
+ static pace(text: string): number;
27
+ }
28
+ //# sourceMappingURL=spoken-timeline.d.ts.map
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpokenTimeline = void 0;
4
+ /**
5
+ * When each sentence of what a voice service reads is heard (docs/design/ta-call.md 12): its words are known at once,
6
+ * its sound comes as the service makes it, and how long it lasts only once all of it came. The sentence at a moment
7
+ * is guessed from where its words are in the whole, on the length the sound will have (what came, or what the words
8
+ * take at their pace, whichever is longer), and kept once asked: the captions, the clip of the person and the frames of
9
+ * her mouth all ask it for the same moments, so that they never disagree.
10
+ */
11
+ class SpokenTimeline {
12
+ constructor(pieces,
13
+ /** How many characters a second the voice reads, about. */
14
+ pace) {
15
+ this.pieces = pieces;
16
+ this.pace = pace;
17
+ /** Seconds of sound that came so far. */
18
+ this.received = 0;
19
+ /** All of it came. */
20
+ this.said = false;
21
+ /** When each sentence asked for begins, in seconds of the reading: the first at 0. */
22
+ this.starts = [0];
23
+ let sum = 0;
24
+ this.before = pieces.map(piece => {
25
+ const at = sum;
26
+ sum += piece.length;
27
+ return at;
28
+ });
29
+ this.chars = Math.max(1, sum);
30
+ }
31
+ /** The sentence heard `seconds` into the reading; what was asked once stays. */
32
+ at(seconds) {
33
+ const total = this.said ? this.received : Math.max(this.received, this.chars / this.pace);
34
+ while (this.starts.length < this.pieces.length) {
35
+ const next = Math.max(this.starts[this.starts.length - 1], (total * this.before[this.starts.length]) / this.chars);
36
+ if (next > seconds) {
37
+ break;
38
+ }
39
+ this.starts.push(next);
40
+ }
41
+ let index = this.starts.length - 1;
42
+ while (index > 0 && this.starts[index] > seconds) {
43
+ index--;
44
+ }
45
+ return index;
46
+ }
47
+ /** Characters a second a voice reads in a language, about: Chinese and Japanese by characters, others by letters. */
48
+ static pace(text) {
49
+ return /[\u3040-\u30ff\u3400-\u9fff]/.test(text) ? 4.5 : 14;
50
+ }
51
+ }
52
+ exports.SpokenTimeline = SpokenTimeline;
53
+ //# sourceMappingURL=spoken-timeline.js.map
@@ -1,3 +1,4 @@
1
+ import type { ImageContent, TaCallScene, TaVoices } from '@celljs/ta-protocol';
1
2
  import * as React from 'react';
2
3
  import type { ComposerAction } from '../components/composer-box-protocol';
3
4
  import type { TalkCall } from '../components/voice-talk';
@@ -24,13 +25,17 @@ export declare function talkCall(call: VoiceCall): (said: {
24
25
  sent: Promise<unknown>;
25
26
  } | undefined, how: TalkCall) => void;
26
27
  export declare namespace CallPartnerUtil {
28
+ /** Calls are answered by the voice service's own model: the user chose it, and the service in use thinks. */
29
+ function voiced(voices: TaVoices | undefined): boolean;
27
30
  /**
28
31
  * The side of a call of a partner of an extension, its replies said whole (SpokenReply.whole: they are written for
29
32
  * the ear); undefined when it leaves the call to the conversation.
30
33
  */
31
- function open(partner: WebCallPartner, target: WebCallTarget): Promise<CallPartner | undefined>;
34
+ function open(partner: WebCallPartner, target: WebCallTarget, look?: (text: string) => ImageContent | undefined, scenes?: (changed: (scene: TaCallScene) => void) => () => void): Promise<CallPartner | undefined>;
32
35
  /** An answer begun by the partner before the user was known to be done, its reply said whole. */
33
- function draft(session: WebCallSession, text: string): CallDraft;
36
+ function draft(session: WebCallSession, text: string, options?: {
37
+ images?: ImageContent[];
38
+ }): CallDraft;
34
39
  /** After a failure to ask for what the partner says by itself, before it asks again. */
35
40
  const RETRY_MS = 3000;
36
41
  /** Asks for what the partner says by itself again and again, each as it comes, until the call is over. */
@@ -59,6 +64,8 @@ export declare function dialogAnnouncements(requests: readonly {
59
64
  }[], t: Translate): CallAnnouncement[];
60
65
  /** Call, in the + of a conversation's box. */
61
66
  export declare function callAction(state: CallState, call: VoiceCall, t: Translate): ComposerAction;
67
+ /** Video call, beside Call: Ta shows as a person who speaks, and sees the user once they turn their camera on (docs/design/ta-call.md 12). */
68
+ export declare function videoCallAction(state: CallState, call: VoiceCall, t: Translate): ComposerAction;
62
69
  /**
63
70
  * Over the message box while in a call: what Ta does now (with captions, what is said, in its line), and the buttons to
64
71
  * interrupt it and hang up; marked as the part of the call (CallScreen), which Ta's agents read and work by these