[Tizen.AIAvatar] Fix Svace issue (#6046)
authorhuiyu <35286162+huiyueun@users.noreply.github.com>
Wed, 3 Apr 2024 01:24:05 +0000 (10:24 +0900)
committerGitHub <noreply@github.com>
Wed, 3 Apr 2024 01:24:05 +0000 (10:24 +0900)
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.AIAvatar/src/internal/Common/RestClient.cs
src/Tizen.AIAvatar/src/internal/Uix/TTSLipSyncer.cs
src/Tizen.AIAvatar/src/public/Avatar/Animations/AnimationModule/BlendShapePlayer.cs
src/Tizen.AIAvatar/src/public/Avatar/Animations/AnimationModule/LipSyncer.cs
src/Tizen.AIAvatar/src/public/Avatar/Animations/AnimationModule/MotionPlayer.cs
src/Tizen.AIAvatar/src/public/Avatar/Avatar.cs
src/Tizen.AIAvatar/src/public/Avatar/Controller/AvatarTTS.cs

index 7d11291..0ee81eb 100644 (file)
@@ -46,6 +46,7 @@ namespace Tizen.AIAvatar
             }
 
             HttpResponseMessage response = await client.SendAsync(request);
+            request?.Dispose();
             return await HandleResponse(response);
         }
 
index 1049463..2c471a1 100644 (file)
@@ -58,10 +58,9 @@ namespace Tizen.AIAvatar
         private AsyncLipSyncer lipSyncer;
 
 
-        internal TTSLipSyncer(Avatar avatar)
+        internal TTSLipSyncer(AsyncLipSyncer lipSyncer)
         {
-            currentAvatar = avatar; 
-            lipSyncer = (currentAvatar.AvatarAnimator.GetAnimationModule(AnimationModuleType.LipSyncer) as AsyncLipSyncer);
+            this.lipSyncer = lipSyncer;
             InitTts();
         }
 
index 92906a0..e2beca4 100644 (file)
@@ -44,6 +44,9 @@ namespace Tizen.AIAvatar
         }
 
         [EditorBrowsable(EditorBrowsableState.Never)]
+        public AsyncLipSyncer LipSyncer => lipSyncer;
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public void SetBlinkAnimation(Animation blinkerAnimation)
         {
             animationModules[AnimationModuleType.EyeBlinker].Init(blinkerAnimation);
index 510be5c..d8b4121 100644 (file)
@@ -123,25 +123,23 @@ namespace Tizen.AIAvatar
 
         private void PlayLipSync(byte[] audio)
         {
-
-            Tizen.Log.Error("MYLOG", "Play Lip sync : " + audio.Length);
-            if(audio == null)
+            if (audio == null)
             {
-                Tizen.Log.Error("MYLOG", "audi data is null");
+                Tizen.Log.Error(LogTag, "audi data is null");
+                return;
             }
 
             DestroyLipAnimation();
             var lipAnimation = CreateLipAnimation(audio, CurrentAudioOptions.SampleRate);
             if (lipAnimation != null)
             {
-                Tizen.Log.Error("MYLOG", "lipAnimation is not null");
                 ResetLipAnimation(lipAnimation);
                 PlayLipAnimation();
             }
             else
             {
 
-                Tizen.Log.Error("MYLOG", "lipAnimation is null");
+                Tizen.Log.Error(LogTag, "lipAnimation is null");
             }
             audioPlayer.Play(audio);
             CurrentMotionState = AvatarMotionState.Playing;
index 9797aff..ce101c4 100644 (file)
@@ -19,6 +19,8 @@ using System.ComponentModel;
 using Tizen.NUI;
 using Tizen.NUI.Scene3D;
 
+using static Tizen.AIAvatar.AIAvatar;
+
 namespace Tizen.AIAvatar
 {
     internal class MotionPlayer
@@ -34,14 +36,19 @@ namespace Tizen.AIAvatar
         /// <summary>
         /// Play avatar animation by AnimationInfo
         /// </summary>
-        /// <param name="index">index of default avatar animations</param>
         [EditorBrowsable(EditorBrowsableState.Never)]
         internal void PlayAnimation(Animation motionAnimation, int duration = 3000, bool isLooping = false, int loopCount = 1)
         {
             ResetAnimations();
-
-            MotionAnimation = this.motionAnimation;
-            MotionAnimation.Play();
+            if (motionAnimation != null)
+            {
+                MotionAnimation = motionAnimation;
+                MotionAnimation?.Play();
+            }
+            else
+            {
+                Tizen.Log.Error(LogTag, "motionAnimation is null");
+            }
         }
 
         /// <summary>
index 10d6ea0..f1ffab8 100644 (file)
@@ -110,12 +110,29 @@ namespace Tizen.AIAvatar
         [EditorBrowsable(EditorBrowsableState.Never)]
         private void PlayAnimation(AnimationInfo animationInfo, int duration = 3000, bool isLooping = false, int loopCount = 1)
         {
+            if (animationInfo == null)
+            {
+                Tizen.Log.Error(LogTag, "animationInfo is null");
+                return;
+            }
+            if (animationInfo.MotionData == null)
+            {
+                Tizen.Log.Error(LogTag, "animationInfo.MotionData is null");
+                return;
+            }
             var motionAnimation = GenerateMotionDataAnimation(animationInfo.MotionData);
-            motionAnimation.Duration = duration;
-            motionAnimation.Looping = isLooping;
-            motionAnimation.LoopCount = loopCount;
-            motionAnimation.BlendPoint = 0.2f;
-            motionPlayer.PlayAnimation(motionAnimation);
+            if (motionAnimation != null)
+            {
+                motionAnimation.Duration = duration;
+                motionAnimation.Looping = isLooping;
+                motionAnimation.LoopCount = loopCount;
+                motionAnimation.BlendPoint = 0.2f;
+                motionPlayer.PlayAnimation(motionAnimation);
+            }
+            else
+            {
+                Tizen.Log.Error(LogTag, "motionAnimation is null");
+            }
         }
 
         /// <summary>
@@ -126,13 +143,24 @@ namespace Tizen.AIAvatar
         private void PlayAnimation(MotionData motionData, int duration = 3000, bool isLooping = false, int loopCount = 1)
         {
 
+            if (motionData == null)
+            {
+                Tizen.Log.Error(LogTag, "motionData is null");
+                return;
+            }
             var motionAnimation = GenerateMotionDataAnimation(motionData);
-            motionAnimation.Duration = duration;
-            motionAnimation.Looping = isLooping;
-            motionAnimation.LoopCount = loopCount;
-            motionAnimation.BlendPoint = 0.2f;
-
-            motionPlayer.PlayAnimation(motionAnimation);
+            if (motionAnimation != null)
+            {
+                motionAnimation.Duration = duration;
+                motionAnimation.Looping = isLooping;
+                motionAnimation.LoopCount = loopCount;
+                motionAnimation.BlendPoint = 0.2f;
+                motionPlayer.PlayAnimation(motionAnimation);
+            }
+            else
+            {
+                Tizen.Log.Error(LogTag, "motionAnimation is null");
+            }
         }
 
         private void PlayAnimation(int index, int duration = 3000, bool isLooping = false, int loopCount = 1)
index 9141fb5..6c5954d 100644 (file)
@@ -81,7 +81,7 @@ namespace Tizen.AIAvatar
             {
                 try
                 {
-                    ttsLipSyncer = new TTSLipSyncer(avatar);
+                    ttsLipSyncer = new TTSLipSyncer(avatar?.AvatarAnimator?.LipSyncer);
                 }
                 catch (Exception e)
                 {