@celljs/ta-web 4.26.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 (290) 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/chat-home.d.ts +6 -4
  43. package/esm/browser/components/chat-home.js +7 -7
  44. package/esm/browser/components/chat-icon.js +9 -5
  45. package/esm/browser/components/chat-list-hooks.d.ts +14 -4
  46. package/esm/browser/components/chat-list-hooks.js +11 -5
  47. package/esm/browser/components/chat-list-row.d.ts +7 -4
  48. package/esm/browser/components/chat-list-row.js +22 -10
  49. package/esm/browser/components/chat-list.js +6 -11
  50. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  51. package/esm/browser/components/conversation-scroll-util.d.ts +8 -1
  52. package/esm/browser/components/conversation-scroll-util.js +21 -0
  53. package/esm/browser/components/conversation-scroll.js +10 -11
  54. package/esm/browser/components/gallery.js +28 -7
  55. package/esm/browser/components/host-view.d.ts +1 -1
  56. package/esm/browser/components/image-pull.d.ts +64 -0
  57. package/esm/browser/components/image-pull.js +202 -0
  58. package/esm/browser/components/kept-call-bar.js +2 -1
  59. package/esm/browser/components/lightbox.d.ts +1 -1
  60. package/esm/browser/components/lightbox.js +57 -2
  61. package/esm/browser/components/markdown.d.ts +3 -1
  62. package/esm/browser/components/markdown.js +8 -4
  63. package/esm/browser/components/partner-row.js +2 -1
  64. package/esm/browser/components/relay-services.d.ts +9 -3
  65. package/esm/browser/components/relay-services.js +73 -35
  66. package/esm/browser/components/session-view.js +4 -2
  67. package/esm/browser/components/settings-parts.js +2 -0
  68. package/esm/browser/components/ta-avatar.d.ts +15 -1
  69. package/esm/browser/components/ta-avatar.js +72 -11
  70. package/esm/browser/components/voice-services.js +6 -1
  71. package/esm/browser/extension/web-api-call.d.ts +64 -2
  72. package/esm/browser/extension/web-api-contributions.d.ts +1 -0
  73. package/esm/browser/extension/web-api-partners.d.ts +2 -0
  74. package/esm/browser/extension/web-extension-api.d.ts +6 -6
  75. package/esm/browser/extension/web-extension-context.js +1 -0
  76. package/esm/browser/extension/web-extension-protocol.d.ts +3 -1
  77. package/esm/browser/extension/web-extension-run.d.ts +3 -2
  78. package/esm/browser/extension/web-extension-run.js +2 -0
  79. package/esm/browser/hosts.d.ts +2 -0
  80. package/esm/browser/hosts.js +22 -3
  81. package/esm/browser/i18n/locales.d.ts +24 -5
  82. package/esm/browser/i18n/messages-ja.js +25 -6
  83. package/esm/browser/i18n/messages-zh-tw.js +25 -6
  84. package/esm/browser/i18n/messages.d.ts +23 -4
  85. package/esm/browser/i18n/messages.js +50 -12
  86. package/esm/browser/markdown/code-renderers.d.ts +2 -0
  87. package/esm/browser/markdown/code-renderers.js +2 -0
  88. package/esm/browser/screen/page-answers.d.ts +2 -1
  89. package/esm/browser/screen/page-answers.js +7 -4
  90. package/esm/browser/settings/settings-protocol.d.ts +2 -0
  91. package/esm/browser/settings/settings-protocol.js +2 -0
  92. package/esm/browser/style/chat-list.d.ts +1 -1
  93. package/esm/browser/style/chat-list.js +1 -1
  94. package/esm/browser/style/conversation.d.ts +1 -1
  95. package/esm/browser/style/conversation.js +6 -1
  96. package/esm/browser/style/device.js +1 -0
  97. package/esm/browser/style/dialogs.d.ts +1 -1
  98. package/esm/browser/style/dialogs.js +1 -1
  99. package/esm/browser/style/layout.d.ts +1 -1
  100. package/esm/browser/style/layout.js +135 -57
  101. package/esm/browser/style/shell.d.ts +1 -1
  102. package/esm/browser/style/shell.js +8 -0
  103. package/esm/browser/style/video-call.d.ts +2 -0
  104. package/esm/browser/style/video-call.js +52 -0
  105. package/esm/browser/style.js +2 -0
  106. package/esm/browser/util/desktop.d.ts +10 -1
  107. package/esm/browser/util/desktop.js +10 -0
  108. package/esm/browser/util/image-pull.d.ts +61 -0
  109. package/esm/browser/util/image-pull.js +88 -0
  110. package/esm/browser/util/spoken.d.ts +3 -3
  111. package/esm/browser/util/spoken.js +4 -4
  112. package/esm/browser/video-call/call-camera.d.ts +59 -0
  113. package/esm/browser/video-call/call-camera.js +188 -0
  114. package/esm/browser/video-call/call-window.d.ts +19 -0
  115. package/esm/browser/video-call/call-window.js +80 -0
  116. package/esm/browser/video-call/clip-plan.d.ts +47 -0
  117. package/esm/browser/video-call/clip-plan.js +60 -0
  118. package/esm/browser/video-call/face-clips.d.ts +33 -0
  119. package/esm/browser/video-call/face-clips.js +93 -0
  120. package/esm/browser/video-call/face-files.d.ts +31 -0
  121. package/esm/browser/video-call/face-files.js +77 -0
  122. package/esm/browser/video-call/video-call-view.d.ts +19 -0
  123. package/esm/browser/video-call/video-call-view.js +214 -0
  124. package/esm/browser/video-call/video-face.d.ts +13 -0
  125. package/esm/browser/video-call/video-face.js +497 -0
  126. package/esm/browser/workbench-hosts.d.ts +1 -0
  127. package/esm/browser/workbench-hosts.js +8 -4
  128. package/esm/browser/workbench-lists.d.ts +16 -1
  129. package/esm/browser/workbench-lists.js +38 -3
  130. package/esm/browser/workbench-protocol.d.ts +2 -0
  131. package/esm/browser/workbench-util.d.ts +5 -0
  132. package/esm/browser/workbench-util.js +18 -0
  133. package/esm/browser/workbench.d.ts +6 -0
  134. package/esm/browser/workbench.js +36 -5
  135. package/lib/browser/assistant/assistant-role.d.ts +9 -4
  136. package/lib/browser/assistant/assistant-role.js +17 -5
  137. package/lib/browser/assistant/assistant-task-util.d.ts +6 -0
  138. package/lib/browser/assistant/assistant-task-util.js +11 -0
  139. package/lib/browser/assistant/assistant-view.js +3 -0
  140. package/lib/browser/assistant/assistant.d.ts +2 -1
  141. package/lib/browser/assistant/assistant.js +9 -7
  142. package/lib/browser/assistant/call-conversing.d.ts +46 -0
  143. package/lib/browser/assistant/call-conversing.js +96 -0
  144. package/lib/browser/assistant/call-face.d.ts +14 -0
  145. package/lib/browser/assistant/call-face.js +117 -0
  146. package/lib/browser/assistant/call-keeper.d.ts +8 -4
  147. package/lib/browser/assistant/call-keeper.js +32 -11
  148. package/lib/browser/assistant/call-partnering.d.ts +38 -0
  149. package/lib/browser/assistant/call-partnering.js +83 -0
  150. package/lib/browser/assistant/call-scenes.d.ts +26 -0
  151. package/lib/browser/assistant/call-scenes.js +85 -0
  152. package/lib/browser/assistant/call-screen.d.ts +3 -0
  153. package/lib/browser/assistant/call-screen.js +15 -0
  154. package/lib/browser/assistant/mic-sense.d.ts +32 -0
  155. package/lib/browser/assistant/mic-sense.js +123 -0
  156. package/lib/browser/assistant/noise-gate.d.ts +33 -0
  157. package/lib/browser/assistant/noise-gate.js +71 -0
  158. package/lib/browser/assistant/pcm-util.d.ts +11 -0
  159. package/lib/browser/assistant/pcm-util.js +58 -0
  160. package/lib/browser/assistant/read-aloud.d.ts +2 -1
  161. package/lib/browser/assistant/realtime-voice-protocol.d.ts +85 -0
  162. package/lib/browser/assistant/realtime-voice-protocol.js +43 -0
  163. package/lib/browser/assistant/realtime-voice.d.ts +50 -62
  164. package/lib/browser/assistant/realtime-voice.js +217 -138
  165. package/lib/browser/assistant/spoken-timeline.d.ts +28 -0
  166. package/lib/browser/assistant/spoken-timeline.js +53 -0
  167. package/lib/browser/assistant/voice-call-bar.d.ts +9 -2
  168. package/lib/browser/assistant/voice-call-bar.js +81 -30
  169. package/lib/browser/assistant/voice-call-protocol.d.ts +61 -4
  170. package/lib/browser/assistant/voice-call.d.ts +16 -23
  171. package/lib/browser/assistant/voice-call.js +134 -117
  172. package/lib/browser/assistant/voice-reading.d.ts +84 -0
  173. package/lib/browser/assistant/voice-reading.js +156 -0
  174. package/lib/browser/avatar/dino-talk.d.ts +16 -0
  175. package/lib/browser/avatar/dino-talk.js +37 -0
  176. package/lib/browser/components/chat-home.d.ts +6 -4
  177. package/lib/browser/components/chat-home.js +8 -9
  178. package/lib/browser/components/chat-icon.js +9 -5
  179. package/lib/browser/components/chat-list-hooks.d.ts +14 -4
  180. package/lib/browser/components/chat-list-hooks.js +12 -6
  181. package/lib/browser/components/chat-list-row.d.ts +7 -4
  182. package/lib/browser/components/chat-list-row.js +23 -12
  183. package/lib/browser/components/chat-list.js +5 -10
  184. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  185. package/lib/browser/components/conversation-scroll-util.d.ts +8 -1
  186. package/lib/browser/components/conversation-scroll-util.js +21 -0
  187. package/lib/browser/components/conversation-scroll.js +10 -11
  188. package/lib/browser/components/gallery.js +28 -7
  189. package/lib/browser/components/host-view.d.ts +1 -1
  190. package/lib/browser/components/image-pull.d.ts +65 -0
  191. package/lib/browser/components/image-pull.js +206 -0
  192. package/lib/browser/components/kept-call-bar.js +2 -1
  193. package/lib/browser/components/lightbox.d.ts +1 -1
  194. package/lib/browser/components/lightbox.js +57 -2
  195. package/lib/browser/components/markdown.d.ts +3 -1
  196. package/lib/browser/components/markdown.js +7 -3
  197. package/lib/browser/components/partner-row.js +2 -1
  198. package/lib/browser/components/relay-services.d.ts +9 -3
  199. package/lib/browser/components/relay-services.js +71 -33
  200. package/lib/browser/components/session-view.js +3 -1
  201. package/lib/browser/components/settings-parts.js +2 -0
  202. package/lib/browser/components/ta-avatar.d.ts +15 -1
  203. package/lib/browser/components/ta-avatar.js +72 -11
  204. package/lib/browser/components/voice-services.js +5 -0
  205. package/lib/browser/extension/web-api-call.d.ts +64 -2
  206. package/lib/browser/extension/web-api-contributions.d.ts +1 -0
  207. package/lib/browser/extension/web-api-partners.d.ts +2 -0
  208. package/lib/browser/extension/web-extension-api.d.ts +6 -6
  209. package/lib/browser/extension/web-extension-context.js +1 -0
  210. package/lib/browser/extension/web-extension-protocol.d.ts +3 -1
  211. package/lib/browser/extension/web-extension-run.d.ts +3 -2
  212. package/lib/browser/extension/web-extension-run.js +2 -0
  213. package/lib/browser/hosts.d.ts +2 -0
  214. package/lib/browser/hosts.js +22 -3
  215. package/lib/browser/i18n/locales.d.ts +24 -5
  216. package/lib/browser/i18n/messages-ja.js +25 -6
  217. package/lib/browser/i18n/messages-zh-tw.js +25 -6
  218. package/lib/browser/i18n/messages.d.ts +23 -4
  219. package/lib/browser/i18n/messages.js +50 -12
  220. package/lib/browser/markdown/code-renderers.d.ts +2 -0
  221. package/lib/browser/markdown/code-renderers.js +3 -1
  222. package/lib/browser/screen/page-answers.d.ts +2 -1
  223. package/lib/browser/screen/page-answers.js +7 -4
  224. package/lib/browser/settings/settings-protocol.d.ts +2 -0
  225. package/lib/browser/settings/settings-protocol.js +2 -0
  226. package/lib/browser/style/chat-list.d.ts +1 -1
  227. package/lib/browser/style/chat-list.js +1 -1
  228. package/lib/browser/style/conversation.d.ts +1 -1
  229. package/lib/browser/style/conversation.js +6 -1
  230. package/lib/browser/style/device.js +1 -0
  231. package/lib/browser/style/dialogs.d.ts +1 -1
  232. package/lib/browser/style/dialogs.js +1 -1
  233. package/lib/browser/style/layout.d.ts +1 -1
  234. package/lib/browser/style/layout.js +135 -57
  235. package/lib/browser/style/shell.d.ts +1 -1
  236. package/lib/browser/style/shell.js +8 -0
  237. package/lib/browser/style/video-call.d.ts +3 -0
  238. package/lib/browser/style/video-call.js +55 -0
  239. package/lib/browser/style.js +2 -0
  240. package/lib/browser/util/desktop.d.ts +10 -1
  241. package/lib/browser/util/desktop.js +10 -0
  242. package/lib/browser/util/image-pull.d.ts +62 -0
  243. package/lib/browser/util/image-pull.js +91 -0
  244. package/lib/browser/util/spoken.d.ts +3 -3
  245. package/lib/browser/util/spoken.js +4 -4
  246. package/lib/browser/video-call/call-camera.d.ts +60 -0
  247. package/lib/browser/video-call/call-camera.js +192 -0
  248. package/lib/browser/video-call/call-window.d.ts +20 -0
  249. package/lib/browser/video-call/call-window.js +83 -0
  250. package/lib/browser/video-call/clip-plan.d.ts +48 -0
  251. package/lib/browser/video-call/clip-plan.js +64 -0
  252. package/lib/browser/video-call/face-clips.d.ts +34 -0
  253. package/lib/browser/video-call/face-clips.js +96 -0
  254. package/lib/browser/video-call/face-files.d.ts +32 -0
  255. package/lib/browser/video-call/face-files.js +82 -0
  256. package/lib/browser/video-call/video-call-view.d.ts +20 -0
  257. package/lib/browser/video-call/video-call-view.js +250 -0
  258. package/lib/browser/video-call/video-face.d.ts +14 -0
  259. package/lib/browser/video-call/video-face.js +533 -0
  260. package/lib/browser/workbench-hosts.d.ts +1 -0
  261. package/lib/browser/workbench-hosts.js +8 -4
  262. package/lib/browser/workbench-lists.d.ts +16 -1
  263. package/lib/browser/workbench-lists.js +38 -3
  264. package/lib/browser/workbench-protocol.d.ts +2 -0
  265. package/lib/browser/workbench-util.d.ts +5 -0
  266. package/lib/browser/workbench-util.js +18 -0
  267. package/lib/browser/workbench.d.ts +6 -0
  268. package/lib/browser/workbench.js +35 -4
  269. package/package.json +7 -7
  270. package/public/faces/README.md +27 -0
  271. package/public/faces/clap.mp4 +0 -0
  272. package/public/faces/dance.mp4 +0 -0
  273. package/public/faces/happy.mp4 +0 -0
  274. package/public/faces/heart.mp4 +0 -0
  275. package/public/faces/idle-1.mp4 +0 -0
  276. package/public/faces/idle-2.mp4 +0 -0
  277. package/public/faces/idle-3.mp4 +0 -0
  278. package/public/faces/laugh.mp4 +0 -0
  279. package/public/faces/lips.json +1 -0
  280. package/public/faces/listening.mp4 +0 -0
  281. package/public/faces/poster.jpg +0 -0
  282. package/public/faces/shy.mp4 +0 -0
  283. package/public/faces/sorry.mp4 +0 -0
  284. package/public/faces/stretch.mp4 +0 -0
  285. package/public/faces/surprised.mp4 +0 -0
  286. package/public/faces/talk-1.mp4 +0 -0
  287. package/public/faces/talk-2.mp4 +0 -0
  288. package/public/faces/think-2.mp4 +0 -0
  289. package/public/faces/thinking.mp4 +0 -0
  290. package/public/faces/wave.mp4 +0 -0
