@memori.ai/memori-react 7.6.1 → 7.7.1
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/CHANGELOG.md +30 -0
- package/dist/components/AttachmentMediaModal/AttachmentMediaModal.d.ts +14 -0
- package/dist/components/AttachmentMediaModal/AttachmentMediaModal.js +66 -0
- package/dist/components/AttachmentMediaModal/AttachmentMediaModal.js.map +1 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.d.ts +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js +51 -26
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/components/fullbodyAvatar.js +8 -6
- package/dist/components/Avatar/AvatarView/components/fullbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/utils/useMouthSpeaking.js +1 -1
- package/dist/components/Avatar/AvatarView/utils/useMouthSpeaking.js.map +1 -1
- package/dist/components/ImageUpload/ImageUpload.css +168 -0
- package/dist/components/ImageUpload/ImageUpload.d.ts +28 -0
- package/dist/components/ImageUpload/ImageUpload.js +163 -0
- package/dist/components/ImageUpload/ImageUpload.js.map +1 -0
- package/dist/components/MemoriWidget/MemoriWidget.js +2 -1
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/layouts/Default.d.ts +17 -0
- package/dist/components/layouts/Default.js +8 -0
- package/dist/components/layouts/Default.js.map +1 -0
- package/dist/components/layouts/ZoomedFullBody.d.ts +2 -2
- package/dist/components/layouts/ZoomedFullBody.js +11 -2
- package/dist/components/layouts/ZoomedFullBody.js.map +1 -1
- package/dist/components/layouts/zoomed-full-body.css +16 -0
- package/dist/components/ui/Message.d.ts +17 -0
- package/dist/components/ui/Message.js +13 -0
- package/dist/components/ui/Message.js.map +1 -0
- package/dist/context/visemeContext.js +36 -11
- package/dist/context/visemeContext.js.map +1 -1
- package/dist/helpers/translations.js +10 -2
- package/dist/helpers/translations.js.map +1 -1
- package/dist/helpers/utils.js +5 -6
- package/dist/helpers/utils.js.map +1 -1
- package/dist/styles.css +1 -1
- package/esm/components/AttachmentMediaModal/AttachmentMediaModal.d.ts +14 -0
- package/esm/components/AttachmentMediaModal/AttachmentMediaModal.js +63 -0
- package/esm/components/AttachmentMediaModal/AttachmentMediaModal.js.map +1 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.d.ts +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js +53 -28
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/components/fullbodyAvatar.js +8 -6
- package/esm/components/Avatar/AvatarView/components/fullbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/utils/useMouthSpeaking.js +1 -1
- package/esm/components/Avatar/AvatarView/utils/useMouthSpeaking.js.map +1 -1
- package/esm/components/ImageUpload/ImageUpload.css +168 -0
- package/esm/components/ImageUpload/ImageUpload.d.ts +28 -0
- package/esm/components/ImageUpload/ImageUpload.js +160 -0
- package/esm/components/ImageUpload/ImageUpload.js.map +1 -0
- package/esm/components/MemoriWidget/MemoriWidget.js +2 -1
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/layouts/Default.d.ts +17 -0
- package/esm/components/layouts/Default.js +5 -0
- package/esm/components/layouts/Default.js.map +1 -0
- package/esm/components/layouts/ZoomedFullBody.d.ts +2 -2
- package/esm/components/layouts/ZoomedFullBody.js +11 -2
- package/esm/components/layouts/ZoomedFullBody.js.map +1 -1
- package/esm/components/layouts/zoomed-full-body.css +16 -0
- package/esm/components/ui/Message.d.ts +17 -0
- package/esm/components/ui/Message.js +10 -0
- package/esm/components/ui/Message.js.map +1 -0
- package/esm/context/visemeContext.js +36 -11
- package/esm/context/visemeContext.js.map +1 -1
- package/esm/helpers/translations.js +10 -2
- package/esm/helpers/translations.js.map +1 -1
- package/esm/helpers/utils.js +5 -6
- package/esm/helpers/utils.js.map +1 -1
- package/esm/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.tsx +81 -36
- package/src/components/MemoriWidget/MemoriWidget.tsx +3 -2
- package/src/components/layouts/ZoomedFullBody.test.tsx +1 -1
- package/src/components/layouts/ZoomedFullBody.tsx +38 -29
- package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +25 -21
- package/src/components/layouts/zoomed-full-body.css +16 -0
- package/src/context/visemeContext.tsx +68 -51
- package/src/helpers/translations.ts +11 -8
- package/src/helpers/utils.ts +9 -8
- package/src/index.stories.tsx +23 -21
- package/src/styles.css +1 -1
- package/dist/components/Avatar/AvatarView/components/avatar.d.ts +0 -9
- package/dist/components/Avatar/AvatarView/components/avatar.js +0 -39
- package/dist/components/Avatar/AvatarView/components/avatar.js.map +0 -1
- package/dist/components/Avatar/AvatarView/utils/useViseme.d.ts +0 -18
- package/dist/components/Avatar/AvatarView/utils/useViseme.js +0 -141
- package/dist/components/Avatar/AvatarView/utils/useViseme.js.map +0 -1
- package/dist/components/Avatar/AvatarView/utils/visemeContext.d.ts +0 -24
- package/dist/components/Avatar/AvatarView/utils/visemeContext.js +0 -157
- package/dist/components/Avatar/AvatarView/utils/visemeContext.js.map +0 -1
- package/dist/components/MemoriWidget/enhanceSSML/enhanceSSML.d.ts +0 -4
- package/dist/components/MemoriWidget/enhanceSSML/enhanceSSML.js +0 -157
- package/dist/components/MemoriWidget/enhanceSSML/enhanceSSML.js.map +0 -1
- package/dist/components/layouts/ZoomedHalfBody.d.ts +0 -4
- package/dist/components/layouts/ZoomedHalfBody.js +0 -8
- package/dist/components/layouts/ZoomedHalfBody.js.map +0 -1
- package/dist/components/layouts/zoomed-half-body.css +0 -3
- package/esm/components/Avatar/AvatarView/components/avatar.d.ts +0 -9
- package/esm/components/Avatar/AvatarView/components/avatar.js +0 -35
- package/esm/components/Avatar/AvatarView/components/avatar.js.map +0 -1
- package/esm/components/Avatar/AvatarView/utils/useViseme.d.ts +0 -18
- package/esm/components/Avatar/AvatarView/utils/useViseme.js +0 -137
- package/esm/components/Avatar/AvatarView/utils/useViseme.js.map +0 -1
- package/esm/components/Avatar/AvatarView/utils/visemeContext.d.ts +0 -24
- package/esm/components/Avatar/AvatarView/utils/visemeContext.js +0 -152
- package/esm/components/Avatar/AvatarView/utils/visemeContext.js.map +0 -1
- package/esm/components/MemoriWidget/enhanceSSML/enhanceSSML.d.ts +0 -4
- package/esm/components/MemoriWidget/enhanceSSML/enhanceSSML.js +0 -152
- package/esm/components/MemoriWidget/enhanceSSML/enhanceSSML.js.map +0 -1
- package/esm/components/layouts/ZoomedHalfBody.d.ts +0 -4
- package/esm/components/layouts/ZoomedHalfBody.js +0 -5
- package/esm/components/layouts/ZoomedHalfBody.js.map +0 -1
- package/esm/components/layouts/zoomed-half-body.css +0 -3
|
@@ -6,7 +6,7 @@ import React, {
|
|
|
6
6
|
useRef,
|
|
7
7
|
useEffect,
|
|
8
8
|
} from 'react';
|
|
9
|
-
import { SkinnedMesh } from 'three';
|
|
9
|
+
import { MathUtils, SkinnedMesh } from 'three';
|
|
10
10
|
|
|
11
11
|
type AzureViseme = { visemeId: number; audioOffset: number };
|
|
12
12
|
|
|
@@ -30,37 +30,36 @@ interface VisemeContextType {
|
|
|
30
30
|
|
|
31
31
|
const VisemeContext = createContext<VisemeContextType | undefined>(undefined);
|
|
32
32
|
|
|
33
|
-
const VISEME_SMOOTHING = 0.
|
|
33
|
+
const VISEME_SMOOTHING = 0.3;
|
|
34
34
|
const DEFAULT_VISEME_DURATION = 0.1;
|
|
35
35
|
const MINIMUM_ELAPSED_TIME = 0.01;
|
|
36
|
-
const VISEME_SPEED_FACTOR = 1
|
|
37
|
-
const AUDIO_PLAYBACK_RATE = 1
|
|
38
|
-
const VISEME_BASE_SPEED = 1
|
|
36
|
+
const VISEME_SPEED_FACTOR = 1;
|
|
37
|
+
const AUDIO_PLAYBACK_RATE = 1;
|
|
38
|
+
const VISEME_BASE_SPEED = 1;
|
|
39
39
|
|
|
40
40
|
const VISEME_MAP: { [key: number]: string } = {
|
|
41
|
-
0: 'viseme_sil',
|
|
42
|
-
1: 'viseme_PP',
|
|
43
|
-
2: 'viseme_FF',
|
|
44
|
-
3: 'viseme_TH',
|
|
45
|
-
4: 'viseme_DD',
|
|
46
|
-
5: 'viseme_kk',
|
|
47
|
-
6: 'viseme_CH',
|
|
48
|
-
7: 'viseme_SS',
|
|
49
|
-
8: 'viseme_nn',
|
|
50
|
-
9: 'viseme_RR',
|
|
51
|
-
10: 'viseme_aa',
|
|
52
|
-
11: 'viseme_E',
|
|
53
|
-
12: 'viseme_I',
|
|
54
|
-
13: 'viseme_O',
|
|
55
|
-
14: 'viseme_U',
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
21: 'viseme_PP', // y (closest match, could be debated)
|
|
41
|
+
0: 'viseme_sil',
|
|
42
|
+
1: 'viseme_PP',
|
|
43
|
+
2: 'viseme_FF',
|
|
44
|
+
3: 'viseme_TH',
|
|
45
|
+
4: 'viseme_DD',
|
|
46
|
+
5: 'viseme_kk',
|
|
47
|
+
6: 'viseme_CH',
|
|
48
|
+
7: 'viseme_SS',
|
|
49
|
+
8: 'viseme_nn',
|
|
50
|
+
9: 'viseme_RR',
|
|
51
|
+
10: 'viseme_aa',
|
|
52
|
+
11: 'viseme_E',
|
|
53
|
+
12: 'viseme_I',
|
|
54
|
+
13: 'viseme_O',
|
|
55
|
+
14: 'viseme_U',
|
|
56
|
+
15: 'viseme_kk',
|
|
57
|
+
16: 'viseme_CH',
|
|
58
|
+
17: 'viseme_SS',
|
|
59
|
+
18: 'viseme_TH',
|
|
60
|
+
19: 'viseme_RR',
|
|
61
|
+
20: 'viseme_kk',
|
|
62
|
+
21: 'viseme_PP',
|
|
64
63
|
};
|
|
65
64
|
|
|
66
65
|
export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
@@ -80,8 +79,8 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
80
79
|
return start * (1 - alpha) + end * alpha;
|
|
81
80
|
};
|
|
82
81
|
|
|
83
|
-
const
|
|
84
|
-
return x < 0.5 ?
|
|
82
|
+
const easeInOutQuad = (x: number): number => {
|
|
83
|
+
return x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2;
|
|
85
84
|
};
|
|
86
85
|
|
|
87
86
|
const setMeshRef = useCallback(
|
|
@@ -89,7 +88,6 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
89
88
|
if (mesh && mesh.morphTargetDictionary && mesh.morphTargetInfluences) {
|
|
90
89
|
meshRef.current = mesh;
|
|
91
90
|
setIsMeshSet(true);
|
|
92
|
-
// console.log('Mesh set successfully:', mesh);
|
|
93
91
|
} else {
|
|
94
92
|
console.error('Invalid mesh provided:', mesh);
|
|
95
93
|
}
|
|
@@ -99,7 +97,6 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
99
97
|
|
|
100
98
|
const addVisemeToQueue = useCallback((viseme: AzureViseme) => {
|
|
101
99
|
visemeQueueRef.current.push(viseme);
|
|
102
|
-
// console.log('Viseme added to queue:', viseme);
|
|
103
100
|
}, []);
|
|
104
101
|
|
|
105
102
|
const getCurrentViseme = useCallback((elapsedTime: number) => {
|
|
@@ -115,7 +112,7 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
115
112
|
}, []);
|
|
116
113
|
|
|
117
114
|
const getDynamicSpeedFactor = (visemeDuration: number): number => {
|
|
118
|
-
const baseDuration = 0.1;
|
|
115
|
+
const baseDuration = 0.1;
|
|
119
116
|
return (
|
|
120
117
|
VISEME_BASE_SPEED * (baseDuration / visemeDuration) * AUDIO_PLAYBACK_RATE
|
|
121
118
|
);
|
|
@@ -136,11 +133,10 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
136
133
|
const dynamicSpeedFactor = getDynamicSpeedFactor(viseme.duration);
|
|
137
134
|
const adjustedProgress = visemeProgress * dynamicSpeedFactor;
|
|
138
135
|
|
|
139
|
-
|
|
140
|
-
const easedProgress = easeInOutCubic(adjustedProgress);
|
|
136
|
+
const easedProgress = easeInOutQuad(adjustedProgress);
|
|
141
137
|
const targetWeight = Math.sin(easedProgress * Math.PI) * viseme.weight;
|
|
142
138
|
|
|
143
|
-
currentVisemeWeightRef.current[viseme.name] = lerp(
|
|
139
|
+
currentVisemeWeightRef.current[viseme.name] = MathUtils.lerp(
|
|
144
140
|
currentVisemeWeightRef.current[viseme.name] || 0,
|
|
145
141
|
targetWeight,
|
|
146
142
|
VISEME_SMOOTHING
|
|
@@ -153,12 +149,26 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
153
149
|
) {
|
|
154
150
|
meshRef.current.morphTargetInfluences[visemeIndex] =
|
|
155
151
|
currentVisemeWeightRef.current[viseme.name];
|
|
156
|
-
// console.log(`Applied viseme: ${viseme.name}, weight: ${currentVisemeWeightRef.current[viseme.name]}`);
|
|
157
152
|
} else {
|
|
158
153
|
console.error(
|
|
159
154
|
`Viseme not found in morph target dictionary: ${viseme.name}`
|
|
160
155
|
);
|
|
161
156
|
}
|
|
157
|
+
|
|
158
|
+
Object.keys(currentVisemeWeightRef.current).forEach((visemeName) => {
|
|
159
|
+
if (visemeName !== viseme.name) {
|
|
160
|
+
currentVisemeWeightRef.current[visemeName] = lerp(
|
|
161
|
+
currentVisemeWeightRef.current[visemeName],
|
|
162
|
+
0,
|
|
163
|
+
VISEME_SMOOTHING * 0.5
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const index = meshRef.current!.morphTargetDictionary?.[visemeName];
|
|
167
|
+
if (typeof index === 'number' && meshRef.current!.morphTargetInfluences) {
|
|
168
|
+
meshRef.current!.morphTargetInfluences[index] = currentVisemeWeightRef.current[visemeName];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
162
172
|
},
|
|
163
173
|
[]
|
|
164
174
|
);
|
|
@@ -199,7 +209,6 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
199
209
|
visemeQueueRef.current = [];
|
|
200
210
|
|
|
201
211
|
if (azureVisemes.length === 0) {
|
|
202
|
-
// console.log('No visemes to process');
|
|
203
212
|
return [];
|
|
204
213
|
}
|
|
205
214
|
|
|
@@ -216,21 +225,34 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
216
225
|
weight: 1,
|
|
217
226
|
startTime: currentViseme.audioOffset / 10000000,
|
|
218
227
|
};
|
|
219
|
-
//console.log('Processed viseme:', processedViseme);
|
|
220
228
|
return processedViseme;
|
|
221
229
|
}
|
|
222
230
|
);
|
|
223
231
|
|
|
224
|
-
|
|
232
|
+
const interpolatedVisemes: ProcessedViseme[] = [];
|
|
233
|
+
for (let i = 0; i < processedVisemes.length - 1; i++) {
|
|
234
|
+
const currentViseme = processedVisemes[i];
|
|
235
|
+
const nextViseme = processedVisemes[i + 1];
|
|
236
|
+
|
|
237
|
+
interpolatedVisemes.push(currentViseme);
|
|
238
|
+
|
|
239
|
+
const intermediateDuration = (nextViseme.startTime - currentViseme.startTime) * 0.5;
|
|
240
|
+
interpolatedVisemes.push({
|
|
241
|
+
name: 'viseme_sil',
|
|
242
|
+
duration: intermediateDuration,
|
|
243
|
+
weight: 0.5,
|
|
244
|
+
startTime: currentViseme.startTime + intermediateDuration,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
interpolatedVisemes.push(processedVisemes[processedVisemes.length - 1]);
|
|
248
|
+
|
|
249
|
+
currentVisemesRef.current = interpolatedVisemes;
|
|
225
250
|
|
|
226
|
-
// Start animation immediately if not already animating
|
|
227
251
|
if (!isAnimatingRef.current) {
|
|
228
252
|
isAnimatingRef.current = true;
|
|
229
253
|
startTimeRef.current = performance.now();
|
|
230
|
-
// console.log('Starting animation');
|
|
231
254
|
animationFrameRef.current = requestAnimationFrame(animate);
|
|
232
255
|
} else {
|
|
233
|
-
// If already animating, adjust the start time for the new visemes
|
|
234
256
|
if (startTimeRef.current !== null) {
|
|
235
257
|
const currentTime = performance.now();
|
|
236
258
|
const elapsedTime =
|
|
@@ -240,8 +262,8 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
240
262
|
}
|
|
241
263
|
}
|
|
242
264
|
|
|
243
|
-
return
|
|
244
|
-
}, [
|
|
265
|
+
return interpolatedVisemes;
|
|
266
|
+
}, [animate]);
|
|
245
267
|
|
|
246
268
|
const clearVisemes = useCallback(() => {
|
|
247
269
|
currentVisemesRef.current = [];
|
|
@@ -266,10 +288,8 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
266
288
|
currentVisemeWeightRef.current = {};
|
|
267
289
|
startTimeRef.current = null;
|
|
268
290
|
isAnimatingRef.current = false;
|
|
269
|
-
// console.log('Visemes cleared');
|
|
270
291
|
}, []);
|
|
271
292
|
|
|
272
|
-
// Your existing emotion map
|
|
273
293
|
const emotionMap: Record<string, Record<string, number>> = {
|
|
274
294
|
Gioia: { Gioria: 1 },
|
|
275
295
|
Rabbia: { Rabbia: 1 },
|
|
@@ -278,7 +298,6 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
278
298
|
Timore: { Timore: 1 },
|
|
279
299
|
};
|
|
280
300
|
|
|
281
|
-
// Mapping from your emotions to Azure styles
|
|
282
301
|
const emotionToAzureStyleMap: Record<string, string> = {
|
|
283
302
|
Gioia: 'cheerful',
|
|
284
303
|
Rabbia: 'angry',
|
|
@@ -287,12 +306,10 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
287
306
|
Timore: 'terrified',
|
|
288
307
|
};
|
|
289
308
|
|
|
290
|
-
// Function to get Azure style from emotion
|
|
291
309
|
function getAzureStyleForEmotion(emotion: string): string {
|
|
292
310
|
return emotionToAzureStyleMap[emotion] || 'neutral';
|
|
293
311
|
}
|
|
294
312
|
|
|
295
|
-
|
|
296
313
|
useEffect(() => {
|
|
297
314
|
return () => {
|
|
298
315
|
if (animationFrameRef.current !== null) {
|
|
@@ -325,4 +342,4 @@ export const useViseme = (): VisemeContextType => {
|
|
|
325
342
|
throw new Error('useViseme must be used within a VisemeProvider');
|
|
326
343
|
}
|
|
327
344
|
return context;
|
|
328
|
-
};
|
|
345
|
+
};
|
|
@@ -28,18 +28,21 @@ export const getTranslation = async (
|
|
|
28
28
|
|
|
29
29
|
const isReservedKeyword = dialogKeywords.indexOf(text.toLowerCase()) > -1;
|
|
30
30
|
const fromLanguage = isReservedKeyword ? 'IT' : from?.toUpperCase();
|
|
31
|
+
const toLanguage = to.toUpperCase();
|
|
32
|
+
|
|
31
33
|
const deeplResult = await fetch(
|
|
32
|
-
`${
|
|
33
|
-
baseUrl || 'https://www.aisuru.com'
|
|
34
|
-
}/api/translate?text=${encodeURIComponent(
|
|
35
|
-
textToTranslate
|
|
36
|
-
)}&target_lang=${to.toUpperCase()}${
|
|
37
|
-
fromLanguage ? `&source_lang=${fromLanguage}` : ''
|
|
38
|
-
}`,
|
|
34
|
+
`${baseUrl || 'https://www.aisuru.com'}/api/translate`,
|
|
39
35
|
{
|
|
40
|
-
|
|
36
|
+
cache: 'no-cache',
|
|
37
|
+
method: 'POST',
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
text: textToTranslate,
|
|
40
|
+
target_lang: toLanguage,
|
|
41
|
+
source_lang: fromLanguage,
|
|
42
|
+
}),
|
|
41
43
|
headers: {
|
|
42
44
|
Accept: '*/*',
|
|
45
|
+
'Content-Type': 'application/json',
|
|
43
46
|
},
|
|
44
47
|
}
|
|
45
48
|
);
|
package/src/helpers/utils.ts
CHANGED
|
@@ -184,15 +184,16 @@ export const stripMarkdown = (text: string) => {
|
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
export const stripOutputTags = (text: string): string => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (!
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
let textBefore = output[0].split('<output')[0];
|
|
193
|
-
let textAfter = output[1];
|
|
187
|
+
const outputTagRegex = /<output.*?<\/output>/gs;
|
|
188
|
+
|
|
189
|
+
if (!outputTagRegex.test(text)) {
|
|
190
|
+
return text;
|
|
191
|
+
}
|
|
194
192
|
|
|
195
|
-
|
|
193
|
+
const strippedText = text.replace(outputTagRegex, '');
|
|
194
|
+
|
|
195
|
+
// Recursively strip nested output tags
|
|
196
|
+
return stripOutputTags(strippedText);
|
|
196
197
|
};
|
|
197
198
|
|
|
198
199
|
export const stripHTML = (text: string) => {
|
package/src/index.stories.tsx
CHANGED
|
@@ -111,29 +111,31 @@ Giovanna.args = {
|
|
|
111
111
|
|
|
112
112
|
export const GiovannaProva = Template.bind({});
|
|
113
113
|
GiovannaProva.args = {
|
|
114
|
-
memoriName: '
|
|
115
|
-
ownerUserName: '
|
|
116
|
-
memoriID: '
|
|
117
|
-
ownerUserID: '
|
|
118
|
-
tenantID: '
|
|
119
|
-
engineURL: 'https://engine.memori.ai',
|
|
120
|
-
apiURL: 'https://backend.memori.ai',
|
|
121
|
-
baseURL: 'https://
|
|
122
|
-
uiLang: '
|
|
114
|
+
memoriName: 'Giovanna Test',
|
|
115
|
+
ownerUserName: 'andrea.patini3',
|
|
116
|
+
memoriID: '431d9819-c958-442c-a799-f90617371c0c',
|
|
117
|
+
ownerUserID: '58770358-a5db-4b49-b3a4-734fc468e745',
|
|
118
|
+
tenantID: 'aisuru-staging.aclambda.online',
|
|
119
|
+
engineURL: 'https://engine-staging.memori.ai',
|
|
120
|
+
apiURL: 'https://backend-staging.memori.ai',
|
|
121
|
+
baseURL: 'https://aisuru-staging.aclambda.online',
|
|
122
|
+
uiLang: 'EN',
|
|
123
123
|
spokenLang: 'IT',
|
|
124
124
|
layout: 'ZOOMED_FULL_BODY',
|
|
125
|
-
showInstruct: false,
|
|
126
|
-
showSettings: true,
|
|
127
|
-
showClear: false,
|
|
128
|
-
showAIicon: true,
|
|
129
|
-
showWhyThisAnswer: true,
|
|
130
|
-
showTypingText: false,
|
|
131
|
-
showOnlyLastMessages: false,
|
|
132
|
-
showTranslationOriginal: false,
|
|
133
|
-
showCopyButton: false,
|
|
134
|
-
showShare: true,
|
|
135
|
-
showLogin: false,
|
|
136
|
-
enableAudio: true,
|
|
125
|
+
showInstruct: 'false',
|
|
126
|
+
showSettings: 'true',
|
|
127
|
+
showClear: 'false',
|
|
128
|
+
showAIicon: 'true',
|
|
129
|
+
showWhyThisAnswer: 'true',
|
|
130
|
+
showTypingText: 'false',
|
|
131
|
+
showOnlyLastMessages: 'false',
|
|
132
|
+
showTranslationOriginal: 'false',
|
|
133
|
+
showCopyButton: 'false',
|
|
134
|
+
showShare: 'true',
|
|
135
|
+
showLogin: 'false',
|
|
136
|
+
enableAudio: 'true',
|
|
137
|
+
integrationID: 'e92ac275-39b5-474d-8f9e-826cc5284f1e',
|
|
138
|
+
initialQuestion: 'inizio simulazione',
|
|
137
139
|
};
|
|
138
140
|
|
|
139
141
|
const TemplateWithBatchButton: Story<Props> = args => (
|
package/src/styles.css
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
@import url('./components/layouts/totem.css');
|
|
53
53
|
@import url('./components/layouts/website-assistant.css');
|
|
54
54
|
@import url('./components/layouts/chat.css');
|
|
55
|
-
|
|
55
|
+
@import url('./components/layouts/zoomed-full-body.css');
|
|
56
56
|
@import url('https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/katex.min.css');
|
|
57
57
|
|
|
58
58
|
.sr-only {
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
interface AvatarProps {
|
|
2
|
-
url: string;
|
|
3
|
-
eyeBlink?: boolean;
|
|
4
|
-
headMovement?: boolean;
|
|
5
|
-
speaking?: boolean;
|
|
6
|
-
onLoaded?: () => void;
|
|
7
|
-
}
|
|
8
|
-
export default function Avatar({ url, eyeBlink, headMovement, speaking, onLoaded, }: AvatarProps): JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const three_1 = require("three");
|
|
7
|
-
const drei_1 = require("@react-three/drei");
|
|
8
|
-
const useEyeBlink_1 = tslib_1.__importDefault(require("../utils/useEyeBlink"));
|
|
9
|
-
const useHeadMovement_1 = tslib_1.__importDefault(require("../utils/useHeadMovement"));
|
|
10
|
-
const useMouthSpeaking_1 = tslib_1.__importDefault(require("../utils/useMouthSpeaking"));
|
|
11
|
-
const fiber_1 = require("@react-three/fiber");
|
|
12
|
-
const utils_1 = require("../utils/utils");
|
|
13
|
-
const AVATAR_POSITION = new three_1.Vector3(0, -0.6, 0);
|
|
14
|
-
function Avatar({ url, eyeBlink, headMovement, speaking, onLoaded, }) {
|
|
15
|
-
const { scene } = (0, drei_1.useGLTF)(url);
|
|
16
|
-
const { nodes, materials } = (0, fiber_1.useGraph)(scene);
|
|
17
|
-
(0, useEyeBlink_1.default)(eyeBlink, nodes);
|
|
18
|
-
(0, useHeadMovement_1.default)(headMovement, nodes);
|
|
19
|
-
(0, useMouthSpeaking_1.default)(!!speaking, nodes);
|
|
20
|
-
(0, react_1.useEffect)(() => {
|
|
21
|
-
const setupAvatar = () => {
|
|
22
|
-
(0, utils_1.hideHands)(nodes);
|
|
23
|
-
(0, utils_1.correctMaterials)(materials);
|
|
24
|
-
onLoaded === null || onLoaded === void 0 ? void 0 : onLoaded();
|
|
25
|
-
};
|
|
26
|
-
setupAvatar();
|
|
27
|
-
return () => {
|
|
28
|
-
const disposeObjects = () => {
|
|
29
|
-
Object.values(materials).forEach(fiber_1.dispose);
|
|
30
|
-
Object.values(nodes).filter(utils_1.isSkinnedMesh).forEach(fiber_1.dispose);
|
|
31
|
-
};
|
|
32
|
-
disposeObjects();
|
|
33
|
-
};
|
|
34
|
-
}, [materials, nodes, url, onLoaded]);
|
|
35
|
-
const skinnedMeshes = (0, react_1.useMemo)(() => Object.values(nodes).filter(utils_1.isSkinnedMesh), [nodes]);
|
|
36
|
-
return ((0, jsx_runtime_1.jsxs)("group", { position: AVATAR_POSITION, children: [(0, jsx_runtime_1.jsx)("primitive", { object: nodes.Hips }, "armature"), skinnedMeshes.map((node) => ((0, jsx_runtime_1.jsx)("primitive", { object: node, receiveShadow: true, castShadow: true }, node.name)))] }));
|
|
37
|
-
}
|
|
38
|
-
exports.default = Avatar;
|
|
39
|
-
//# sourceMappingURL=avatar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../../../../src/components/Avatar/AvatarView/components/avatar.tsx"],"names":[],"mappings":";;;;AAAA,iCAAkD;AAClD,iCAA0C;AAC1C,4CAA4C;AAC5C,+EAA+C;AAC/C,uFAAuD;AACvD,yFAAyD;AACzD,8CAAuD;AACvD,0CAA4E;AAW5E,MAAM,eAAe,GAAG,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAEhD,SAAwB,MAAM,CAAC,EAC7B,GAAG,EACH,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,QAAQ,GACI;IACZ,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,cAAO,EAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE7C,IAAA,qBAAW,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC7B,IAAA,yBAAe,EAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACrC,IAAA,0BAAgB,EAAC,CAAC,CAAC,QAAQ,EAA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ureViseme = {
|
|
3
|
-
visemeId: number;
|
|
4
|
-
audioOffset: number;
|
|
5
|
-
};
|
|
6
|
-
type ProcessedViseme = {
|
|
7
|
-
name: string;
|
|
8
|
-
duration: number;
|
|
9
|
-
weight: number;
|
|
10
|
-
startTime: number;
|
|
11
|
-
};
|
|
12
|
-
export declare const useViseme: () => {
|
|
13
|
-
addVisemeToQueue: (viseme: AzureViseme) => void;
|
|
14
|
-
processVisemeQueue: () => ProcessedViseme[];
|
|
15
|
-
clearVisemes: () => void;
|
|
16
|
-
setMeshRef: (mesh: SkinnedMesh | null) => void;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useViseme = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const VISEME_SMOOTHING = 0.42;
|
|
6
|
-
const DEFAULT_VISEME_DURATION = 0.1;
|
|
7
|
-
const lerp = (start, end, alpha) => {
|
|
8
|
-
return start * (1 - alpha) + end * alpha;
|
|
9
|
-
};
|
|
10
|
-
const useViseme = () => {
|
|
11
|
-
const [currentVisemes, setCurrentVisemes] = (0, react_1.useState)([]);
|
|
12
|
-
const visemeQueueRef = (0, react_1.useRef)([]);
|
|
13
|
-
const animationFrameRef = (0, react_1.useRef)(null);
|
|
14
|
-
const startTimeRef = (0, react_1.useRef)(null);
|
|
15
|
-
const currentVisemeWeightRef = (0, react_1.useRef)({});
|
|
16
|
-
const meshRef = (0, react_1.useRef)(null);
|
|
17
|
-
const visemeMap = {
|
|
18
|
-
0: 'viseme_sil',
|
|
19
|
-
1: 'viseme_aa',
|
|
20
|
-
2: 'viseme_aa',
|
|
21
|
-
3: 'viseme_O',
|
|
22
|
-
4: 'viseme_E',
|
|
23
|
-
5: 'viseme_I',
|
|
24
|
-
6: 'viseme_I',
|
|
25
|
-
7: 'viseme_U',
|
|
26
|
-
8: 'viseme_O',
|
|
27
|
-
9: 'viseme_aa',
|
|
28
|
-
10: 'viseme_O',
|
|
29
|
-
11: 'viseme_aa',
|
|
30
|
-
12: 'viseme_CH',
|
|
31
|
-
13: 'viseme_RR',
|
|
32
|
-
14: 'viseme_SS',
|
|
33
|
-
15: 'viseme_SS',
|
|
34
|
-
16: 'viseme_CH',
|
|
35
|
-
17: 'viseme_TH',
|
|
36
|
-
18: 'viseme_FF',
|
|
37
|
-
19: 'viseme_DD',
|
|
38
|
-
20: 'viseme_kk',
|
|
39
|
-
21: 'viseme_PP'
|
|
40
|
-
};
|
|
41
|
-
const setMeshRef = (0, react_1.useCallback)((mesh) => {
|
|
42
|
-
meshRef.current = mesh;
|
|
43
|
-
}, []);
|
|
44
|
-
const addVisemeToQueue = (0, react_1.useCallback)((viseme) => {
|
|
45
|
-
visemeQueueRef.current.push(viseme);
|
|
46
|
-
}, []);
|
|
47
|
-
const processVisemeQueue = (0, react_1.useCallback)(() => {
|
|
48
|
-
const azureVisemes = [...visemeQueueRef.current];
|
|
49
|
-
visemeQueueRef.current = [];
|
|
50
|
-
if (azureVisemes.length === 0)
|
|
51
|
-
return [];
|
|
52
|
-
const processedVisemes = azureVisemes.map((currentViseme, i) => {
|
|
53
|
-
const nextViseme = azureVisemes[i + 1];
|
|
54
|
-
const duration = nextViseme
|
|
55
|
-
? (nextViseme.audioOffset - currentViseme.audioOffset) / 10000000
|
|
56
|
-
: DEFAULT_VISEME_DURATION;
|
|
57
|
-
return {
|
|
58
|
-
name: visemeMap[currentViseme.visemeId] || 'viseme_sil',
|
|
59
|
-
duration,
|
|
60
|
-
weight: 1,
|
|
61
|
-
startTime: currentViseme.audioOffset / 10000000
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
setCurrentVisemes(processedVisemes);
|
|
65
|
-
console.log('processedVisemes', processedVisemes, meshRef.current);
|
|
66
|
-
startTimeRef.current = performance.now();
|
|
67
|
-
if (animationFrameRef.current === null) {
|
|
68
|
-
animationFrameRef.current = requestAnimationFrame(animate);
|
|
69
|
-
}
|
|
70
|
-
return processedVisemes;
|
|
71
|
-
}, []);
|
|
72
|
-
const clearVisemes = (0, react_1.useCallback)(() => {
|
|
73
|
-
var _a, _b;
|
|
74
|
-
setCurrentVisemes([]);
|
|
75
|
-
visemeQueueRef.current = [];
|
|
76
|
-
if (animationFrameRef.current !== null) {
|
|
77
|
-
cancelAnimationFrame(animationFrameRef.current);
|
|
78
|
-
animationFrameRef.current = null;
|
|
79
|
-
}
|
|
80
|
-
if (((_a = meshRef.current) === null || _a === void 0 ? void 0 : _a.morphTargetDictionary) && ((_b = meshRef.current) === null || _b === void 0 ? void 0 : _b.morphTargetInfluences)) {
|
|
81
|
-
Object.values(meshRef.current.morphTargetDictionary).forEach((index) => {
|
|
82
|
-
if (typeof index === 'number') {
|
|
83
|
-
meshRef.current.morphTargetInfluences[index] = 0;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
currentVisemeWeightRef.current = {};
|
|
88
|
-
}, []);
|
|
89
|
-
const getCurrentViseme = (0, react_1.useCallback)((elapsedTime) => {
|
|
90
|
-
return currentVisemes.find((viseme, index) => {
|
|
91
|
-
const nextViseme = currentVisemes[index + 1];
|
|
92
|
-
return elapsedTime >= viseme.startTime && (!nextViseme || elapsedTime < nextViseme.startTime);
|
|
93
|
-
});
|
|
94
|
-
}, [currentVisemes]);
|
|
95
|
-
const applyViseme = (0, react_1.useCallback)((viseme, elapsedTime) => {
|
|
96
|
-
var _a, _b, _c;
|
|
97
|
-
if (!meshRef.current)
|
|
98
|
-
return;
|
|
99
|
-
const visemeProgress = Math.min((elapsedTime - viseme.startTime) / viseme.duration, 1);
|
|
100
|
-
const targetWeight = Math.sin(visemeProgress * Math.PI) * viseme.weight;
|
|
101
|
-
if (!currentVisemeWeightRef.current[viseme.name]) {
|
|
102
|
-
currentVisemeWeightRef.current[viseme.name] = 0;
|
|
103
|
-
}
|
|
104
|
-
currentVisemeWeightRef.current[viseme.name] = lerp(currentVisemeWeightRef.current[viseme.name], targetWeight, VISEME_SMOOTHING);
|
|
105
|
-
const visemeIndex = (_b = (_a = meshRef.current) === null || _a === void 0 ? void 0 : _a.morphTargetDictionary) === null || _b === void 0 ? void 0 : _b[viseme.name];
|
|
106
|
-
if (typeof visemeIndex === 'number' && ((_c = meshRef.current) === null || _c === void 0 ? void 0 : _c.morphTargetInfluences)) {
|
|
107
|
-
meshRef.current.morphTargetInfluences[visemeIndex] = currentVisemeWeightRef.current[viseme.name];
|
|
108
|
-
}
|
|
109
|
-
}, []);
|
|
110
|
-
const animate = (0, react_1.useCallback)((time) => {
|
|
111
|
-
if (startTimeRef.current === null) {
|
|
112
|
-
startTimeRef.current = time;
|
|
113
|
-
}
|
|
114
|
-
const elapsedTime = (time - startTimeRef.current) / 1000;
|
|
115
|
-
const currentViseme = getCurrentViseme(elapsedTime);
|
|
116
|
-
if (currentViseme) {
|
|
117
|
-
applyViseme(currentViseme, elapsedTime);
|
|
118
|
-
}
|
|
119
|
-
if (currentVisemes.length > 0 && elapsedTime < currentVisemes[currentVisemes.length - 1].startTime + currentVisemes[currentVisemes.length - 1].duration) {
|
|
120
|
-
animationFrameRef.current = requestAnimationFrame(animate);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
clearVisemes();
|
|
124
|
-
}
|
|
125
|
-
}, [getCurrentViseme, applyViseme, currentVisemes, clearVisemes]);
|
|
126
|
-
(0, react_1.useEffect)(() => {
|
|
127
|
-
return () => {
|
|
128
|
-
if (animationFrameRef.current !== null) {
|
|
129
|
-
cancelAnimationFrame(animationFrameRef.current);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}, []);
|
|
133
|
-
return {
|
|
134
|
-
addVisemeToQueue,
|
|
135
|
-
processVisemeQueue,
|
|
136
|
-
clearVisemes,
|
|
137
|
-
setMeshRef
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
exports.useViseme = useViseme;
|
|
141
|
-
//# sourceMappingURL=useViseme.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useViseme.js","sourceRoot":"","sources":["../../../../../src/components/Avatar/AvatarView/utils/useViseme.ts"],"names":[],"mappings":";;;AAAA,iCAAiE;AAejE,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,KAAa,EAAU,EAAE;IACjE,OAAO,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC;AAC3C,CAAC,CAAC;AAEK,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAoB,EAAE,CAAC,CAAC;IAC5E,MAAM,cAAc,GAAG,IAAA,cAAM,EAAgB,EAAE,CAAC,CAAC;IACjD,MAAM,iBAAiB,GAAG,IAAA,cAAM,EAAgB,IAAI,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG,IAAA,cAAM,EAAgB,IAAI,CAAC,CAAC;IACjD,MAAM,sBAAsB,GAAG,IAAA,cAAM,EAA4B,EAAE,CAAC,CAAC;IACrE,MAAM,OAAO,GAAG,IAAA,cAAM,EAAqB,IAAI,CAAC,CAAC;IAEjD,MAAM,SAAS,GAA8B;QAC3C,CAAC,EAAE,YAAY;QACf,CAAC,EAAE,WAAW;QACd,CAAC,EAAE,WAAW;QACd,CAAC,EAAE,UAAU;QACb,CAAC,EAAE,UAAU;QACb,CAAC,EAAE,UAAU;QACb,CAAC,EAAE,UAAU;QACb,CAAC,EAAE,UAAU;QACb,CAAC,EAAE,UAAU;QACb,CAAC,EAAE,WAAW;QACd,EAAE,EAAE,UAAU;QACd,EAAE,EAAE,WAAW;QACf,EAAE,EAAE,WAAW;QACf,EAAE,EAAE,WAAW;QACf,EAAE,EAAE,WAAW;QACf,EAAE,EAAE,W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JpB"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SkinnedMesh } from 'three';
|
|
3
|
-
type AzureViseme = {
|
|
4
|
-
visemeId: number;
|
|
5
|
-
audioOffset: number;
|
|
6
|
-
};
|
|
7
|
-
type ProcessedViseme = {
|
|
8
|
-
name: string;
|
|
9
|
-
duration: number;
|
|
10
|
-
weight: number;
|
|
11
|
-
startTime: number;
|
|
12
|
-
};
|
|
13
|
-
type VisemeContextType = {
|
|
14
|
-
addVisemeToQueue: (viseme: AzureViseme) => void;
|
|
15
|
-
processVisemeQueue: () => ProcessedViseme[];
|
|
16
|
-
clearVisemes: () => void;
|
|
17
|
-
setMeshRef: (mesh: SkinnedMesh | null) => void;
|
|
18
|
-
};
|
|
19
|
-
export declare const VisemeContext: React.Context<VisemeContextType>;
|
|
20
|
-
export declare const VisemeProvider: React.FC<{
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
}>;
|
|
23
|
-
export declare const useViseme: () => VisemeContextType;
|
|
24
|
-
export {};
|