@sage-rsc/talking-head-react 1.0.35 → 1.0.37
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/index.cjs +2 -2
- package/dist/index.js +194 -188
- package/package.json +1 -1
- package/src/components/CurriculumLearning.jsx +34 -17
- package/src/lib/talkinghead.mjs +2 -2
package/package.json
CHANGED
|
@@ -219,7 +219,7 @@ const CurriculumLearning = forwardRef(({
|
|
|
219
219
|
if (nextLessonRef.current) {
|
|
220
220
|
nextLessonRef.current();
|
|
221
221
|
}
|
|
222
|
-
},
|
|
222
|
+
}, 300);
|
|
223
223
|
}
|
|
224
224
|
});
|
|
225
225
|
} else {
|
|
@@ -232,7 +232,7 @@ const CurriculumLearning = forwardRef(({
|
|
|
232
232
|
if (completeCurriculumRef.current) {
|
|
233
233
|
completeCurriculumRef.current();
|
|
234
234
|
}
|
|
235
|
-
},
|
|
235
|
+
}, 300);
|
|
236
236
|
}
|
|
237
237
|
});
|
|
238
238
|
}
|
|
@@ -405,12 +405,12 @@ const CurriculumLearning = forwardRef(({
|
|
|
405
405
|
avatarRef.current.setMood("happy");
|
|
406
406
|
avatarRef.current.setBodyMovement("idle");
|
|
407
407
|
|
|
408
|
-
|
|
408
|
+
// Automatically start teaching the next lesson after a brief pause
|
|
409
409
|
setTimeout(() => {
|
|
410
410
|
if (startTeachingRef.current) {
|
|
411
411
|
startTeachingRef.current();
|
|
412
412
|
}
|
|
413
|
-
},
|
|
413
|
+
}, 300);
|
|
414
414
|
}
|
|
415
415
|
} else {
|
|
416
416
|
// No more lessons in current module - check if there's a next module
|
|
@@ -439,11 +439,11 @@ const CurriculumLearning = forwardRef(({
|
|
|
439
439
|
avatarRef.current.setBodyMovement("idle");
|
|
440
440
|
|
|
441
441
|
// Automatically start teaching the next lesson after a brief pause
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
442
|
+
setTimeout(() => {
|
|
443
|
+
if (startTeachingRef.current) {
|
|
444
|
+
startTeachingRef.current();
|
|
445
|
+
}
|
|
446
|
+
}, 300);
|
|
447
447
|
}
|
|
448
448
|
} else {
|
|
449
449
|
// No more modules or lessons - complete curriculum
|
|
@@ -457,7 +457,22 @@ const CurriculumLearning = forwardRef(({
|
|
|
457
457
|
// Start teaching the lesson
|
|
458
458
|
const startTeaching = useCallback(() => {
|
|
459
459
|
const currentLesson = getCurrentLesson();
|
|
460
|
-
if
|
|
460
|
+
// Combine body and avatar_script if both exist, or use whichever is available
|
|
461
|
+
// If both exist, combine them with a period and space for natural flow
|
|
462
|
+
let teachingText = null;
|
|
463
|
+
if (currentLesson?.avatar_script && currentLesson?.body) {
|
|
464
|
+
// Both exist - combine them with proper punctuation
|
|
465
|
+
const script = currentLesson.avatar_script.trim();
|
|
466
|
+
const body = currentLesson.body.trim();
|
|
467
|
+
// Add period if script doesn't end with punctuation
|
|
468
|
+
const separator = script.match(/[.!?]$/) ? ' ' : '. ';
|
|
469
|
+
teachingText = `${script}${separator}${body}`;
|
|
470
|
+
} else {
|
|
471
|
+
// Use whichever is available
|
|
472
|
+
teachingText = currentLesson?.avatar_script || currentLesson?.body || null;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if (avatarRef.current && avatarRef.current.isReady && teachingText) {
|
|
461
476
|
stateRef.current.isTeaching = true;
|
|
462
477
|
stateRef.current.isQuestionMode = false;
|
|
463
478
|
|
|
@@ -495,9 +510,9 @@ const CurriculumLearning = forwardRef(({
|
|
|
495
510
|
});
|
|
496
511
|
|
|
497
512
|
// Wait for avatar to finish speaking before moving to questions
|
|
498
|
-
avatarRef.current.speakText(
|
|
513
|
+
avatarRef.current.speakText(teachingText, {
|
|
499
514
|
lipsyncLang: config.lipsyncLang,
|
|
500
|
-
|
|
515
|
+
onSpeechEnd: () => {
|
|
501
516
|
stateRef.current.isTeaching = false;
|
|
502
517
|
// Add a small delay after speech ends for natural flow
|
|
503
518
|
setTimeout(() => {
|
|
@@ -512,7 +527,7 @@ const CurriculumLearning = forwardRef(({
|
|
|
512
527
|
completeLessonRef.current();
|
|
513
528
|
}
|
|
514
529
|
}
|
|
515
|
-
},
|
|
530
|
+
}, 200);
|
|
516
531
|
}
|
|
517
532
|
});
|
|
518
533
|
}
|
|
@@ -562,7 +577,7 @@ const CurriculumLearning = forwardRef(({
|
|
|
562
577
|
if (nextQuestionRef.current) {
|
|
563
578
|
nextQuestionRef.current();
|
|
564
579
|
}
|
|
565
|
-
},
|
|
580
|
+
}, 200);
|
|
566
581
|
}
|
|
567
582
|
});
|
|
568
583
|
} else {
|
|
@@ -590,7 +605,7 @@ const CurriculumLearning = forwardRef(({
|
|
|
590
605
|
if (nextQuestionRef.current) {
|
|
591
606
|
nextQuestionRef.current();
|
|
592
607
|
}
|
|
593
|
-
},
|
|
608
|
+
}, 200);
|
|
594
609
|
}
|
|
595
610
|
});
|
|
596
611
|
}
|
|
@@ -663,12 +678,14 @@ const CurriculumLearning = forwardRef(({
|
|
|
663
678
|
const handleAvatarReady = useCallback((talkingHead) => {
|
|
664
679
|
console.log('Avatar is ready!', talkingHead);
|
|
665
680
|
const currentLesson = getCurrentLesson();
|
|
666
|
-
if (
|
|
681
|
+
// Check if there's teaching content (either avatar_script or body)
|
|
682
|
+
const hasTeachingContent = currentLesson?.avatar_script || currentLesson?.body;
|
|
683
|
+
if (autoStart && hasTeachingContent) {
|
|
667
684
|
setTimeout(() => {
|
|
668
685
|
if (startTeachingRef.current) {
|
|
669
686
|
startTeachingRef.current();
|
|
670
687
|
}
|
|
671
|
-
},
|
|
688
|
+
}, 500);
|
|
672
689
|
}
|
|
673
690
|
}, [autoStart, getCurrentLesson]);
|
|
674
691
|
|
package/src/lib/talkinghead.mjs
CHANGED
|
@@ -168,9 +168,9 @@ class TalkingHead {
|
|
|
168
168
|
cameraPanEnable: false,
|
|
169
169
|
cameraZoomEnable: false,
|
|
170
170
|
lightAmbientColor: 0xffffff,
|
|
171
|
-
lightAmbientIntensity: 2,
|
|
171
|
+
lightAmbientIntensity: 1.2,
|
|
172
172
|
lightDirectColor: 0x8888aa,
|
|
173
|
-
lightDirectIntensity:
|
|
173
|
+
lightDirectIntensity: 18,
|
|
174
174
|
lightDirectPhi: 1,
|
|
175
175
|
lightDirectTheta: 2,
|
|
176
176
|
lightSpotIntensity: 0,
|