@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.
- package/esm/browser/assistant/assistant-role.d.ts +9 -4
- package/esm/browser/assistant/assistant-role.js +17 -5
- package/esm/browser/assistant/assistant-task-util.d.ts +6 -0
- package/esm/browser/assistant/assistant-task-util.js +12 -1
- package/esm/browser/assistant/assistant-view.js +4 -1
- package/esm/browser/assistant/assistant.d.ts +2 -1
- package/esm/browser/assistant/assistant.js +9 -7
- package/esm/browser/assistant/call-conversing.d.ts +45 -0
- package/esm/browser/assistant/call-conversing.js +91 -0
- package/esm/browser/assistant/call-face.d.ts +13 -0
- package/esm/browser/assistant/call-face.js +81 -0
- package/esm/browser/assistant/call-keeper.d.ts +8 -4
- package/esm/browser/assistant/call-keeper.js +32 -11
- package/esm/browser/assistant/call-partnering.d.ts +37 -0
- package/esm/browser/assistant/call-partnering.js +79 -0
- package/esm/browser/assistant/call-scenes.d.ts +25 -0
- package/esm/browser/assistant/call-scenes.js +82 -0
- package/esm/browser/assistant/call-screen.d.ts +3 -0
- package/esm/browser/assistant/call-screen.js +15 -0
- package/esm/browser/assistant/mic-sense.d.ts +31 -0
- package/esm/browser/assistant/mic-sense.js +119 -0
- package/esm/browser/assistant/noise-gate.d.ts +32 -0
- package/esm/browser/assistant/noise-gate.js +66 -0
- package/esm/browser/assistant/pcm-util.d.ts +10 -0
- package/esm/browser/assistant/pcm-util.js +55 -0
- package/esm/browser/assistant/read-aloud.d.ts +2 -1
- package/esm/browser/assistant/realtime-voice-protocol.d.ts +84 -0
- package/esm/browser/assistant/realtime-voice-protocol.js +40 -0
- package/esm/browser/assistant/realtime-voice.d.ts +50 -62
- package/esm/browser/assistant/realtime-voice.js +213 -134
- package/esm/browser/assistant/spoken-timeline.d.ts +27 -0
- package/esm/browser/assistant/spoken-timeline.js +49 -0
- package/esm/browser/assistant/voice-call-bar.d.ts +9 -2
- package/esm/browser/assistant/voice-call-bar.js +81 -31
- package/esm/browser/assistant/voice-call-protocol.d.ts +61 -4
- package/esm/browser/assistant/voice-call.d.ts +16 -23
- package/esm/browser/assistant/voice-call.js +134 -117
- package/esm/browser/assistant/voice-reading.d.ts +83 -0
- package/esm/browser/assistant/voice-reading.js +150 -0
- package/esm/browser/avatar/dino-talk.d.ts +15 -0
- package/esm/browser/avatar/dino-talk.js +34 -0
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/conversation-scroll-util.d.ts +8 -1
- package/esm/browser/components/conversation-scroll-util.js +21 -0
- package/esm/browser/components/conversation-scroll.js +10 -11
- package/esm/browser/components/gallery.js +28 -7
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/image-pull.d.ts +64 -0
- package/esm/browser/components/image-pull.js +202 -0
- package/esm/browser/components/kept-call-bar.js +2 -1
- package/esm/browser/components/lightbox.d.ts +1 -1
- package/esm/browser/components/lightbox.js +57 -2
- package/esm/browser/components/markdown.d.ts +3 -1
- package/esm/browser/components/markdown.js +8 -4
- package/esm/browser/components/partner-row.js +2 -1
- package/esm/browser/components/relay-services.d.ts +9 -3
- package/esm/browser/components/relay-services.js +73 -35
- package/esm/browser/components/session-view.js +4 -2
- package/esm/browser/components/settings-parts.js +2 -0
- package/esm/browser/components/ta-avatar.d.ts +15 -1
- package/esm/browser/components/ta-avatar.js +38 -5
- package/esm/browser/components/voice-services.js +6 -1
- package/esm/browser/extension/web-api-call.d.ts +64 -2
- package/esm/browser/extension/web-api-contributions.d.ts +1 -0
- package/esm/browser/extension/web-api-partners.d.ts +2 -0
- package/esm/browser/extension/web-extension-api.d.ts +6 -6
- package/esm/browser/extension/web-extension-context.js +1 -0
- package/esm/browser/extension/web-extension-protocol.d.ts +3 -1
- package/esm/browser/extension/web-extension-run.d.ts +3 -2
- package/esm/browser/extension/web-extension-run.js +2 -0
- package/esm/browser/i18n/locales.d.ts +24 -5
- package/esm/browser/i18n/messages-ja.js +25 -6
- package/esm/browser/i18n/messages-zh-tw.js +25 -6
- package/esm/browser/i18n/messages.d.ts +23 -4
- package/esm/browser/i18n/messages.js +50 -12
- package/esm/browser/markdown/code-renderers.d.ts +2 -0
- package/esm/browser/markdown/code-renderers.js +2 -0
- package/esm/browser/screen/page-answers.d.ts +2 -1
- package/esm/browser/screen/page-answers.js +7 -4
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/chat-list.d.ts +1 -1
- package/esm/browser/style/chat-list.js +1 -1
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +6 -1
- package/esm/browser/style/device.js +1 -0
- package/esm/browser/style/dialogs.d.ts +1 -1
- package/esm/browser/style/dialogs.js +1 -1
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +135 -57
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +8 -0
- package/esm/browser/style/video-call.d.ts +2 -0
- package/esm/browser/style/video-call.js +52 -0
- package/esm/browser/style.js +2 -0
- package/esm/browser/util/desktop.d.ts +10 -1
- package/esm/browser/util/desktop.js +10 -0
- package/esm/browser/util/image-pull.d.ts +61 -0
- package/esm/browser/util/image-pull.js +88 -0
- package/esm/browser/util/spoken.d.ts +3 -3
- package/esm/browser/util/spoken.js +4 -4
- package/esm/browser/video-call/call-camera.d.ts +59 -0
- package/esm/browser/video-call/call-camera.js +188 -0
- package/esm/browser/video-call/call-window.d.ts +19 -0
- package/esm/browser/video-call/call-window.js +80 -0
- package/esm/browser/video-call/clip-plan.d.ts +47 -0
- package/esm/browser/video-call/clip-plan.js +60 -0
- package/esm/browser/video-call/face-clips.d.ts +33 -0
- package/esm/browser/video-call/face-clips.js +93 -0
- package/esm/browser/video-call/face-files.d.ts +31 -0
- package/esm/browser/video-call/face-files.js +77 -0
- package/esm/browser/video-call/video-call-view.d.ts +19 -0
- package/esm/browser/video-call/video-call-view.js +214 -0
- package/esm/browser/video-call/video-face.d.ts +13 -0
- package/esm/browser/video-call/video-face.js +497 -0
- package/esm/browser/workbench-hosts.d.ts +1 -0
- package/esm/browser/workbench-protocol.d.ts +2 -0
- package/esm/browser/workbench-util.d.ts +5 -0
- package/esm/browser/workbench-util.js +18 -0
- package/esm/browser/workbench.d.ts +6 -0
- package/esm/browser/workbench.js +36 -5
- package/lib/browser/assistant/assistant-role.d.ts +9 -4
- package/lib/browser/assistant/assistant-role.js +17 -5
- package/lib/browser/assistant/assistant-task-util.d.ts +6 -0
- package/lib/browser/assistant/assistant-task-util.js +11 -0
- package/lib/browser/assistant/assistant-view.js +3 -0
- package/lib/browser/assistant/assistant.d.ts +2 -1
- package/lib/browser/assistant/assistant.js +9 -7
- package/lib/browser/assistant/call-conversing.d.ts +46 -0
- package/lib/browser/assistant/call-conversing.js +96 -0
- package/lib/browser/assistant/call-face.d.ts +14 -0
- package/lib/browser/assistant/call-face.js +117 -0
- package/lib/browser/assistant/call-keeper.d.ts +8 -4
- package/lib/browser/assistant/call-keeper.js +32 -11
- package/lib/browser/assistant/call-partnering.d.ts +38 -0
- package/lib/browser/assistant/call-partnering.js +83 -0
- package/lib/browser/assistant/call-scenes.d.ts +26 -0
- package/lib/browser/assistant/call-scenes.js +85 -0
- package/lib/browser/assistant/call-screen.d.ts +3 -0
- package/lib/browser/assistant/call-screen.js +15 -0
- package/lib/browser/assistant/mic-sense.d.ts +32 -0
- package/lib/browser/assistant/mic-sense.js +123 -0
- package/lib/browser/assistant/noise-gate.d.ts +33 -0
- package/lib/browser/assistant/noise-gate.js +71 -0
- package/lib/browser/assistant/pcm-util.d.ts +11 -0
- package/lib/browser/assistant/pcm-util.js +58 -0
- package/lib/browser/assistant/read-aloud.d.ts +2 -1
- package/lib/browser/assistant/realtime-voice-protocol.d.ts +85 -0
- package/lib/browser/assistant/realtime-voice-protocol.js +43 -0
- package/lib/browser/assistant/realtime-voice.d.ts +50 -62
- package/lib/browser/assistant/realtime-voice.js +217 -138
- package/lib/browser/assistant/spoken-timeline.d.ts +28 -0
- package/lib/browser/assistant/spoken-timeline.js +53 -0
- package/lib/browser/assistant/voice-call-bar.d.ts +9 -2
- package/lib/browser/assistant/voice-call-bar.js +81 -30
- package/lib/browser/assistant/voice-call-protocol.d.ts +61 -4
- package/lib/browser/assistant/voice-call.d.ts +16 -23
- package/lib/browser/assistant/voice-call.js +134 -117
- package/lib/browser/assistant/voice-reading.d.ts +84 -0
- package/lib/browser/assistant/voice-reading.js +156 -0
- package/lib/browser/avatar/dino-talk.d.ts +16 -0
- package/lib/browser/avatar/dino-talk.js +37 -0
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/conversation-scroll-util.d.ts +8 -1
- package/lib/browser/components/conversation-scroll-util.js +21 -0
- package/lib/browser/components/conversation-scroll.js +10 -11
- package/lib/browser/components/gallery.js +28 -7
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/image-pull.d.ts +65 -0
- package/lib/browser/components/image-pull.js +206 -0
- package/lib/browser/components/kept-call-bar.js +2 -1
- package/lib/browser/components/lightbox.d.ts +1 -1
- package/lib/browser/components/lightbox.js +57 -2
- package/lib/browser/components/markdown.d.ts +3 -1
- package/lib/browser/components/markdown.js +7 -3
- package/lib/browser/components/partner-row.js +2 -1
- package/lib/browser/components/relay-services.d.ts +9 -3
- package/lib/browser/components/relay-services.js +71 -33
- package/lib/browser/components/session-view.js +3 -1
- package/lib/browser/components/settings-parts.js +2 -0
- package/lib/browser/components/ta-avatar.d.ts +15 -1
- package/lib/browser/components/ta-avatar.js +38 -5
- package/lib/browser/components/voice-services.js +5 -0
- package/lib/browser/extension/web-api-call.d.ts +64 -2
- package/lib/browser/extension/web-api-contributions.d.ts +1 -0
- package/lib/browser/extension/web-api-partners.d.ts +2 -0
- package/lib/browser/extension/web-extension-api.d.ts +6 -6
- package/lib/browser/extension/web-extension-context.js +1 -0
- package/lib/browser/extension/web-extension-protocol.d.ts +3 -1
- package/lib/browser/extension/web-extension-run.d.ts +3 -2
- package/lib/browser/extension/web-extension-run.js +2 -0
- package/lib/browser/i18n/locales.d.ts +24 -5
- package/lib/browser/i18n/messages-ja.js +25 -6
- package/lib/browser/i18n/messages-zh-tw.js +25 -6
- package/lib/browser/i18n/messages.d.ts +23 -4
- package/lib/browser/i18n/messages.js +50 -12
- package/lib/browser/markdown/code-renderers.d.ts +2 -0
- package/lib/browser/markdown/code-renderers.js +3 -1
- package/lib/browser/screen/page-answers.d.ts +2 -1
- package/lib/browser/screen/page-answers.js +7 -4
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/chat-list.d.ts +1 -1
- package/lib/browser/style/chat-list.js +1 -1
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +6 -1
- package/lib/browser/style/device.js +1 -0
- package/lib/browser/style/dialogs.d.ts +1 -1
- package/lib/browser/style/dialogs.js +1 -1
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +135 -57
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +8 -0
- package/lib/browser/style/video-call.d.ts +3 -0
- package/lib/browser/style/video-call.js +55 -0
- package/lib/browser/style.js +2 -0
- package/lib/browser/util/desktop.d.ts +10 -1
- package/lib/browser/util/desktop.js +10 -0
- package/lib/browser/util/image-pull.d.ts +62 -0
- package/lib/browser/util/image-pull.js +91 -0
- package/lib/browser/util/spoken.d.ts +3 -3
- package/lib/browser/util/spoken.js +4 -4
- package/lib/browser/video-call/call-camera.d.ts +60 -0
- package/lib/browser/video-call/call-camera.js +192 -0
- package/lib/browser/video-call/call-window.d.ts +20 -0
- package/lib/browser/video-call/call-window.js +83 -0
- package/lib/browser/video-call/clip-plan.d.ts +48 -0
- package/lib/browser/video-call/clip-plan.js +64 -0
- package/lib/browser/video-call/face-clips.d.ts +34 -0
- package/lib/browser/video-call/face-clips.js +96 -0
- package/lib/browser/video-call/face-files.d.ts +32 -0
- package/lib/browser/video-call/face-files.js +82 -0
- package/lib/browser/video-call/video-call-view.d.ts +20 -0
- package/lib/browser/video-call/video-call-view.js +250 -0
- package/lib/browser/video-call/video-face.d.ts +14 -0
- package/lib/browser/video-call/video-face.js +533 -0
- package/lib/browser/workbench-hosts.d.ts +1 -0
- package/lib/browser/workbench-protocol.d.ts +2 -0
- package/lib/browser/workbench-util.d.ts +5 -0
- package/lib/browser/workbench-util.js +18 -0
- package/lib/browser/workbench.d.ts +6 -0
- package/lib/browser/workbench.js +35 -4
- package/package.json +7 -7
- package/public/faces/README.md +27 -0
- package/public/faces/clap.mp4 +0 -0
- package/public/faces/dance.mp4 +0 -0
- package/public/faces/happy.mp4 +0 -0
- package/public/faces/heart.mp4 +0 -0
- package/public/faces/idle-1.mp4 +0 -0
- package/public/faces/idle-2.mp4 +0 -0
- package/public/faces/idle-3.mp4 +0 -0
- package/public/faces/laugh.mp4 +0 -0
- package/public/faces/lips.json +1 -0
- package/public/faces/listening.mp4 +0 -0
- package/public/faces/poster.jpg +0 -0
- package/public/faces/shy.mp4 +0 -0
- package/public/faces/sorry.mp4 +0 -0
- package/public/faces/stretch.mp4 +0 -0
- package/public/faces/surprised.mp4 +0 -0
- package/public/faces/talk-1.mp4 +0 -0
- package/public/faces/talk-2.mp4 +0 -0
- package/public/faces/think-2.mp4 +0 -0
- package/public/faces/thinking.mp4 +0 -0
- package/public/faces/wave.mp4 +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { useInject } from '@celljs/react';
|
|
2
|
-
import { Captions, CaptionsOff, Pause, Phone, PhoneOff } from 'lucide-react';
|
|
2
|
+
import { Captions, CaptionsOff, Pause, Phone, PhoneOff, Video } from 'lucide-react';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Icon } from '../components/icon.js';
|
|
5
5
|
import { useSettings, useWebExtensions, useWorkbench } from '../hooks.js';
|
|
6
6
|
import { useT } from '../i18n/use-t.js';
|
|
7
7
|
import { ScreenUtil } from '../screen/screen-protocol.js';
|
|
8
8
|
import { SpokenReply } from '../util/spoken.js';
|
|
9
|
+
import { CallCameras } from '../video-call/call-camera.js';
|
|
10
|
+
import { CallWindow } from '../video-call/call-window.js';
|
|
9
11
|
import { TaCallKeeper } from './call-keeper.js';
|
|
12
|
+
import { CallScenes } from './call-scenes.js';
|
|
10
13
|
import { CallScreen } from './call-screen.js';
|
|
11
14
|
import { RealtimeVoice } from './realtime-voice.js';
|
|
12
15
|
import { VoiceCall } from './voice-call.js';
|
|
@@ -49,30 +52,49 @@ export function useVoiceCall(options, target, title) {
|
|
|
49
52
|
function made() {
|
|
50
53
|
const latest = { current: options };
|
|
51
54
|
const partnering = { current: { callPartner, target } };
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
55
|
+
const call = new VoiceCall({
|
|
56
|
+
language: () => latest.current.language(),
|
|
57
|
+
voice: () => latest.current.voice(),
|
|
58
|
+
// What the user says goes with the note that asks for what to say back (SpokenReply), and what is new of the call.
|
|
59
|
+
send: text => latest.current.send(SpokenReply.asked(text, CallScenes.next(call, bench.pages.device))),
|
|
60
|
+
ended: (reason, detail) => { var _a, _b; return (_b = (_a = latest.current).ended) === null || _b === void 0 ? void 0 : _b.call(_a, reason, detail); },
|
|
61
|
+
openVoice: async (opening) => {
|
|
62
|
+
var _a;
|
|
63
|
+
await online();
|
|
64
|
+
// A Ta of before, or one let in who may not see the settings: the voice of the device.
|
|
65
|
+
const voices = await bench.voice.listVoices().catch(() => undefined);
|
|
66
|
+
if (!(voices === null || voices === void 0 ? void 0 : voices.use)) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
// The service's own model answers with the brain of the partner opened for it (docs/design/ta-voice.md 8).
|
|
70
|
+
const brain = CallPartnerUtil.voiced(voices) ? (_a = (await opening)) === null || _a === void 0 ? void 0 : _a.brain : undefined;
|
|
71
|
+
return new RealtimeVoice(bench).open(latest.current.language(), brain ? { brain } : {});
|
|
72
|
+
},
|
|
73
|
+
openPartner: plain => {
|
|
74
|
+
const { callPartner: partner, target: called } = partnering.current;
|
|
75
|
+
return partner && called
|
|
76
|
+
? online().then(async () => {
|
|
77
|
+
const voiced = !plain && CallPartnerUtil.voiced(await bench.voice.listVoices().catch(() => undefined));
|
|
78
|
+
const device = bench.pages.device;
|
|
79
|
+
const scene = CallScenes.of(call, device);
|
|
80
|
+
const target = { ...called, language: latest.current.language(), device, scene, ...(voiced ? { voiced } : {}) };
|
|
81
|
+
return CallPartnerUtil.open(partner, target, text => CallCameras.frame(call, text), changed => CallScenes.watch(call, device, changed));
|
|
82
|
+
})
|
|
83
|
+
: undefined;
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
return { refs: { latest, partnering }, call };
|
|
74
87
|
}
|
|
75
88
|
const state = React.useSyncExternalStore(listener => call.subscribe(listener), () => call.state);
|
|
89
|
+
// The conversation of the call going on took its own id (one loaded again is known by its file first): the keeper knows it by it.
|
|
90
|
+
const targetId = target === null || target === void 0 ? void 0 : target.sessionId;
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
var _a;
|
|
93
|
+
var _b;
|
|
94
|
+
if (targetId && call.state.active) {
|
|
95
|
+
keeper.begin({ sessionId: targetId, double: (_a = held.refs.partnering.current.target) === null || _a === void 0 ? void 0 : _a.double, title: (_b = named.current) !== null && _b !== void 0 ? _b : '', held });
|
|
96
|
+
}
|
|
97
|
+
}, [targetId, call, held, keeper]);
|
|
76
98
|
React.useEffect(() => {
|
|
77
99
|
// The call going on is the keeper's as it begins: it floats while its conversation is not in front (KeptCallBar).
|
|
78
100
|
const begun = () => {
|
|
@@ -86,11 +108,12 @@ export function useVoiceCall(options, target, title) {
|
|
|
86
108
|
const offBegun = call.subscribe(begun);
|
|
87
109
|
// Its call went on as the page went away (it loaded again, the app restarted): it goes on.
|
|
88
110
|
const { target: called } = held.refs.partnering.current;
|
|
89
|
-
|
|
90
|
-
|
|
111
|
+
const resumed = called && !call.state.active ? keeper.resume(called.sessionId, called.double) : undefined;
|
|
112
|
+
if (resumed) {
|
|
113
|
+
call.start(undefined, { video: resumed.video === true });
|
|
91
114
|
}
|
|
92
115
|
// Another app in front or the screen locked: the device stops listening and reading, so the call waits.
|
|
93
|
-
const shown = () => (
|
|
116
|
+
const shown = () => (CallWindow.hidden() ? call.pause() : call.resume());
|
|
94
117
|
document.addEventListener('visibilitychange', shown);
|
|
95
118
|
window.addEventListener('pagehide', shown);
|
|
96
119
|
return () => {
|
|
@@ -126,36 +149,52 @@ export function talkCall(call) {
|
|
|
126
149
|
}
|
|
127
150
|
export var CallPartnerUtil;
|
|
128
151
|
(function (CallPartnerUtil) {
|
|
152
|
+
/** Calls are answered by the voice service's own model: the user chose it, and the service in use thinks. */
|
|
153
|
+
function voiced(voices) {
|
|
154
|
+
var _a;
|
|
155
|
+
const service = (voices === null || voices === void 0 ? void 0 : voices.use) ? voices.services.find(each => each.id === voices.use) : undefined;
|
|
156
|
+
return (voices === null || voices === void 0 ? void 0 : voices.brain) === 'service' && !!service && !!((_a = voices.types.find(type => type.type === service.type)) === null || _a === void 0 ? void 0 : _a.thinks);
|
|
157
|
+
}
|
|
158
|
+
CallPartnerUtil.voiced = voiced;
|
|
129
159
|
/**
|
|
130
160
|
* The side of a call of a partner of an extension, its replies said whole (SpokenReply.whole: they are written for
|
|
131
161
|
* the ear); undefined when it leaves the call to the conversation.
|
|
132
162
|
*/
|
|
133
|
-
async function open(partner, target) {
|
|
163
|
+
async function open(partner, target, look, scenes) {
|
|
134
164
|
const session = await partner.open(target);
|
|
135
165
|
let closed = false;
|
|
166
|
+
// How the call changes (video or voice, the camera, how it shows) goes to the partner as it does.
|
|
167
|
+
const offScenes = (session === null || session === void 0 ? void 0 : session.scene) ? scenes === null || scenes === void 0 ? void 0 : scenes(scene => { var _a; return (_a = session.scene) === null || _a === void 0 ? void 0 : _a.call(session, scene); }) : undefined;
|
|
168
|
+
// In a video call, what the camera sees goes with what the user said, when it changed (CallCameras.frame).
|
|
169
|
+
const seen = (text) => {
|
|
170
|
+
const image = look === null || look === void 0 ? void 0 : look(text);
|
|
171
|
+
return image ? { images: [image] } : {};
|
|
172
|
+
};
|
|
136
173
|
return (session && {
|
|
137
174
|
say: async (text, options) => {
|
|
138
|
-
const reply = await session.say(text, options);
|
|
175
|
+
const reply = await session.say(text, { ...options, ...seen(text) });
|
|
139
176
|
return reply ? SpokenReply.whole(reply) : undefined;
|
|
140
177
|
},
|
|
141
|
-
...(session.draft ? { draft: (text) => CallPartnerUtil.draft(session, text) } : {}),
|
|
178
|
+
...(session.draft ? { draft: (text) => CallPartnerUtil.draft(session, text, seen(text)) } : {}),
|
|
142
179
|
news: listener => {
|
|
143
180
|
if (session.next) {
|
|
144
181
|
void CallPartnerUtil.follow(session.next.bind(session), () => closed, text => listener(SpokenReply.whole(text)));
|
|
145
182
|
}
|
|
146
183
|
},
|
|
147
184
|
ending: () => { var _a; return ((_a = session.ending) === null || _a === void 0 ? void 0 : _a.call(session)) === true; },
|
|
185
|
+
...(session.brain ? { brain: session.brain } : {}),
|
|
148
186
|
close: () => {
|
|
149
187
|
closed = true;
|
|
188
|
+
offScenes === null || offScenes === void 0 ? void 0 : offScenes();
|
|
150
189
|
session.close();
|
|
151
190
|
},
|
|
152
191
|
});
|
|
153
192
|
}
|
|
154
193
|
CallPartnerUtil.open = open;
|
|
155
194
|
/** An answer begun by the partner before the user was known to be done, its reply said whole. */
|
|
156
|
-
function draft(session, text) {
|
|
195
|
+
function draft(session, text, options) {
|
|
157
196
|
var _a;
|
|
158
|
-
const begun = (_a = session.draft) === null || _a === void 0 ? void 0 : _a.call(session, text);
|
|
197
|
+
const begun = (_a = session.draft) === null || _a === void 0 ? void 0 : _a.call(session, text, options);
|
|
159
198
|
return {
|
|
160
199
|
reply: begun ? begun.reply.then(reply => (reply ? SpokenReply.whole(reply) : undefined)) : Promise.reject(new Error('No drafts.')),
|
|
161
200
|
keep: () => begun === null || begun === void 0 ? void 0 : begun.keep(),
|
|
@@ -242,6 +281,17 @@ export function callAction(state, call, t) {
|
|
|
242
281
|
run: () => call.start(),
|
|
243
282
|
};
|
|
244
283
|
}
|
|
284
|
+
/** 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). */
|
|
285
|
+
export function videoCallAction(state, call, t) {
|
|
286
|
+
return {
|
|
287
|
+
key: 'videoCall',
|
|
288
|
+
label: t('ta.call.video'),
|
|
289
|
+
title: t('ta.call.videoTitle'),
|
|
290
|
+
icon: React.createElement(Icon, { icon: Video, size: 16 }),
|
|
291
|
+
disabled: state.active,
|
|
292
|
+
run: () => call.start(undefined, { video: true }),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
245
295
|
/**
|
|
246
296
|
* A caption in the one line of the bar of a call, as a ticker: what the user says keeps its newest words in sight as
|
|
247
297
|
* it grows (`follow`); a sentence Ta reads shows from its start and scrolls on to its end, about as fast as it is read
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TaVoiceBrainRef } from '@celljs/ta-protocol';
|
|
1
2
|
import type { Voice } from '../util/voice.js';
|
|
2
3
|
import type { CallTurnTimes } from './call-turn-end.js';
|
|
3
4
|
/** Where a call is: Ta listens to the user, works on what they said, or says its answer. */
|
|
@@ -20,6 +21,10 @@ export interface CallState {
|
|
|
20
21
|
partnered?: boolean;
|
|
21
22
|
/** Its voice hears the user cut in while Ta speaks: no need to tap. */
|
|
22
23
|
bargeIn?: boolean;
|
|
24
|
+
/** A video call: Ta shows as a person who speaks (docs/design/ta-call.md 12), and sees the user once they turn their camera on. */
|
|
25
|
+
video?: boolean;
|
|
26
|
+
/** When the call began (ms since the epoch). */
|
|
27
|
+
since?: number;
|
|
23
28
|
}
|
|
24
29
|
/** What a call uses of the page's voice: Voice by default, a service of voices.json (RealtimeVoice), a fake in tests. */
|
|
25
30
|
export interface CallVoice {
|
|
@@ -32,6 +37,50 @@ export interface CallVoice {
|
|
|
32
37
|
readonly cutsIn?: boolean;
|
|
33
38
|
/** The call ended: it lets go of what it holds (the microphone, the service). */
|
|
34
39
|
stop?(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Its own model answers (a voice service that thinks, docs/design/ta-voice.md 8): it hears, thinks and speaks by
|
|
42
|
+
* itself, and the call only shows what goes on (converse); it neither listens nor speaks by turns.
|
|
43
|
+
*/
|
|
44
|
+
readonly thinks?: boolean;
|
|
45
|
+
/** Of one that thinks: what goes on in the call is told `talk`. */
|
|
46
|
+
converse?(talk: CallTalk): void;
|
|
47
|
+
/** Of one that thinks: the microphone goes quiet (the page hidden), or on again. */
|
|
48
|
+
mute?(muted: boolean): void;
|
|
49
|
+
/** How loud what it plays now is (RMS, 0 to 1), for the face of the call to speak by; one without cannot tell. */
|
|
50
|
+
level?(): number;
|
|
51
|
+
/** Of a voice that plays what a service reads: what it reads now, on the clock of its sound (CallReading). */
|
|
52
|
+
nowReading?(): CallReading | undefined;
|
|
53
|
+
/** The sound of what it reads as it comes, PCM16 mono at `rate`; `pcm` undefined once all of it came. */
|
|
54
|
+
onSound?(listener: (say: number, pcm: Uint8Array | undefined, rate: number) => void): () => void;
|
|
55
|
+
/** Each reading plays `ms` after its sound began to come: what is drawn with it has the time to be ready. */
|
|
56
|
+
hold?(ms: number): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* What a voice reads now (CallVoice.reading), on the clock of its sound: the captions, the clip of the person of a
|
|
60
|
+
* video call and the frames of her mouth all follow it (docs/design/ta-call.md 12).
|
|
61
|
+
*/
|
|
62
|
+
export interface CallReading {
|
|
63
|
+
say: number;
|
|
64
|
+
pieces: readonly string[];
|
|
65
|
+
/** Where it is, in seconds of its sound; negative before it plays (held). */
|
|
66
|
+
now(): number;
|
|
67
|
+
/** The sentence heard at that second of it, the same for every one who asks (SpokenTimeline). */
|
|
68
|
+
pieceAt(seconds: number): number;
|
|
69
|
+
}
|
|
70
|
+
/** What goes on in a call a voice that thinks answers (CallVoice.converse). */
|
|
71
|
+
export interface CallTalk {
|
|
72
|
+
/** What the user says so far; `final` once they are done with it. */
|
|
73
|
+
heard(text: string, final: boolean): void;
|
|
74
|
+
/** Its answer so far, as it says it; `paced`: its sentences show as they are heard (reading), not all at once. */
|
|
75
|
+
replying(text: string, paced?: boolean): void;
|
|
76
|
+
/** The sentence of its answer heard now, as its sound plays. */
|
|
77
|
+
reading?(pieces: string[], at: number): void;
|
|
78
|
+
/** It said all of its answer; `end`: it hung up. */
|
|
79
|
+
replied(end: boolean): void;
|
|
80
|
+
/** The user began to speak: what it said stops. */
|
|
81
|
+
cut(): void;
|
|
82
|
+
/** The service is gone (ta serve restarted, the connection dropped). */
|
|
83
|
+
lost(error: string): void;
|
|
35
84
|
}
|
|
36
85
|
/**
|
|
37
86
|
* Who answers in a call in place of the conversation itself: a front that only talks, handing the work to the
|
|
@@ -51,6 +100,8 @@ export interface CallPartner {
|
|
|
51
100
|
draft?(text: string): CallDraft;
|
|
52
101
|
/** Whether it ended the call (WebCallSession.ending): Ta hangs up once its reply is said. */
|
|
53
102
|
ending?(): boolean;
|
|
103
|
+
/** Of a call the voice service answers: the brain its voice opens with (WebCallSession.brain). */
|
|
104
|
+
brain?: TaVoiceBrainRef;
|
|
54
105
|
close(): void;
|
|
55
106
|
}
|
|
56
107
|
/** An answer begun before the user was known to be done (CallPartner.draft). */
|
|
@@ -69,10 +120,16 @@ export interface CallOptions extends CallTurnTimes {
|
|
|
69
120
|
send(text: string): Promise<unknown>;
|
|
70
121
|
/** The call ended by itself: why, for a notice; `detail` what the voice service said. */
|
|
71
122
|
ended?(reason: CallEnd, detail?: string): void;
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
123
|
+
/**
|
|
124
|
+
* The voice of a service the call opens as it starts; undefined for that of the device. With the partner opening,
|
|
125
|
+
* a service that thinks may answer with its brain (CallPartner.brain).
|
|
126
|
+
*/
|
|
127
|
+
openVoice?(partner?: Promise<CallPartner | undefined>): Promise<CallVoice | undefined> | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* Who answers in its place, opened as the call starts; undefined (or failing) for the conversation itself. `plain`:
|
|
130
|
+
* one that answers itself, never leaving it to the voice service.
|
|
131
|
+
*/
|
|
132
|
+
openPartner?(plain?: boolean): Promise<CallPartner | undefined> | undefined;
|
|
76
133
|
/** How long nobody may speak before the call ends by itself; default SILENT_MS. */
|
|
77
134
|
silentMs?: number;
|
|
78
135
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Voice } from '../util/voice.js';
|
|
2
|
+
import { CallConversing, CallDrafts } from './call-conversing.js';
|
|
3
|
+
import { CallPartnering } from './call-partnering.js';
|
|
2
4
|
import { CallTurnEnd } from './call-turn-end.js';
|
|
3
|
-
import type {
|
|
5
|
+
import type { CallEnd, CallOptions, CallPartner, CallState, CallVoice } from './voice-call-protocol.js';
|
|
6
|
+
import { CallSounds } from './voice-reading.js';
|
|
4
7
|
import { VoiceReopen } from './voice-reopen.js';
|
|
5
8
|
/**
|
|
6
9
|
* A call with a conversation (the double's, or any other), by the voice of the page: Ta listens until the user pauses, sends what they said, reads
|
|
@@ -33,30 +36,27 @@ export declare class VoiceCall {
|
|
|
33
36
|
protected opening: boolean;
|
|
34
37
|
protected waiting?: string;
|
|
35
38
|
/** Who answers in this call in place of the conversation (CallOptions.openPartner), once open. */
|
|
36
|
-
protected
|
|
39
|
+
protected readonly partners: CallPartnering;
|
|
37
40
|
/** Its voice service opening again (revoice). */
|
|
38
41
|
protected reopening?: VoiceReopen;
|
|
39
|
-
/** The answer begun on what the user said so far (CallPartner.draft)
|
|
40
|
-
protected
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
/** A partner whose draft failed (an older Ta): it answers once the user is done only. */
|
|
45
|
-
protected draftless?: CallPartner;
|
|
42
|
+
/** The answer begun on what the user said so far (CallPartner.draft). */
|
|
43
|
+
protected readonly drafts: CallDrafts;
|
|
44
|
+
/** Of a voice that thinks, which answers by itself. */
|
|
45
|
+
protected readonly conversing: CallConversing;
|
|
46
46
|
constructor(options: CallOptions, device?: CallVoice);
|
|
47
47
|
subscribe(listener: () => void): () => void;
|
|
48
48
|
/**
|
|
49
49
|
* Begins the call: Ta listens. With what the user said as they called (let go over 通话 of a talk), already being
|
|
50
50
|
* sent by the box, Ta waits for its turn and reads the answer instead; should the sending fail, it listens.
|
|
51
|
-
* `direct`: the conversation's voice kept on (let go over 持续说),
|
|
52
|
-
*/
|
|
51
|
+
* `direct`: the conversation's voice kept on (let go over 持续说), no partner; `video`: a video call (CallState.video). */
|
|
53
52
|
start(said?: {
|
|
54
53
|
text: string;
|
|
55
54
|
sent: Promise<unknown>;
|
|
56
|
-
}, { direct }?: {
|
|
55
|
+
}, { direct, video }?: {
|
|
57
56
|
direct?: boolean;
|
|
57
|
+
video?: boolean;
|
|
58
58
|
}): void;
|
|
59
|
-
/** The voice of a service is the call's now: it hears the user cut in. */
|
|
59
|
+
/** The voice of a service is the call's now: it hears the user cut in, or answers by itself (thinks). */
|
|
60
60
|
protected takeVoice(voice: CallVoice): void;
|
|
61
61
|
/** Its voice is there: the answer that came meanwhile is read, a turn at work is waited for, else Ta listens. */
|
|
62
62
|
protected voiced(): void;
|
|
@@ -83,6 +83,9 @@ export declare class VoiceCall {
|
|
|
83
83
|
pause(): void;
|
|
84
84
|
/** The page shows again: the answer that waits is read, a turn at work is waited for, else Ta listens. */
|
|
85
85
|
resume(): void;
|
|
86
|
+
/** For the face of the call (CallSounds): Ta's voice, whichever the call has (it opens after the call shows). */
|
|
87
|
+
readonly sounds: CallSounds;
|
|
88
|
+
readonly level: () => number | undefined;
|
|
86
89
|
/** While Ta speaks (an answer, or news it tells by itself): it stops and listens to the user, before any more news. */
|
|
87
90
|
interrupt(): void;
|
|
88
91
|
/** The run of the turn the call asked has started: its reply is the first after `before`. */
|
|
@@ -130,18 +133,8 @@ export declare class VoiceCall {
|
|
|
130
133
|
* should they be done with these words (take), dropped as they say more (docs/design/ta-call.md 10).
|
|
131
134
|
*/
|
|
132
135
|
protected suspect(text: string): void;
|
|
133
|
-
/** The user was done with the words of the draft: its answer is the reply; failing, the partner is asked as usual. */
|
|
134
|
-
protected kept(draft: CallDraft, said: string): void;
|
|
135
|
-
protected dropDraft(): void;
|
|
136
136
|
/** The voice and the partner the call opens as it starts; undefined when it opens neither. A partner that fails is none. */
|
|
137
137
|
protected open(direct: boolean): Promise<[CallVoice | undefined, CallPartner | undefined]> | undefined;
|
|
138
|
-
/** The partner answers what the user said; its reply is read as a turn's is. */
|
|
139
|
-
protected ask(text: string, sent?: boolean): void;
|
|
140
|
-
/**
|
|
141
|
-
* The partner did not answer (the Ta service restarted, its side of the call is gone): it opens again once and
|
|
142
|
-
* answers what was said; failing that, the conversation answers from then on. The call goes on either way.
|
|
143
|
-
*/
|
|
144
|
-
protected reopen(failed: CallPartner, text: string, sent?: boolean): void;
|
|
145
138
|
/** What the user said did not go: not in the captions as if it had, and Ta listens again. */
|
|
146
139
|
protected unsent(): void;
|
|
147
140
|
protected end(reason: CallEnd, detail?: string): void;
|