@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.
- 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/chat-home.d.ts +6 -4
- package/esm/browser/components/chat-home.js +7 -7
- package/esm/browser/components/chat-icon.js +9 -5
- package/esm/browser/components/chat-list-hooks.d.ts +14 -4
- package/esm/browser/components/chat-list-hooks.js +11 -5
- package/esm/browser/components/chat-list-row.d.ts +7 -4
- package/esm/browser/components/chat-list-row.js +22 -10
- package/esm/browser/components/chat-list.js +6 -11
- 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 +72 -11
- 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/hosts.d.ts +2 -0
- package/esm/browser/hosts.js +22 -3
- 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-hosts.js +8 -4
- package/esm/browser/workbench-lists.d.ts +16 -1
- package/esm/browser/workbench-lists.js +38 -3
- 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/chat-home.d.ts +6 -4
- package/lib/browser/components/chat-home.js +8 -9
- package/lib/browser/components/chat-icon.js +9 -5
- package/lib/browser/components/chat-list-hooks.d.ts +14 -4
- package/lib/browser/components/chat-list-hooks.js +12 -6
- package/lib/browser/components/chat-list-row.d.ts +7 -4
- package/lib/browser/components/chat-list-row.js +23 -12
- package/lib/browser/components/chat-list.js +5 -10
- 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 +72 -11
- 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/hosts.d.ts +2 -0
- package/lib/browser/hosts.js +22 -3
- 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-hosts.js +8 -4
- package/lib/browser/workbench-lists.d.ts +16 -1
- package/lib/browser/workbench-lists.js +38 -3
- 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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MicFilter = exports.NoiseGate = void 0;
|
|
4
|
+
const realtime_voice_protocol_1 = require("./realtime-voice-protocol");
|
|
5
|
+
/**
|
|
6
|
+
* What of the microphone a voice service hears (docs/design/ta-voice.md 9): speech, the sound louder than the room for
|
|
7
|
+
* two pieces at least, with the piece before it (its first sound) and HANG pieces after (the gaps between words); the
|
|
8
|
+
* rest goes as silence, so that the service neither answers a noise nor hears a knock or a cough as the user, and still
|
|
9
|
+
* hears them stop. Each piece waits for the next to be known, one piece of delay.
|
|
10
|
+
*/
|
|
11
|
+
class NoiseGate {
|
|
12
|
+
constructor(hang = 4) {
|
|
13
|
+
this.hang = hang;
|
|
14
|
+
this.wasLoud = false;
|
|
15
|
+
this.index = 0;
|
|
16
|
+
this.lastVoiced = Number.NEGATIVE_INFINITY;
|
|
17
|
+
}
|
|
18
|
+
/** A piece of PCM16, `loud` when louder than the room: the piece before it as it should go, once known. */
|
|
19
|
+
push(pcm, loud) {
|
|
20
|
+
const at = this.index++;
|
|
21
|
+
if (loud && this.wasLoud) {
|
|
22
|
+
this.lastVoiced = at;
|
|
23
|
+
}
|
|
24
|
+
this.wasLoud = loud;
|
|
25
|
+
const pending = this.pending;
|
|
26
|
+
this.pending = pcm;
|
|
27
|
+
if (!pending) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return this.lastVoiced >= at - 1 - this.hang ? pending : new Uint8Array(pending.length);
|
|
31
|
+
}
|
|
32
|
+
/** The user is known to speak now (they cut in): what comes goes as it is, a while. */
|
|
33
|
+
open() {
|
|
34
|
+
this.lastVoiced = this.index;
|
|
35
|
+
}
|
|
36
|
+
/** What was heard is not to go (the service's own answer played): it begins again. */
|
|
37
|
+
reset() {
|
|
38
|
+
this.pending = undefined;
|
|
39
|
+
this.wasLoud = false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.NoiseGate = NoiseGate;
|
|
43
|
+
/**
|
|
44
|
+
* What of the microphone goes to a voice service (docs/design/ta-voice.md 9): speech alone (NoiseGate), and nothing
|
|
45
|
+
* while what plays is its own answer, which it would hear and answer: that is held, and goes only once the user cuts in.
|
|
46
|
+
*/
|
|
47
|
+
class MicFilter {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.held = [];
|
|
50
|
+
this.gate = new NoiseGate();
|
|
51
|
+
}
|
|
52
|
+
/** A piece of the microphone: what to send now. `playing`: its own answer plays, or just did. */
|
|
53
|
+
take(pcm, loud, playing) {
|
|
54
|
+
if (playing) {
|
|
55
|
+
this.held.push(pcm);
|
|
56
|
+
this.held.splice(0, Math.max(0, this.held.length - realtime_voice_protocol_1.HELD_MS / realtime_voice_protocol_1.CHUNK_MS));
|
|
57
|
+
this.gate.reset();
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
// What was held was the room while it played, not the user.
|
|
61
|
+
this.held.length = 0;
|
|
62
|
+
return this.gate.push(pcm, loud);
|
|
63
|
+
}
|
|
64
|
+
/** The user cut in: what was held of them, from the start of their words, to send now; then all they say. */
|
|
65
|
+
cutIn() {
|
|
66
|
+
this.gate.open();
|
|
67
|
+
return this.held.splice(0);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.MicFilter = MicFilter;
|
|
71
|
+
//# sourceMappingURL=noise-gate.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The samples of a microphone, made PCM16 mono at another rate. */
|
|
2
|
+
export declare namespace PcmUtil {
|
|
3
|
+
/** Linear resampling of mono float samples to `to` Hz, as PCM16 little-endian. */
|
|
4
|
+
function toPcm16(samples: Float32Array, from: number, to: number): Uint8Array;
|
|
5
|
+
function toFloat(pcm: Uint8Array): Float32Array;
|
|
6
|
+
function base64(bytes: Uint8Array): string;
|
|
7
|
+
/** How loud samples are (RMS, 0 to 1). */
|
|
8
|
+
function rms(samples: Float32Array): number;
|
|
9
|
+
function bytes(base64: string): Uint8Array;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=pcm-util.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PcmUtil = void 0;
|
|
4
|
+
/** The samples of a microphone, made PCM16 mono at another rate. */
|
|
5
|
+
var PcmUtil;
|
|
6
|
+
(function (PcmUtil) {
|
|
7
|
+
/** Linear resampling of mono float samples to `to` Hz, as PCM16 little-endian. */
|
|
8
|
+
function toPcm16(samples, from, to) {
|
|
9
|
+
const ratio = from / to;
|
|
10
|
+
const length = Math.floor(samples.length / ratio);
|
|
11
|
+
const out = new DataView(new ArrayBuffer(length * 2));
|
|
12
|
+
for (let i = 0; i < length; i++) {
|
|
13
|
+
const at = i * ratio;
|
|
14
|
+
const low = Math.floor(at);
|
|
15
|
+
const high = Math.min(low + 1, samples.length - 1);
|
|
16
|
+
const value = samples[low] + (samples[high] - samples[low]) * (at - low);
|
|
17
|
+
out.setInt16(i * 2, Math.max(-1, Math.min(1, value)) * 0x7fff, true);
|
|
18
|
+
}
|
|
19
|
+
return new Uint8Array(out.buffer);
|
|
20
|
+
}
|
|
21
|
+
PcmUtil.toPcm16 = toPcm16;
|
|
22
|
+
function toFloat(pcm) {
|
|
23
|
+
const view = new DataView(pcm.buffer, pcm.byteOffset, pcm.byteLength);
|
|
24
|
+
const out = new Float32Array(Math.floor(pcm.byteLength / 2));
|
|
25
|
+
for (let i = 0; i < out.length; i++) {
|
|
26
|
+
out[i] = view.getInt16(i * 2, true) / 0x8000;
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
PcmUtil.toFloat = toFloat;
|
|
31
|
+
function base64(bytes) {
|
|
32
|
+
let text = '';
|
|
33
|
+
for (let i = 0; i < bytes.length; i += 0x8000) {
|
|
34
|
+
text += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
|
|
35
|
+
}
|
|
36
|
+
return btoa(text);
|
|
37
|
+
}
|
|
38
|
+
PcmUtil.base64 = base64;
|
|
39
|
+
/** How loud samples are (RMS, 0 to 1). */
|
|
40
|
+
function rms(samples) {
|
|
41
|
+
let sum = 0;
|
|
42
|
+
for (const sample of samples) {
|
|
43
|
+
sum += sample * sample;
|
|
44
|
+
}
|
|
45
|
+
return Math.sqrt(sum / (samples.length || 1));
|
|
46
|
+
}
|
|
47
|
+
PcmUtil.rms = rms;
|
|
48
|
+
function bytes(base64) {
|
|
49
|
+
const text = atob(base64);
|
|
50
|
+
const out = new Uint8Array(text.length);
|
|
51
|
+
for (let i = 0; i < text.length; i++) {
|
|
52
|
+
out[i] = text.charCodeAt(i);
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
PcmUtil.bytes = bytes;
|
|
57
|
+
})(PcmUtil || (exports.PcmUtil = PcmUtil = {}));
|
|
58
|
+
//# sourceMappingURL=pcm-util.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RealtimeVoice
|
|
1
|
+
import { RealtimeVoice } from './realtime-voice';
|
|
2
|
+
import type { RealtimeVoiceHost } from './realtime-voice-protocol';
|
|
2
3
|
import type { CallVoice } from './voice-call-protocol';
|
|
3
4
|
/** How long a voice service opened to read stays open after it read, ready for the next reply. */
|
|
4
5
|
export declare const READ_IDLE_MS = 60000;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { TaVoiceEvent, TaVoiceServer } from '@celljs/ta-protocol';
|
|
2
|
+
import type { CallTalk } from './voice-call-protocol';
|
|
3
|
+
import type { VoiceReading } from './voice-reading';
|
|
4
|
+
/** What a voice of a service uses of the page's connection. */
|
|
5
|
+
export interface RealtimeVoiceHost {
|
|
6
|
+
readonly voice: TaVoiceServer;
|
|
7
|
+
onVoiceEvent(listener: (event: TaVoiceEvent) => void): () => void;
|
|
8
|
+
/**
|
|
9
|
+
* How the connection is: once it is not online, the voice is gone (ta serve closes the voices of a connection with
|
|
10
|
+
* it, and one that restarted has none), though no event of it says so.
|
|
11
|
+
*/
|
|
12
|
+
subscribe?(listener: (state: {
|
|
13
|
+
status: string;
|
|
14
|
+
}) => void): () => void;
|
|
15
|
+
}
|
|
16
|
+
/** How long a listen waits for a sentence before it counts as silence. */
|
|
17
|
+
export declare const REALTIME_SILENCE_MS = 12000;
|
|
18
|
+
/** The audio sent at once, in ms of sound. */
|
|
19
|
+
export declare const CHUNK_MS = 100;
|
|
20
|
+
/**
|
|
21
|
+
* Of a voice that thinks: what the microphone heard this long before the user cut in is sent then, the start of their
|
|
22
|
+
* words; and it sends nothing this long after its answer played, what is left of it in the room.
|
|
23
|
+
*/
|
|
24
|
+
export declare const HELD_MS = 800;
|
|
25
|
+
export declare const ECHO_TAIL_MS = 300;
|
|
26
|
+
/** 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). */
|
|
27
|
+
export declare const ABOVE_NOISE = 2;
|
|
28
|
+
/** The sound around the user counts at most this loud: in a din, the level of BargeIn.level times this is speech. */
|
|
29
|
+
export declare const NOISE_CAP = 0.08;
|
|
30
|
+
/** ms of voiced speech before the reading goes lower: a cough, a knock, a word of someone else does not. */
|
|
31
|
+
export declare const DUCK_MS = 200;
|
|
32
|
+
/** A gap this long in what may be the user cutting in ends its run: coughs apart do not add up. */
|
|
33
|
+
export declare const GAP_MS = 250;
|
|
34
|
+
/** What goes to a voice service is louder than the floor of the room this many times (NoiseGate), and at least GATE_LEVEL. */
|
|
35
|
+
export declare const GATE_ABOVE = 2.5;
|
|
36
|
+
export declare const GATE_LEVEL = 0.004;
|
|
37
|
+
export interface Hearing {
|
|
38
|
+
onText(text: string, final: boolean): void;
|
|
39
|
+
onEnd(error?: string): void;
|
|
40
|
+
timer?: ReturnType<typeof setTimeout>;
|
|
41
|
+
/** The user began a sentence: it does not end as silence. */
|
|
42
|
+
speaking: boolean;
|
|
43
|
+
/** What they said before they paused on a word that leads on: what they say next goes on from it. */
|
|
44
|
+
before?: string;
|
|
45
|
+
}
|
|
46
|
+
/** A sound heard while Ta reads, not yet known to be the user cutting in. */
|
|
47
|
+
export interface Doubt {
|
|
48
|
+
/** ms of voiced speech in it, in a run with gaps shorter than GAP_MS. */
|
|
49
|
+
loud: number;
|
|
50
|
+
/** ms since the last of it was voiced speech: past GAP_MS, the run begins again. */
|
|
51
|
+
quiet: number;
|
|
52
|
+
/** The reading went lower (DUCK_MS of speech). */
|
|
53
|
+
ducked?: boolean;
|
|
54
|
+
timer: ReturnType<typeof setTimeout>;
|
|
55
|
+
/** Some of it was loud as speech, but no louder than Ta's own voice heard back (TaBargeIn.echo). */
|
|
56
|
+
echoed?: boolean;
|
|
57
|
+
/** Some of it was louder than that: the user's. */
|
|
58
|
+
voiced?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface Reading {
|
|
61
|
+
say: number;
|
|
62
|
+
onEnd(): void;
|
|
63
|
+
/** All its audio came: it ends once the last piece played. */
|
|
64
|
+
said: boolean;
|
|
65
|
+
/** Where it is as it plays, its captions and the face of a video call by it (VoiceReading). */
|
|
66
|
+
clock?: VoiceReading;
|
|
67
|
+
}
|
|
68
|
+
/** A call its own model answers (converse): told what goes on; the answers up to `cut` stopped as the user spoke. */
|
|
69
|
+
export interface Talking {
|
|
70
|
+
talk: CallTalk;
|
|
71
|
+
cut: number;
|
|
72
|
+
muted: boolean;
|
|
73
|
+
/** The words of its answer `say` so far, in sentences. */
|
|
74
|
+
reply?: {
|
|
75
|
+
say: number;
|
|
76
|
+
pieces: readonly string[];
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export declare namespace Talking {
|
|
80
|
+
/** Its answer `say` so far: kept for the reading of its sound, which times its sentences by it as they come. */
|
|
81
|
+
function reply(talking: Talking, say: number, text: string, clock: Pick<VoiceReading, 'say' | 'words'> | undefined): void;
|
|
82
|
+
/** The sentences of the answer `say` known as its sound begins; one empty when none yet. */
|
|
83
|
+
function pieces(talking: Talking, say: number): readonly string[];
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=realtime-voice-protocol.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Talking = exports.GATE_LEVEL = exports.GATE_ABOVE = exports.GAP_MS = exports.DUCK_MS = exports.NOISE_CAP = exports.ABOVE_NOISE = exports.ECHO_TAIL_MS = exports.HELD_MS = exports.CHUNK_MS = exports.REALTIME_SILENCE_MS = void 0;
|
|
4
|
+
const voice_1 = require("../util/voice");
|
|
5
|
+
/** How long a listen waits for a sentence before it counts as silence. */
|
|
6
|
+
exports.REALTIME_SILENCE_MS = 12000;
|
|
7
|
+
/** The audio sent at once, in ms of sound. */
|
|
8
|
+
exports.CHUNK_MS = 100;
|
|
9
|
+
/**
|
|
10
|
+
* Of a voice that thinks: what the microphone heard this long before the user cut in is sent then, the start of their
|
|
11
|
+
* words; and it sends nothing this long after its answer played, what is left of it in the room.
|
|
12
|
+
*/
|
|
13
|
+
exports.HELD_MS = 800;
|
|
14
|
+
exports.ECHO_TAIL_MS = 300;
|
|
15
|
+
/** 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). */
|
|
16
|
+
exports.ABOVE_NOISE = 2;
|
|
17
|
+
/** The sound around the user counts at most this loud: in a din, the level of BargeIn.level times this is speech. */
|
|
18
|
+
exports.NOISE_CAP = 0.08;
|
|
19
|
+
/** ms of voiced speech before the reading goes lower: a cough, a knock, a word of someone else does not. */
|
|
20
|
+
exports.DUCK_MS = 200;
|
|
21
|
+
/** A gap this long in what may be the user cutting in ends its run: coughs apart do not add up. */
|
|
22
|
+
exports.GAP_MS = 250;
|
|
23
|
+
/** What goes to a voice service is louder than the floor of the room this many times (NoiseGate), and at least GATE_LEVEL. */
|
|
24
|
+
exports.GATE_ABOVE = 2.5;
|
|
25
|
+
exports.GATE_LEVEL = 0.004;
|
|
26
|
+
var Talking;
|
|
27
|
+
(function (Talking) {
|
|
28
|
+
/** Its answer `say` so far: kept for the reading of its sound, which times its sentences by it as they come. */
|
|
29
|
+
function reply(talking, say, text, clock) {
|
|
30
|
+
talking.reply = { say, pieces: voice_1.Voice.sentences(voice_1.Voice.spoken(text) || text) };
|
|
31
|
+
if ((clock === null || clock === void 0 ? void 0 : clock.say) === say) {
|
|
32
|
+
clock.words(talking.reply.pieces);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
Talking.reply = reply;
|
|
36
|
+
/** The sentences of the answer `say` known as its sound begins; one empty when none yet. */
|
|
37
|
+
function pieces(talking, say) {
|
|
38
|
+
var _a;
|
|
39
|
+
return ((_a = talking.reply) === null || _a === void 0 ? void 0 : _a.say) === say ? talking.reply.pieces : [''];
|
|
40
|
+
}
|
|
41
|
+
Talking.pieces = pieces;
|
|
42
|
+
})(Talking || (exports.Talking = Talking = {}));
|
|
43
|
+
//# sourceMappingURL=realtime-voice-protocol.js.map
|
|
@@ -1,53 +1,10 @@
|
|
|
1
|
-
import { TaBargeIn, type
|
|
1
|
+
import { TaBargeIn, type TaVoiceBrainRef, type TaVoiceEvent, type TaVoiceSession } from '@celljs/ta-protocol';
|
|
2
2
|
import { Voice } from '../util/voice';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* How the connection is: once it is not online, the voice is gone (ta serve closes the voices of a connection with
|
|
10
|
-
* it, and one that restarted has none), though no event of it says so.
|
|
11
|
-
*/
|
|
12
|
-
subscribe?(listener: (state: {
|
|
13
|
-
status: string;
|
|
14
|
-
}) => void): () => void;
|
|
15
|
-
}
|
|
16
|
-
/** How long a listen waits for a sentence before it counts as silence. */
|
|
17
|
-
export declare const REALTIME_SILENCE_MS = 12000;
|
|
18
|
-
/** The samples of a microphone, made PCM16 mono at another rate. */
|
|
19
|
-
export declare namespace PcmUtil {
|
|
20
|
-
/** Linear resampling of mono float samples to `to` Hz, as PCM16 little-endian. */
|
|
21
|
-
function toPcm16(samples: Float32Array, from: number, to: number): Uint8Array;
|
|
22
|
-
function toFloat(pcm: Uint8Array): Float32Array;
|
|
23
|
-
function base64(bytes: Uint8Array): string;
|
|
24
|
-
function bytes(base64: string): Uint8Array;
|
|
25
|
-
}
|
|
26
|
-
interface Hearing {
|
|
27
|
-
onText(text: string, final: boolean): void;
|
|
28
|
-
onEnd(error?: string): void;
|
|
29
|
-
timer?: ReturnType<typeof setTimeout>;
|
|
30
|
-
/** The user began a sentence: it does not end as silence. */
|
|
31
|
-
speaking: boolean;
|
|
32
|
-
/** What they said before they paused on a word that leads on: what they say next goes on from it. */
|
|
33
|
-
before?: string;
|
|
34
|
-
}
|
|
35
|
-
/** A sound heard while Ta reads, not yet known to be the user cutting in. */
|
|
36
|
-
interface Doubt {
|
|
37
|
-
/** ms of it at the level of speech. */
|
|
38
|
-
loud: number;
|
|
39
|
-
timer: ReturnType<typeof setTimeout>;
|
|
40
|
-
/** Some of it was loud as speech, but no louder than Ta's own voice heard back (TaBargeIn.echo). */
|
|
41
|
-
echoed?: boolean;
|
|
42
|
-
/** Some of it was louder than that: the user's. */
|
|
43
|
-
voiced?: boolean;
|
|
44
|
-
}
|
|
45
|
-
interface Reading {
|
|
46
|
-
say: number;
|
|
47
|
-
onEnd(): void;
|
|
48
|
-
/** All its audio came: it ends once the last piece played. */
|
|
49
|
-
said: boolean;
|
|
50
|
-
}
|
|
3
|
+
import { MicSense } from './mic-sense';
|
|
4
|
+
import { MicFilter } from './noise-gate';
|
|
5
|
+
import { type Doubt, type Hearing, type Reading, type RealtimeVoiceHost, Talking } from './realtime-voice-protocol';
|
|
6
|
+
import type { CallReading, CallTalk, CallVoice } from './voice-call-protocol';
|
|
7
|
+
import { VoiceReading, VoiceSoundTap } from './voice-reading';
|
|
51
8
|
/**
|
|
52
9
|
* 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
|
|
53
10
|
* while Ta listens or reads (so the service hears the user cut in), and what the service reads plays here. A service
|
|
@@ -79,16 +36,32 @@ export declare class RealtimeVoice implements CallVoice {
|
|
|
79
36
|
/** stop() let go of the microphone and the service. */
|
|
80
37
|
protected stopped: boolean;
|
|
81
38
|
protected offState?: () => void;
|
|
39
|
+
/** Of a voice that thinks, once the call takes it (converse). */
|
|
40
|
+
protected talking?: Talking;
|
|
41
|
+
/** Of a voice that thinks: nothing is sent until the microphone's clock is here, as its answer dies away. */
|
|
42
|
+
protected quietUntil: number;
|
|
43
|
+
/** What of the microphone the service hears: speech alone, and none of a voice that thinks playing its answer. */
|
|
44
|
+
protected readonly mic: MicFilter;
|
|
45
|
+
/** The sound of what it reads, for the face of a video call, and how long each reading is held for it. */
|
|
46
|
+
protected readonly tap: VoiceSoundTap;
|
|
82
47
|
constructor(host: RealtimeVoiceHost, device?: CallVoice);
|
|
83
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Opens the service and, unless `hear` is false, the microphone; rejects with why one of them is not there. With
|
|
50
|
+
* `brain`, a service that thinks answers by itself (thinks).
|
|
51
|
+
*/
|
|
84
52
|
open(language: string, options?: {
|
|
85
53
|
hear?: boolean;
|
|
54
|
+
brain?: TaVoiceBrainRef;
|
|
86
55
|
}): Promise<this>;
|
|
87
56
|
listen(_language: string, onText: (text: string, final: boolean) => void, onEnd: (error?: string) => void): Voice.Listening | undefined;
|
|
88
57
|
/** It is open: it neither closed by itself nor was stopped. */
|
|
89
58
|
get isOpen(): boolean;
|
|
90
59
|
/** The user's voice stops what it reads, or only a tap does (TaBargeIn.tap). */
|
|
91
60
|
get cutsIn(): boolean;
|
|
61
|
+
/** Its own model answers the call: it hears, thinks and speaks by itself. */
|
|
62
|
+
get thinks(): boolean;
|
|
63
|
+
converse(talk: CallTalk): void;
|
|
64
|
+
mute(muted: boolean): void;
|
|
92
65
|
/** It reads with the voice of the service, not with that of the device. */
|
|
93
66
|
get speaks(): boolean;
|
|
94
67
|
speak(text: string, language: string, onEnd: () => void, voice?: string, onPiece?: (pieces: string[], index: number) => void): void;
|
|
@@ -97,7 +70,20 @@ export declare class RealtimeVoice implements CallVoice {
|
|
|
97
70
|
stop(): void;
|
|
98
71
|
/** Sound of the microphone: sent while Ta listens or reads, in pieces of CHUNK_MS. */
|
|
99
72
|
protected captured(samples: Float32Array): void;
|
|
73
|
+
protected send(pcm: Uint8Array): void;
|
|
74
|
+
/** Of a voice that thinks: its answer plays, or just did; the microphone is held (MicFilter). */
|
|
75
|
+
protected get gated(): boolean;
|
|
100
76
|
protected take(event: TaVoiceEvent): void;
|
|
77
|
+
/**
|
|
78
|
+
* An event of a voice that thinks: the user speaking stops its answer (the service stopped it too), its answers
|
|
79
|
+
* play as they come, each a say of its own, and the call is told.
|
|
80
|
+
*/
|
|
81
|
+
protected thought(talking: Talking, event: Exclude<TaVoiceEvent, {
|
|
82
|
+
type: 'closed';
|
|
83
|
+
}>): void;
|
|
84
|
+
/** What plays now stops, here only: the service stopped it, or will drop it. */
|
|
85
|
+
protected silence(): void;
|
|
86
|
+
protected stopPlaying(): void;
|
|
101
87
|
/** The service is gone: the listen and the reading going on end, the listen with `error`. */
|
|
102
88
|
protected lose(error: string): void;
|
|
103
89
|
protected play(samples: Float32Array): void;
|
|
@@ -108,12 +94,21 @@ export declare class RealtimeVoice implements CallVoice {
|
|
|
108
94
|
/** When a sound stops the reading, as voices.json says. */
|
|
109
95
|
protected get barge(): TaBargeIn;
|
|
110
96
|
protected output(context: AudioContext): void;
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
protected samples?: Float32Array<ArrayBuffer>;
|
|
98
|
+
/** 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. */
|
|
99
|
+
level(): number;
|
|
100
|
+
nowReading(): CallReading | undefined;
|
|
101
|
+
readonly onSound: (listener: (say: number, pcm: Uint8Array | undefined, rate: number) => void) => (() => void);
|
|
102
|
+
readonly hold: (ms: number) => void;
|
|
103
|
+
/** Sound of the reading `say` came: told to who listens (the face of a video call), and played. */
|
|
104
|
+
protected heard(say: number, data: string): void;
|
|
105
|
+
/** All the sound of a reading came: it ends once played, and who listens knows. */
|
|
106
|
+
protected allCame(reading: Reading): void;
|
|
107
|
+
protected clockOf(reading: Reading, pieces: string[], onPiece?: (pieces: string[], index: number) => void): VoiceReading | undefined;
|
|
113
108
|
/** A sound began while Ta reads: the reading goes on lower until the sound is known as speech, or not. */
|
|
114
109
|
protected suspect(): void;
|
|
115
|
-
/**
|
|
116
|
-
protected
|
|
110
|
+
/** The floor of the room, and whether what the microphone hears is voiced. */
|
|
111
|
+
protected readonly sense: MicSense;
|
|
117
112
|
/** ms of sound the microphone gave, and where in it the user's voice was last heard while Ta listens. */
|
|
118
113
|
protected clock: number;
|
|
119
114
|
protected voiceAt: number;
|
|
@@ -122,18 +117,11 @@ export declare class RealtimeVoice implements CallVoice {
|
|
|
122
117
|
* are the sound around, which speech must be louder than.
|
|
123
118
|
*/
|
|
124
119
|
protected measure(samples: Float32Array, rate: number): void;
|
|
125
|
-
/** The level that counts as speech: BargeIn.level, or louder than the
|
|
120
|
+
/** The level that counts as speech: BargeIn.level, or louder than the floor of the room. */
|
|
126
121
|
protected get speechLevel(): number;
|
|
127
|
-
/**
|
|
128
|
-
* A piece of the microphone while in doubt: speech long enough is the user cutting in, unless it is no louder than
|
|
129
|
-
* Ta's own voice heard back (what plays, times TaBargeIn.echo).
|
|
130
|
-
*/
|
|
131
|
-
protected weigh(level: number, ms: number): void;
|
|
132
122
|
/** The user cut in: the call stops the reading and listens, and this listen hears the sentence begun. */
|
|
133
123
|
protected bargeIn(): void;
|
|
134
124
|
protected clearDoubt(): void;
|
|
135
125
|
protected loudness(value: number): void;
|
|
136
|
-
static rms(samples: Float32Array): number;
|
|
137
126
|
}
|
|
138
|
-
export {};
|
|
139
127
|
//# sourceMappingURL=realtime-voice.d.ts.map
|