@@ -1,59 +1,11 @@
1
1
  import { TaBargeIn } from '@celljs/ta-protocol';
2
2
  import { TurnEnd } from '../util/turn-end.js';
3
3
  import { Voice } from '../util/voice.js';
4
- /** How long a listen waits for a sentence before it counts as silence. */
5
- export const REALTIME_SILENCE_MS = 12000;
6
- /** The audio sent at once, in ms of sound. */
7
- const CHUNK_MS = 100;
8
- /** 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). */
9
- const ABOVE_NOISE = 2;
10
- /** The sound around the user counts at most this loud: in a din, the level of BargeIn.level times this is speech. */
11
- const NOISE_CAP = 0.08;
12
- /** The samples of a microphone, made PCM16 mono at another rate. */
13
- export var PcmUtil;
14
- (function (PcmUtil) {
15
- /** Linear resampling of mono float samples to `to` Hz, as PCM16 little-endian. */
16
- function toPcm16(samples, from, to) {
17
- const ratio = from / to;
18
- const length = Math.floor(samples.length / ratio);
19
- const out = new DataView(new ArrayBuffer(length * 2));
20
- for (let i = 0; i < length; i++) {
21
- const at = i * ratio;
22
- const low = Math.floor(at);
23
- const high = Math.min(low + 1, samples.length - 1);
24
- const value = samples[low] + (samples[high] - samples[low]) * (at - low);
25
- out.setInt16(i * 2, Math.max(-1, Math.min(1, value)) * 0x7fff, true);
26
- }
27
- return new Uint8Array(out.buffer);
28
- }
29
- PcmUtil.toPcm16 = toPcm16;
30
- function toFloat(pcm) {
31
- const view = new DataView(pcm.buffer, pcm.byteOffset, pcm.byteLength);
32
- const out = new Float32Array(Math.floor(pcm.byteLength / 2));
33
- for (let i = 0; i < out.length; i++) {
34
- out[i] = view.getInt16(i * 2, true) / 0x8000;
35
- }
36
- return out;
37
- }
38
- PcmUtil.toFloat = toFloat;
39
- function base64(bytes) {
40
- let text = '';
41
- for (let i = 0; i < bytes.length; i += 0x8000) {
42
- text += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
43
- }
44
- return btoa(text);
45
- }
46
- PcmUtil.base64 = base64;
47
- function bytes(base64) {
48
- const text = atob(base64);
49
- const out = new Uint8Array(text.length);
50
- for (let i = 0; i < text.length; i++) {
51
- out[i] = text.charCodeAt(i);
52
- }
53
- return out;
54
- }
55
- PcmUtil.bytes = bytes;
56
- })(PcmUtil || (PcmUtil = {}));
4
+ import { MicSense } from './mic-sense.js';
5
+ import { MicFilter } from './noise-gate.js';
6
+ import { PcmUtil } from './pcm-util.js';
7
+ import { ABOVE_NOISE, CHUNK_MS, ECHO_TAIL_MS, GATE_ABOVE, GATE_LEVEL, NOISE_CAP, REALTIME_SILENCE_MS, Talking, } from './realtime-voice-protocol.js';
8
+ import { VoiceReading, VoiceSoundTap } from './voice-reading.js';
57
9
  /**
58
10
  * 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
59
11
  * while Ta listens or reads (so the service hears the user cut in), and what the service reads plays here. A service
@@ -73,19 +25,30 @@ export class RealtimeVoice {
73
25
  this.closed = false;
74
26
  /** stop() let go of the microphone and the service. */
