@sage-rsc/talking-head-react 1.0.53 → 1.0.55
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 +713 -689
- package/package.json +1 -1
- package/src/components/CurriculumLearning.jsx +45 -11
- package/src/lib/talkinghead.mjs +2 -2
package/package.json
CHANGED
|
@@ -284,6 +284,8 @@ const CurriculumLearning = forwardRef(({
|
|
|
284
284
|
stateRef.current.isQuestionMode = true;
|
|
285
285
|
stateRef.current.currentQuestionIndex = 0;
|
|
286
286
|
stateRef.current.totalQuestions = currentLesson?.questions?.length || 0;
|
|
287
|
+
// Reset score when starting questions for a lesson
|
|
288
|
+
stateRef.current.score = 0;
|
|
287
289
|
|
|
288
290
|
// Trigger custom action IMMEDIATELY for UI to show the first question
|
|
289
291
|
const firstQuestion = getCurrentQuestion();
|
|
@@ -293,10 +295,11 @@ const CurriculumLearning = forwardRef(({
|
|
|
293
295
|
type: 'questionStart',
|
|
294
296
|
moduleIndex: stateRef.current.currentModuleIndex,
|
|
295
297
|
lessonIndex: stateRef.current.currentLessonIndex,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
questionIndex: stateRef.current.currentQuestionIndex,
|
|
299
|
+
totalQuestions: stateRef.current.totalQuestions,
|
|
300
|
+
question: firstQuestion,
|
|
301
|
+
score: stateRef.current.score
|
|
302
|
+
});
|
|
300
303
|
}
|
|
301
304
|
|
|
302
305
|
// Function to speak the first question
|
|
@@ -369,7 +372,8 @@ const CurriculumLearning = forwardRef(({
|
|
|
369
372
|
lessonIndex: stateRef.current.currentLessonIndex,
|
|
370
373
|
questionIndex: stateRef.current.currentQuestionIndex,
|
|
371
374
|
totalQuestions: stateRef.current.totalQuestions,
|
|
372
|
-
question: nextQuestionObj
|
|
375
|
+
question: nextQuestionObj,
|
|
376
|
+
score: stateRef.current.score
|
|
373
377
|
});
|
|
374
378
|
}
|
|
375
379
|
|
|
@@ -459,11 +463,18 @@ const CurriculumLearning = forwardRef(({
|
|
|
459
463
|
stateRef.current.score = 0;
|
|
460
464
|
stateRef.current.totalQuestions = 0;
|
|
461
465
|
|
|
466
|
+
// Check if there's a next lesson available after this one
|
|
467
|
+
const currentModuleAfterMove = curriculum.modules[stateRef.current.currentModuleIndex];
|
|
468
|
+
const hasNextLessonInModuleAfterMove = stateRef.current.currentLessonIndex < (currentModuleAfterMove?.lessons?.length || 0) - 1;
|
|
469
|
+
const hasNextModuleAfterMove = stateRef.current.currentModuleIndex < (curriculum.modules?.length || 0) - 1;
|
|
470
|
+
const hasNextLessonAfterMove = hasNextLessonInModuleAfterMove || hasNextModuleAfterMove;
|
|
471
|
+
|
|
462
472
|
// Clear current question in UI and notify parent
|
|
463
473
|
callbacksRef.current.onCustomAction({
|
|
464
474
|
type: 'lessonStart',
|
|
465
475
|
moduleIndex: stateRef.current.currentModuleIndex,
|
|
466
|
-
lessonIndex: stateRef.current.currentLessonIndex
|
|
476
|
+
lessonIndex: stateRef.current.currentLessonIndex,
|
|
477
|
+
hasNextLesson: hasNextLessonAfterMove
|
|
467
478
|
});
|
|
468
479
|
|
|
469
480
|
// Notify parent that lesson has changed - parent decides when to start teaching
|
|
@@ -492,11 +503,18 @@ const CurriculumLearning = forwardRef(({
|
|
|
492
503
|
stateRef.current.score = 0;
|
|
493
504
|
stateRef.current.totalQuestions = 0;
|
|
494
505
|
|
|
506
|
+
// Check if there's a next lesson available after this one
|
|
507
|
+
const currentModuleAfterMove = curriculum.modules[stateRef.current.currentModuleIndex];
|
|
508
|
+
const hasNextLessonInModuleAfterMove = stateRef.current.currentLessonIndex < (currentModuleAfterMove?.lessons?.length || 0) - 1;
|
|
509
|
+
const hasNextModuleAfterMove = stateRef.current.currentModuleIndex < (curriculum.modules?.length || 0) - 1;
|
|
510
|
+
const hasNextLessonAfterMove = hasNextLessonInModuleAfterMove || hasNextModuleAfterMove;
|
|
511
|
+
|
|
495
512
|
// Clear current question in UI and notify parent
|
|
496
513
|
callbacksRef.current.onCustomAction({
|
|
497
514
|
type: 'lessonStart',
|
|
498
515
|
moduleIndex: stateRef.current.currentModuleIndex,
|
|
499
|
-
lessonIndex: stateRef.current.currentLessonIndex
|
|
516
|
+
lessonIndex: stateRef.current.currentLessonIndex,
|
|
517
|
+
hasNextLesson: hasNextLessonAfterMove
|
|
500
518
|
});
|
|
501
519
|
|
|
502
520
|
// Notify parent that lesson has changed - parent decides when to start teaching
|
|
@@ -540,6 +558,9 @@ const CurriculumLearning = forwardRef(({
|
|
|
540
558
|
if (avatarRef.current && avatarRef.current.isReady && teachingText) {
|
|
541
559
|
stateRef.current.isTeaching = true;
|
|
542
560
|
stateRef.current.isQuestionMode = false;
|
|
561
|
+
// Reset score and totalQuestions when starting a new lesson teaching
|
|
562
|
+
stateRef.current.score = 0;
|
|
563
|
+
stateRef.current.totalQuestions = 0;
|
|
543
564
|
|
|
544
565
|
avatarRef.current.setMood("happy");
|
|
545
566
|
|
|
@@ -632,13 +653,17 @@ const CurriculumLearning = forwardRef(({
|
|
|
632
653
|
lipsyncLang: config.lipsyncLang,
|
|
633
654
|
onSpeechEnd: () => {
|
|
634
655
|
// Notify parent that feedback is complete - parent decides next action
|
|
656
|
+
const currentLesson = getCurrentLesson();
|
|
657
|
+
const totalQuestionsInLesson = currentLesson?.questions?.length || 0;
|
|
635
658
|
callbacksRef.current.onCustomAction({
|
|
636
659
|
type: 'answerFeedbackComplete',
|
|
637
660
|
moduleIndex: stateRef.current.currentModuleIndex,
|
|
638
661
|
lessonIndex: stateRef.current.currentLessonIndex,
|
|
639
662
|
questionIndex: stateRef.current.currentQuestionIndex,
|
|
640
663
|
isCorrect: true,
|
|
641
|
-
hasNextQuestion: stateRef.current.currentQuestionIndex <
|
|
664
|
+
hasNextQuestion: stateRef.current.currentQuestionIndex < totalQuestionsInLesson - 1,
|
|
665
|
+
score: stateRef.current.score,
|
|
666
|
+
totalQuestions: stateRef.current.totalQuestions
|
|
642
667
|
});
|
|
643
668
|
}
|
|
644
669
|
});
|
|
@@ -663,26 +688,34 @@ const CurriculumLearning = forwardRef(({
|
|
|
663
688
|
lipsyncLang: config.lipsyncLang,
|
|
664
689
|
onSpeechEnd: () => {
|
|
665
690
|
// Notify parent that feedback is complete - parent decides next action
|
|
691
|
+
const currentLesson = getCurrentLesson();
|
|
692
|
+
const totalQuestionsInLesson = currentLesson?.questions?.length || 0;
|
|
666
693
|
callbacksRef.current.onCustomAction({
|
|
667
694
|
type: 'answerFeedbackComplete',
|
|
668
695
|
moduleIndex: stateRef.current.currentModuleIndex,
|
|
669
696
|
lessonIndex: stateRef.current.currentLessonIndex,
|
|
670
697
|
questionIndex: stateRef.current.currentQuestionIndex,
|
|
671
698
|
isCorrect: false,
|
|
672
|
-
hasNextQuestion: stateRef.current.currentQuestionIndex <
|
|
699
|
+
hasNextQuestion: stateRef.current.currentQuestionIndex < totalQuestionsInLesson - 1,
|
|
700
|
+
score: stateRef.current.score,
|
|
701
|
+
totalQuestions: stateRef.current.totalQuestions
|
|
673
702
|
});
|
|
674
703
|
}
|
|
675
704
|
});
|
|
676
705
|
}
|
|
677
706
|
} else {
|
|
678
707
|
// Avatar not ready - notify parent
|
|
708
|
+
const currentLesson = getCurrentLesson();
|
|
709
|
+
const totalQuestionsInLesson = currentLesson?.questions?.length || 0;
|
|
679
710
|
callbacksRef.current.onCustomAction({
|
|
680
711
|
type: 'answerFeedbackComplete',
|
|
681
712
|
moduleIndex: stateRef.current.currentModuleIndex,
|
|
682
713
|
lessonIndex: stateRef.current.currentLessonIndex,
|
|
683
714
|
questionIndex: stateRef.current.currentQuestionIndex,
|
|
684
715
|
isCorrect: isCorrect,
|
|
685
|
-
hasNextQuestion: stateRef.current.currentQuestionIndex <
|
|
716
|
+
hasNextQuestion: stateRef.current.currentQuestionIndex < totalQuestionsInLesson - 1,
|
|
717
|
+
score: stateRef.current.score,
|
|
718
|
+
totalQuestions: stateRef.current.totalQuestions,
|
|
686
719
|
avatarNotReady: true
|
|
687
720
|
});
|
|
688
721
|
}
|
|
@@ -746,7 +779,8 @@ const CurriculumLearning = forwardRef(({
|
|
|
746
779
|
lessonIndex: stateRef.current.currentLessonIndex,
|
|
747
780
|
questionIndex: stateRef.current.currentQuestionIndex,
|
|
748
781
|
totalQuestions: stateRef.current.totalQuestions,
|
|
749
|
-
question: prevQuestionObj
|
|
782
|
+
question: prevQuestionObj,
|
|
783
|
+
score: stateRef.current.score
|
|
750
784
|
});
|
|
751
785
|
}
|
|
752
786
|
|
package/src/lib/talkinghead.mjs
CHANGED
|
@@ -146,8 +146,8 @@ class TalkingHead {
|
|
|
146
146
|
ttsVoice: "fi-FI-Standard-A",
|
|
147
147
|
ttsRate: 1,
|
|
148
148
|
ttsPitch: 0,
|
|
149
|
-
ttsVolume: 0,
|
|
150
|
-
mixerGainSpeech:
|
|
149
|
+
ttsVolume: 0.3,
|
|
150
|
+
mixerGainSpeech: 1.2,
|
|
151
151
|
mixerGainBackground: null,
|
|
152
152
|
lipsyncLang: 'fi',
|
|
153
153
|
lipsyncModules: ['fi','en','lt'],
|