@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sage-rsc/talking-head-react",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "description": "A reusable React component for 3D talking avatars with lip-sync and text-to-speech",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -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 (avatarRef.current && avatarRef.current.isReady && currentLesson?.avatar_script) {
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(currentLesson.avatar_script, {
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 (autoStart && currentLesson?.avatar_script) {
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();