@sage-rsc/talking-head-react 1.0.26 → 1.0.27
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/dist/{fbxAnimationLoader-BEp5N4LW.js → fbxAnimationLoader-BndnRQYi.js} +1 -1
- package/dist/{fbxAnimationLoader-DYwX3TQf.cjs → fbxAnimationLoader-BoEg8dON.cjs} +1 -1
- package/dist/{index-BAyfuKmk.cjs → index-COqTUp83.cjs} +2 -2
- package/dist/{index-R68Q6EcC.js → index-DPiBXfzj.js} +143 -115
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/CurriculumLearning.jsx +61 -9
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-COqTUp83.cjs");exports.CurriculumLearning=i.CurriculumLearning;exports.TalkingHeadAvatar=i.TalkingHeadAvatar;exports.TalkingHeadComponent=i.TalkingHeadComponent;exports.animations=i.animations;exports.getActiveTTSConfig=i.getActiveTTSConfig;exports.getAnimation=i.getAnimation;exports.getVoiceOptions=i.getVoiceOptions;exports.hasAnimation=i.hasAnimation;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -135,18 +135,55 @@ const CurriculumLearning = forwardRef(({
|
|
|
135
135
|
percentage: percentage
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
+
// Trigger custom action for lesson completion
|
|
139
|
+
callbacksRef.current.onCustomAction({
|
|
140
|
+
type: 'lessonComplete',
|
|
141
|
+
moduleIndex: stateRef.current.currentModuleIndex,
|
|
142
|
+
lessonIndex: stateRef.current.currentLessonIndex,
|
|
143
|
+
score: stateRef.current.score,
|
|
144
|
+
totalQuestions: stateRef.current.totalQuestions,
|
|
145
|
+
percentage: percentage
|
|
146
|
+
});
|
|
147
|
+
|
|
138
148
|
if (avatarRef.current) {
|
|
139
149
|
avatarRef.current.setMood("happy");
|
|
140
150
|
if (animations.lessonComplete) {
|
|
141
151
|
try {
|
|
142
152
|
avatarRef.current.playAnimation(animations.lessonComplete, true);
|
|
143
|
-
|
|
153
|
+
} catch (error) {
|
|
144
154
|
avatarRef.current.playCelebration();
|
|
145
155
|
}
|
|
146
156
|
}
|
|
147
|
-
|
|
157
|
+
|
|
158
|
+
// Check if there's a next lesson available
|
|
159
|
+
const currentModule = curriculum.modules[stateRef.current.currentModuleIndex];
|
|
160
|
+
const hasNextLesson = stateRef.current.currentLessonIndex < (currentModule?.lessons?.length || 0) - 1;
|
|
161
|
+
|
|
162
|
+
if (hasNextLesson) {
|
|
163
|
+
// Wait for speech to finish, then automatically move to next lesson
|
|
164
|
+
avatarRef.current.speakText(feedbackMessage, {
|
|
165
|
+
lipsyncLang: defaultAvatarConfig.lipsyncLang,
|
|
166
|
+
onSpeechEnd: () => {
|
|
167
|
+
// Add a small delay after speech ends for natural flow
|
|
168
|
+
setTimeout(() => {
|
|
169
|
+
nextLesson();
|
|
170
|
+
}, 1000);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
// This is the last lesson, complete curriculum instead
|
|
175
|
+
avatarRef.current.speakText(feedbackMessage, {
|
|
176
|
+
lipsyncLang: defaultAvatarConfig.lipsyncLang,
|
|
177
|
+
onSpeechEnd: () => {
|
|
178
|
+
// Add a small delay after speech ends for natural flow
|
|
179
|
+
setTimeout(() => {
|
|
180
|
+
completeCurriculum();
|
|
181
|
+
}, 1000);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
148
185
|
}
|
|
149
|
-
}, [animations.lessonComplete, defaultAvatarConfig]);
|
|
186
|
+
}, [animations.lessonComplete, curriculum, nextLesson, completeCurriculum, defaultAvatarConfig]);
|
|
150
187
|
|
|
151
188
|
// Complete entire curriculum
|
|
152
189
|
const completeCurriculum = useCallback(() => {
|
|
@@ -246,7 +283,7 @@ const CurriculumLearning = forwardRef(({
|
|
|
246
283
|
if (animations.nextQuestion) {
|
|
247
284
|
try {
|
|
248
285
|
avatarRef.current.playAnimation(animations.nextQuestion, true);
|
|
249
|
-
|
|
286
|
+
} catch (error) {
|
|
250
287
|
console.warn('Failed to play nextQuestion animation:', error);
|
|
251
288
|
}
|
|
252
289
|
}
|
|
@@ -282,16 +319,31 @@ const CurriculumLearning = forwardRef(({
|
|
|
282
319
|
stateRef.current.currentLessonIndex += 1;
|
|
283
320
|
stateRef.current.currentQuestionIndex = 0;
|
|
284
321
|
stateRef.current.lessonCompleted = false;
|
|
322
|
+
stateRef.current.isQuestionMode = false;
|
|
323
|
+
stateRef.current.isTeaching = false;
|
|
285
324
|
stateRef.current.score = 0;
|
|
286
325
|
stateRef.current.totalQuestions = 0;
|
|
287
326
|
|
|
327
|
+
// Clear current question in UI
|
|
328
|
+
callbacksRef.current.onCustomAction({
|
|
329
|
+
type: 'lessonStart',
|
|
330
|
+
moduleIndex: stateRef.current.currentModuleIndex,
|
|
331
|
+
lessonIndex: stateRef.current.currentLessonIndex
|
|
332
|
+
});
|
|
333
|
+
|
|
288
334
|
if (avatarRef.current) {
|
|
289
|
-
|
|
335
|
+
avatarRef.current.setMood("happy");
|
|
336
|
+
avatarRef.current.setBodyMovement("idle");
|
|
337
|
+
|
|
338
|
+
// Automatically start teaching the next lesson after a brief pause
|
|
339
|
+
setTimeout(() => {
|
|
340
|
+
startTeaching();
|
|
341
|
+
}, 500);
|
|
290
342
|
}
|
|
291
343
|
} else {
|
|
292
344
|
completeCurriculum();
|
|
293
345
|
}
|
|
294
|
-
}, [curriculum, completeCurriculum,
|
|
346
|
+
}, [curriculum, completeCurriculum, startTeaching]);
|
|
295
347
|
|
|
296
348
|
// Start teaching the lesson
|
|
297
349
|
const startTeaching = useCallback(() => {
|
|
@@ -365,9 +417,9 @@ const CurriculumLearning = forwardRef(({
|
|
|
365
417
|
|
|
366
418
|
if (avatarRef.current) {
|
|
367
419
|
if (isCorrect) {
|
|
368
|
-
|
|
420
|
+
avatarRef.current.setMood("happy");
|
|
369
421
|
if (animations.correct) {
|
|
370
|
-
|
|
422
|
+
try {
|
|
371
423
|
avatarRef.current.playReaction("happy");
|
|
372
424
|
} catch (error) {
|
|
373
425
|
avatarRef.current.setBodyMovement("happy");
|
|
@@ -388,7 +440,7 @@ const CurriculumLearning = forwardRef(({
|
|
|
388
440
|
}, 500);
|
|
389
441
|
}
|
|
390
442
|
});
|
|
391
|
-
|
|
443
|
+
} else {
|
|
392
444
|
avatarRef.current.setMood("sad");
|
|
393
445
|
if (animations.incorrect) {
|
|
394
446
|
try {
|