75
27
  this.stopped = false;
76
- /** How loud the sound around the user is (noise, what is left of Ta's echo), as the microphone hears it. */
77
- this.noise = 0;
28
+ /** Of a voice that thinks: nothing is sent until the microphone's clock is here, as its answer dies away. */
29
+ this.quietUntil = 0;
30
+ /** What of the microphone the service hears: speech alone, and none of a voice that thinks playing its answer. */
31
+ this.mic = new MicFilter();
32
+ /** The sound of what it reads, for the face of a video call, and how long each reading is held for it. */
33
+ this.tap = new VoiceSoundTap();
34
+ this.onSound = this.tap.on;
35
+ this.hold = this.tap.hold;
36
+ /** The floor of the room, and whether what the microphone hears is voiced. */
37
+ this.sense = new MicSense();
78
38
  /** ms of sound the microphone gave, and where in it the user's voice was last heard while Ta listens. */
79
39
  this.clock = 0;
80
40
  this.voiceAt = Number.NEGATIVE_INFINITY;
81
41
  }
82
- /** Opens the service and, unless `hear` is false, the microphone; rejects with why one of them is not there. */
42
+ /**
43
+ * Opens the service and, unless `hear` is false, the microphone; rejects with why one of them is not there. With
44
+ * `brain`, a service that thinks answers by itself (thinks).
45
+ */
83
46
  async open(language, options = {}) {
84
47
  var _a, _b;
85
48
  var _c;
86
49
  this.offEvents = this.host.onVoiceEvent(event => this.take(event));
87
50
  try {
88
- this.session = await this.host.voice.openVoice({ language });
51
+ this.session = await this.host.voice.openVoice({ language, ...(options.brain ? { brain: options.brain } : {}) });
89
52
  this.offState = (_b = (_a = this.host).subscribe) === null || _b === void 0 ? void 0 : _b.call(_a, state => state.status !== 'online' && this.lose('disconnected'));
90
53
  const Context = (_c = globalThis.AudioContext) !== null && _c !== void 0 ? _c : globalThis.webkitAudioContext;
91
54
  if (options.hear === false) {
@@ -138,6 +101,20 @@ export class RealtimeVoice {
138
101
  get cutsIn() {
139
102
  return !this.barge.tap;
140
103
  }
104
+ /** Its own model answers the call: it hears, thinks and speaks by itself. */
105
+ get thinks() {
106
+ var _a;
107
+ return this.isOpen && !!((_a = this.session) === null || _a === void 0 ? void 0 : _a.thinks);
108
+ }
109
+ converse(talk) {
110
+ this.endHearing();
111
+ this.talking = { talk, cut: 0, muted: false };
112
+ }
113
+ mute(muted) {
114
+ if (this.talking) {
115
+ this.talking.muted = muted;
116
+ }
117
+ }
141
118
  /** It reads with the voice of the service, not with that of the device. */
142
119
  get speaks() {
143
120
  var _a;
@@ -145,6 +122,7 @@ export class RealtimeVoice {
145
122
  }
146
123
  speak(text, language, onEnd, voice, onPiece) {
147
124
  var _a, _b;
125
+ var _c;
148
126
  this.hush();
149
127
  if (!((_a = this.session) === null || _a === void 0 ? void 0 : _a.speaks) || this.closed) {
150
128
  this.device.speak(text, language, onEnd, voice, onPiece);
@@ -155,32 +133,30 @@ export class RealtimeVoice {
155
133
  onEnd();
156
134
  return;
157
135
  }
158
- // The service reads it whole: its captions are the whole answer, as it is read.
159
- onPiece === null || onPiece === void 0 ? void 0 : onPiece([words], 0);
160
136
  // Says are counted on both sides alike: the audio of this one may come before the call answers.
161
137
  const say = ++this.says;
162
- this.reading = { say, onEnd, said: false };
138
+ const reading = { say, onEnd, said: false };
139
+ // Its captions follow its sound, a sentence as it is heard (VoiceReading); without a clock, the whole answer at once.
140
+ reading.clock = (_c = this.clockOf(reading, Voice.sentences(words), onPiece)) !== null && _c !== void 0 ? _c : void (onPiece === null || onPiece === void 0 ? void 0 : onPiece([words], 0));
141
+ this.reading = reading;
163
142
  this.playAt = 0;
164
143
  // Suspended while the page had no tap since it opened the voice: a tap since lets it play.
165
144
  void ((_b = this.context) === null || _b === void 0 ? void 0 : _b.resume().catch(() => undefined));
166
145
  this.host.voice.sayVoice(this.session.voiceId, words).catch(() => this.finishReading(say));
167
146
  }
168
147
  hush() {
148
+ var _a;
169
149
  this.device.hush();
170
150
  this.clearDoubt();
151
+ this.quietUntil = 0;
171
152
  const reading = this.reading;
172
153
  this.reading = undefined;
173
- for (const node of this.playing) {
174
- node.onended = null;
175
- try {
176
- node.stop();
177
- }
178
- catch (_a) {
179
- // Ended already.
180
- }
154
+ this.stopPlaying();
155
+ if (this.talking) {
156
+ // What it says now goes, and what comes of it late is not played.
157
+ 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);
181
158
  }
182
- this.playing.clear();
183
- if (reading && this.session && !this.closed) {
159
+ if ((reading || this.talking) && this.session && !this.closed) {
184
160
  void this.host.voice.hushVoice(this.session.voiceId).catch(() => undefined);
185
161
  }
186
162
  }
@@ -191,9 +167,8 @@ export class RealtimeVoice {
191
167
  stop() {
192
168
  var _a, _b, _c, _d;
193
169
  var _e;
194
- if (this.stopped) {
170
+ if (this.stopped)
195
171
  return;
196
- }
197
172
  const gone = this.closed;
198
173
  this.stopped = true;
199
174
  this.closed = true;
@@ -216,7 +191,8 @@ export class RealtimeVoice {
216
191
  }
217
192
  /** Sound of the microphone: sent while Ta listens or reads, in pieces of CHUNK_MS. */
218
193
  captured(samples) {
219
- if (this.closed || !this.session || !this.context || (!this.hearing && !this.reading)) {
194
+ const sending = this.talking ? !this.talking.muted : !!(this.hearing || this.reading);
195
+ if (this.closed || !this.session || !this.context || !sending) {
220
196
  this.buffered = [];
221
197
  this.bufferedLength = 0;
222
198
  return;
@@ -236,7 +212,22 @@ export class RealtimeVoice {
236
212
  this.buffered = [];
237
213
  this.bufferedLength = 0;
238
214
  const pcm = PcmUtil.toPcm16(all, this.context.sampleRate, this.session.inputRate);
239
- void this.host.voice.sendVoice(this.session.voiceId, PcmUtil.base64(pcm)).catch(() => undefined);
215
+ // Louder than the floor of the room: what may be speech goes as it is, the rest as silence (NoiseGate).
216
+ const level = PcmUtil.rms(all);
217
+ const loud = level >= Math.max(GATE_LEVEL, this.sense.floor * GATE_ABOVE) || (level >= GATE_LEVEL && MicSense.voicing(all, this.context.sampleRate) >= 0.5);
218
+ const heard = this.mic.take(pcm, loud, !!this.talking && this.gated);
219
+ if (heard) {
220
+ this.send(heard);
221
+ }
222
+ }
223
+ send(pcm) {
224
+ if (this.session && !this.closed) {
225
+ void this.host.voice.sendVoice(this.session.voiceId, PcmUtil.base64(pcm)).catch(() => undefined);
226
+ }
227
+ }
228
+ /** Of a voice that thinks: its answer plays, or just did; the microphone is held (MicFilter). */
229
+ get gated() {
230
+ return !!this.reading || this.clock < this.quietUntil;
240
231
  }
241
232
  take(event) {
242
233
  var _a, _b, _c;
@@ -244,6 +235,10 @@ export class RealtimeVoice {
244
235
  if (!this.session || event.voiceId !== this.session.voiceId || this.closed) {
245
236
  return;
246
237
  }
238
+ if (this.talking && event.type !== 'closed') {
239
+ this.thought(this.talking, event);
240
+ return;
241
+ }
247
242
  switch (event.type) {
248
243
  case 'speech':
249
244
  // A sound while Ta reads: it may be the user cutting in, or a noise of theirs; the reading goes on
@@ -259,8 +254,8 @@ export class RealtimeVoice {
259
254
  case 'text': {
260
255
  // Words, not a breath nor the "嗯" of someone listening, cut in; not those of Ta's own voice heard back,
261
256
  // when all the sound was no louder than it.
262
- const echo = ((_a = this.doubt) === null || _a === void 0 ? void 0 : _a.echoed) && !this.doubt.voiced;
263
- if (this.doubt && !echo && TurnEnd.words(event.text) >= this.barge.words) {
257
+ // Only once some of the sound was voiced speech louder than Ta's echo: not a cough heard as a word.
258
+ if (((_a = this.doubt) === null || _a === void 0 ? void 0 : _a.voiced) && TurnEnd.words(event.text) >= this.barge.words) {
264
259
  this.bargeIn();
265
260
  }
266
261
  const hearing = this.hearing;
@@ -288,12 +283,12 @@ export class RealtimeVoice {
288
283
  }
289
284
  case 'audio':
290
285
  if (((_b = this.reading) === null || _b === void 0 ? void 0 : _b.say) === event.say) {
291
- this.play(PcmUtil.toFloat(PcmUtil.bytes(event.data)));
286
+ this.heard(event.say, event.data);
292
287
  }
293
288
  return;
294
289
  case 'said':
295
290
  if (((_c = this.reading) === null || _c === void 0 ? void 0 : _c.say) === event.say) {
296
- this.reading.said = true;
291
+ this.allCame(this.reading);
297
292
  if (!this.playing.size) {
298
293
  this.finishReading(event.say);
299
294
  }
@@ -304,18 +299,66 @@ export class RealtimeVoice {
304
299
  return;
305
300
  }
306
301
  }
307
- /** The service is gone: the listen and the reading going on end, the listen with `error`. */
308
- lose(error) {
309
- if (this.closed) {
310
- return;
302
+ /**
303
+ * An event of a voice that thinks: the user speaking stops its answer (the service stopped it too), its answers
304
+ * play as they come, each a say of its own, and the call is told.
305
+ */
306
+ thought(talking, event) {
307
+ var _a, _b, _c, _d;
308
+ var _e;
309
+ const { talk } = talking;
310
+ switch (event.type) {
311
+ case 'speech':
312
+ 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);
313
+ this.silence();
314
+ talk.cut();
315
+ return;
316
+ case 'text':
317
+ talk.heard(event.text, event.final);
318
+ return;
319
+ case 'reply':
320
+ if (event.say > talking.cut) {
321
+ talk.replying(event.text, !!this.context);
322
+ Talking.reply(talking, event.say, event.text, (_b = this.reading) === null || _b === void 0 ? void 0 : _b.clock);
323
+ }
324
+ return;
325
+ case 'audio':
326
+ if (event.say <= talking.cut) {
327
+ return;
328
+ }
329
+ this.says = Math.max(this.says, event.say);
330
+ if (((_c = this.reading) === null || _c === void 0 ? void 0 : _c.say) !== event.say) {
331
+ this.silence();
332
+ this.playAt = 0;
333
+ this.reading = { say: event.say, said: false, onEnd: () => talk.replied(false) };
334
+ this.reading.clock = this.clockOf(this.reading, [...Talking.pieces(talking, event.say)], (pieces, at) => { var _a; return (_a = talk.reading) === null || _a === void 0 ? void 0 : _a.call(talk, pieces, at); });
335
+ }
336
+ this.heard(event.say, event.data);
337
+ return;
338
+ case 'said':
339
+ if (((_d = this.reading) === null || _d === void 0 ? void 0 : _d.say) === event.say) {
340
+ const reading = this.reading;
341
+ if (event.end) {
342
+ reading.onEnd = () => talk.replied(true);
343
+ }
344
+ this.allCame(reading);
345
+ if (!this.playing.size) {
346
+ this.finishReading(event.say);
347
+ }
348
+ }
349
+ else if (event.end) {
350
+ // It hung up with nothing said.
351
+ talk.replied(true);
352
+ }
353
+ return;
311
354
  }
312
- this.closed = true;
313
- this.clearDoubt();
314
- const hearing = this.hearing;
315
- this.endHearing();
316
- hearing === null || hearing === void 0 ? void 0 : hearing.onEnd(error);
317
- const reading = this.reading;
355
+ }
356
+ /** What plays now stops, here only: the service stopped it, or will drop it. */
357
+ silence() {
318
358
  this.reading = undefined;
359
+ this.stopPlaying();
360
+ }
361
+ stopPlaying() {
319
362
  for (const node of this.playing) {
320
363
  node.onended = null;
321
364
  try {
@@ -326,10 +369,28 @@ export class RealtimeVoice {
326
369
  }
327
370
  }
328
371
  this.playing.clear();
372
+ }
373
+ /** The service is gone: the listen and the reading going on end, the listen with `error`. */
374
+ lose(error) {
375
+ if (this.closed)
376
+ return;
377
+ this.closed = true;
378
+ this.clearDoubt();
379
+ const hearing = this.hearing;
380
+ this.endHearing();
381
+ hearing === null || hearing === void 0 ? void 0 : hearing.onEnd(error);
382
+ const reading = this.reading;
383
+ this.reading = undefined;
384
+ this.stopPlaying();
385
+ if (this.talking) {
386
+ this.talking.talk.lost(error);
387
+ return;
388
+ }
329
389
  reading === null || reading === void 0 ? void 0 : reading.onEnd();
330
390
  }
331
391
  play(samples) {
332
392
  var _a;
393
+ var _b;
333
394
  const context = this.context;
334
395
  const reading = this.reading;
335
396
  if (!context || !reading || !samples.length || !this.session) {
@@ -339,10 +400,13 @@ export class RealtimeVoice {
339
400
  buffer.copyToChannel(samples, 0);
340
401
  const node = context.createBufferSource();
341
402
  node.buffer = buffer;
342
- node.connect((_a = this.gain) !== null && _a !== void 0 ? _a : context.destination);
343
- const at = Math.max(this.playAt, context.currentTime + 0.05);
403
+ node.connect((_b = this.gain) !== null && _b !== void 0 ? _b : context.destination);
404
+ // 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.
405
+ const soon = context.currentTime + 0.05;
406
+ const at = this.playAt - soon >= this.tap.holdS / 2 && this.playAt > 0 ? this.playAt : soon + this.tap.holdS;
344
407
  node.start(at);
345
408
  this.playAt = at + buffer.duration;
409
+ (_a = reading.clock) === null || _a === void 0 ? void 0 : _a.heard(at, buffer.duration);
346
410
  this.playing.add(node);
347
411
  node.onended = () => {
348
412
  this.playing.delete(node);
@@ -356,6 +420,9 @@ export class RealtimeVoice {
356
420
  if ((reading === null || reading === void 0 ? void 0 : reading.say) === say) {
357
421
  this.reading = undefined;
358
422
  this.clearDoubt();
423
+ if (this.talking) {
424
+ this.quietUntil = this.clock + ECHO_TAIL_MS;
425
+ }
359
426
  reading.onEnd();
360
427
  }
361
428
  }
@@ -388,66 +455,84 @@ export class RealtimeVoice {
388
455
  this.played.fftSize = 2048;
389
456
  this.gain.connect(this.played);
390
457
  }
391
- /** How loud what plays now is (RMS, 0 to 1). */
392
- playedLevel() {
393
- if (!this.played || !this.reading) {
458
+ /** 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. */
459
+ level() {
460
+ var _a;
461
+ if (!this.played || !this.playing.size)
394
462
  return 0;
395
- }
396
- const samples = new Float32Array(this.played.fftSize);
397
- this.played.getFloatTimeDomainData(samples);
398
- return RealtimeVoice.rms(samples);
463
+ (_a = this.samples) !== null && _a !== void 0 ? _a : (this.samples = new Float32Array(this.played.fftSize));
464
+ this.played.getFloatTimeDomainData(this.samples);
465
+ return PcmUtil.rms(this.samples);
466
+ }
467
+ nowReading() {
468
+ var _a;
469
+ return (_a = this.reading) === null || _a === void 0 ? void 0 : _a.clock;
470
+ }
471
+ /** Sound of the reading `say` came: told to who listens (the face of a video call), and played. */
472
+ heard(say, data) {
473
+ var _a;
474
+ const pcm = PcmUtil.bytes(data);
475
+ this.tap.tell(say, pcm, (_a = this.session) === null || _a === void 0 ? void 0 : _a.outputRate);
476
+ this.play(PcmUtil.toFloat(pcm));
477
+ }
478
+ /** All the sound of a reading came: it ends once played, and who listens knows. */
479
+ allCame(reading) {
480
+ var _a, _b;
481
+ reading.said = true;
482
+ (_a = reading.clock) === null || _a === void 0 ? void 0 : _a.said();
483
+ this.tap.tell(reading.say, undefined, (_b = this.session) === null || _b === void 0 ? void 0 : _b.outputRate);
484
+ }
485
+ clockOf(reading, pieces, onPiece) {
486
+ return this.context && new VoiceReading(reading.say, pieces, this.context, this.tap.holdS, () => this.reading === reading, onPiece);
399
487
  }
400
488
  /** A sound began while Ta reads: the reading goes on lower until the sound is known as speech, or not. */
401
489
  suspect() {
402
- if (this.doubt) {
490
+ if (this.doubt)
403
491
  return;
404
- }
405
- this.doubt = { loud: 0, timer: setTimeout(() => this.clearDoubt(), this.barge.waitMs) };
406
- this.loudness(this.barge.duck);
492
+ // Not lower yet: only once it is voiced speech a while (weigh), so that a cough or a knock never cuts the voice.
493
+ this.doubt = { loud: 0, quiet: 0, timer: setTimeout(() => this.clearDoubt(), this.barge.waitMs) };
407
494
  }
408
495
  /**
409
496
  * Microphone samples: while in doubt, speech long enough is the user cutting in; else, while no one speaks, they
410
497
  * are the sound around, which speech must be louder than.
411
498
  */
412
499
  measure(samples, rate) {
413
- const level = RealtimeVoice.rms(samples);
500
+ const { level, voiced } = this.sense.measure(samples, rate);
414
501
  const ms = (samples.length / rate) * 1000;
415
502
  this.clock += ms;
416
503
  if (this.hearing && level >= this.speechLevel) {
417
504
  this.voiceAt = this.clock;
418
505
  }
419
- if (this.doubt) {
420
- this.weigh(level, ms);
506
+ // A voice that thinks hears nothing while its answer plays (gated): Ta itself hears the user begin to cut in.
507
+ if (this.talking && this.reading && this.cutsIn && !this.doubt && voiced && level >= this.speechLevel && level >= this.level() * this.barge.echo) {
508
+ this.suspect();
421
509
  }
422
- else if (this.reading || (this.hearing && !this.hearing.speaking)) {
423
- this.noise = this.noise ? this.noise * 0.9 + level * 0.1 : level;
510
+ // A cough, a knock, a cup set down is not voiced, and does not count (MicSense.weigh).
511
+ const echo = (this.reading ? this.level() : 0) * this.barge.echo;
512
+ const weighed = this.doubt && MicSense.weigh(this.doubt, { level, voiced }, ms, this.speechLevel, echo, this.barge);
513
+ if (weighed === 'duck') {
514
+ this.loudness(this.barge.duck);
424
515
  }
425
- }
426
- /** The level that counts as speech: BargeIn.level, or louder than the sound around. */
427
- get speechLevel() {
428
- return Math.max(this.barge.level, Math.min(this.noise, NOISE_CAP) * ABOVE_NOISE);
429
- }
430
- /**
431
- * A piece of the microphone while in doubt: speech long enough is the user cutting in, unless it is no louder than
432
- * Ta's own voice heard back (what plays, times TaBargeIn.echo).
433
- */
434
- weigh(level, ms) {
435
- if (!this.doubt || level < this.speechLevel) {
436
- return;
437
- }
438
- if (level < this.playedLevel() * this.barge.echo) {
439
- this.doubt.echoed = true;
440
- return;
441
- }
442
- this.doubt.voiced = true;
443
- this.doubt.loud += ms;
444
- if (this.doubt.loud >= this.barge.speechMs) {
516
+ else if (weighed === 'cut') {
445
517
  this.bargeIn();
446
518
  }
447
519
  }
520
+ /** The level that counts as speech: BargeIn.level, or louder than the floor of the room. */
521
+ get speechLevel() {
522
+ return Math.max(this.barge.level, Math.min(this.sense.floor, NOISE_CAP) * ABOVE_NOISE);
523
+ }
448
524
  /** The user cut in: the call stops the reading and listens, and this listen hears the sentence begun. */
449
525
  bargeIn() {
450
526
  this.clearDoubt();
527
+ if (this.talking) {
528
+ // Its answer stops, and the service hears the user from the start of their words.
529
+ const held = this.mic.cutIn();
530
+ this.hush();
531
+ this.talking.talk.cut();
532
+ for (const pcm of held) {
533
+ this.send(pcm);
534
+ }
535
+ }
451
536
  for (const listener of this.speechListeners) {
452
537
  listener();
453
538
  }
@@ -465,15 +550,9 @@ export class RealtimeVoice {
465
550
  }
466
551
  loudness(value) {
467
552
  if (this.gain && this.context) {
468
- this.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.05);
469
- }
470
- }
471
- static rms(samples) {
472
- let sum = 0;
473
- for (const sample of samples) {
474
- sum += sample * sample;
553
+ // Gently: lower over about a third of a second, never at once.
554
+ this.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.1);
475
555
  }
476
- return Math.sqrt(sum / (samples.length || 1));
477
556
  }
478
557
  }
479
558
  //# sourceMappingURL=realtime-voice.js.map
@@ -0,0 +1,27 @@
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
+ }
@@ -0,0 +1,49 @@
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 class SpokenTimeline {
9
+ constructor(pieces,
10
+ /** How many characters a second the voice reads, about. */
11
+ pace) {
12
+ this.pieces = pieces;
13
+ this.pace = pace;
14
+ /** Seconds of sound that came so far. */
15
+ this.received = 0;
16
+ /** All of it came. */
17
+ this.said = false;
18
+ /** When each sentence asked for begins, in seconds of the reading: the first at 0. */
19
+ this.starts = [0];
20
+ let sum = 0;
21
+ this.before = pieces.map(piece => {
22
+ const at = sum;
23
+ sum += piece.length;
24
+ return at;
25
+ });
26
+ this.chars = Math.max(1, sum);
27
+ }
28
+ /** The sentence heard `seconds` into the reading; what was asked once stays. */
29
+ at(seconds) {
30
+ const total = this.said ? this.received : Math.max(this.received, this.chars / this.pace);
31
+ while (this.starts.length < this.pieces.length) {
32
+ const next = Math.max(this.starts[this.starts.length - 1], (total * this.before[this.starts.length]) / this.chars);
33
+ if (next > seconds) {
34
+ break;
35
+ }
36
+ this.starts.push(next);
37
+ }
38
+ let index = this.starts.length - 1;
39
+ while (index > 0 && this.starts[index] > seconds) {
40
+ index--;
41
+ }
42
+ return index;
43
+ }
44
+ /** Characters a second a voice reads in a language, about: Chinese and Japanese by characters, others by letters. */
45
+ static pace(text) {
46
+ return /[\u3040-\u30ff\u3400-\u9fff]/.test(text) ? 4.5 : 14;
47
+ }
48
+ }
49
+ //# 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.js';
3
4
  import type { TalkCall } from '../components/voice-talk.js';
@@ -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