@sage-rsc/talking-head-react 1.0.35 → 1.0.36
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 +185 -179
- package/package.json +1 -1
- package/src/components/CurriculumLearning.jsx +20 -3
package/package.json
CHANGED
|
@@ -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,7 +510,7 @@ 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;
|
|
@@ -663,7 +678,9 @@ 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();
|