@streamoji/aitwin 0.5.2 → 0.5.4

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/README.md CHANGED
@@ -16,6 +16,8 @@ npm install react react-dom
16
16
 
17
17
  ## Usage
18
18
 
19
+ ### React — face only (`AiTwin`)
20
+
19
21
  ```tsx
20
22
  import { useRef } from "react";
21
23
  import { AiTwin, type AiTwinHandle } from "@streamoji/aitwin";
@@ -44,6 +46,45 @@ function Demo() {
44
46
  }
45
47
  ```
46
48
 
49
+ ### React — widget chrome (`AiTwinWidget`)
50
+
51
+ Same Talk / Text / mute / float UI as the HTML script tag:
52
+
53
+ ```tsx
54
+ import { useRef } from "react";
55
+ import { AiTwinWidget, type AiTwinWidgetHandle } from "@streamoji/aitwin";
56
+
57
+ function WidgetDemo() {
58
+ const ref = useRef<AiTwinWidgetHandle>(null);
59
+
60
+ return (
61
+ <AiTwinWidget
62
+ ref={ref}
63
+ id="zoe"
64
+ authToken={optionalBearerToken}
65
+ showControls
66
+ float
67
+ onReady={() => console.log("ready")}
68
+ />
69
+ );
70
+ }
71
+ ```
72
+
73
+ ### HTML — script tag
74
+
75
+ ```html
76
+ <div id="aitwin"></div>
77
+ <script src="https://…/aitwin-widget.umd.js"></script>
78
+ <script>
79
+ AiTwinWidget.init("#aitwin", {
80
+ id: "zoe",
81
+ authToken: "client_…",
82
+ showControls: true,
83
+ float: true,
84
+ });
85
+ </script>
86
+ ```
87
+
47
88
  ### Props
48
89
 
49
90
  Provide **`id`** (cloud twin), **`avatarId`/`faceId`** (R2 custom face), or **`assets`** (fixed URLs). One is required.
@@ -59,6 +100,7 @@ Provide **`id`** (cloud twin), **`avatarId`/`faceId`** (R2 custom face), or **`a
59
100
  | `voiceId` | Override TTS voice |
60
101
  | `speakingRate` | Default `0.85` |
61
102
  | `showErrorOverlay` | Canvas error overlay (default `true`) |
103
+ | `captions` | Plain subtitles during TTS/voice playback (`true` or style options) |
62
104
  | `onReady` | Assets loaded and canvas ready |
63
105
  | `onStatusChange` | TTS status: idle, loading, speaking, done, error |
64
106
  | `onDisplayStatus` | Compositor label (viseme / idle / transition) |
@@ -69,6 +111,28 @@ Provide **`id`** (cloud twin), **`avatarId`/`faceId`** (R2 custom face), or **`a
69
111
 
70
112
  Use **stable** `useCallback` handlers for `onReady` / `onError` / `onDisplayStatus` in parent components.
71
113
 
114
+ #### Captions
115
+
116
+ Enable plain subtitles for the current speech segment:
117
+
118
+ ```tsx
119
+ <AiTwin
120
+ id="olivia"
121
+ captions={true}
122
+ />
123
+
124
+ <AiTwin
125
+ id="olivia"
126
+ captions={{
127
+ fontFamily: "Georgia, serif",
128
+ fontSize: "1.1rem",
129
+ color: "rgba(255,255,255,0.85)",
130
+ }}
131
+ />
132
+ ```
133
+
134
+ Works for both `speakText()` and voice `connect()` bot responses.
135
+
72
136
  ### Ref handle
73
137
 
74
138
  | Method | Description |