/// <summary>
        /// Return any features required by
        /// </summary>
        /// <param name="data"></param>
        /// <param name="module"></param>
        /// <returns></returns>
        public static ClipFeatures GetMissingClipFeatures(LipSyncData data, AutoSyncModule module)
        {
            var          req         = module.GetCompatibilityRequirements();
            ClipFeatures metCriteria = 0;

            if (data.clip)
            {
                metCriteria |= ClipFeatures.AudioClip;
            }

            if (!string.IsNullOrEmpty(data.transcript))
            {
                metCriteria |= ClipFeatures.Transcript;
            }

            if (data.phonemeData != null && data.phonemeData.Length > 0)
            {
                metCriteria |= ClipFeatures.Phonemes;
            }

            if (data.emotionData != null && data.emotionData.Length > 0)
            {
                metCriteria |= ClipFeatures.Emotions;
            }

            if (data.gestureData != null && data.gestureData.Length > 0)
            {
                metCriteria |= ClipFeatures.Gestures;
            }


            // Compare masks
            return((req & metCriteria) ^ req);
        }
Exemple #2
0
        public void RunModuleSafely(AutoSyncModule module, LipSyncData data, ASProcessDelegate callback, bool silent = false)
        {
            if (finalData == null)
            {
                finalData = new ASProcessDelegateData(true, "", ClipFeatures.None);
            }

            if (AutoSyncUtility.CheckIsClipCompatible(data, module))
            {
                if (!silent)
                {
                    if (moduleSequence != null)
                    {
                        EditorUtility.DisplayProgressBar("AutoSync", string.Format("Processing module {0}/{1}. Please Wait.", index + 1, moduleSequence.Length), index + 1f / (float)moduleSequence.Length);
                    }
                    else
                    {
                        EditorUtility.DisplayProgressBar("AutoSync", "Processing module, Please Wait.", 1f);
                    }
                }

                module.Process(data, callback);
            }
            else
            {
                EditorUtility.ClearProgressBar();
                callback.Invoke(data, new ASProcessDelegateData(false, "Module failed compatibility check.", ClipFeatures.None));
                moduleSequence = null;
                finalData      = null;
            }
        }
        public void RunModuleSafely(AutoSyncModule module, LipSyncData data, ASProcessDelegate callback, bool silent = false)
        {
            if (finalData == null)
            {
                finalData = new ASProcessDelegateData(true, "", ClipFeatures.None);
            }

            var missingFeatures = AutoSyncUtility.GetMissingClipFeatures(data, module);

            if (missingFeatures == ClipFeatures.None)
            {
                if (!silent)
                {
                    if (moduleSequence != null)
                    {
                        EditorUtility.DisplayProgressBar("AutoSync", string.Format("Processing module {0}/{1}. Please Wait.", index + 1, moduleSequence.Length), index + 1f / (float)moduleSequence.Length);
                    }
                    else
                    {
                        EditorUtility.DisplayProgressBar("AutoSync", "Processing module, Please Wait.", 1f);
                    }
                }

                module.Process(data, callback);
            }
            else
            {
                EditorUtility.ClearProgressBar();
                callback.Invoke(data, new ASProcessDelegateData(false, string.Format("Failed: Missing {0}. See console for details.", missingFeatures.ToString()), ClipFeatures.None));

                if ((missingFeatures & ClipFeatures.AudioClip) == ClipFeatures.AudioClip)
                {
                    Debug.Log("Missing AudioClip. This module requires an audioclip in order to work. Make sure you've assigned an AudioClip at the top of the Clip Editor before running AutoSync.");
                }

                if ((missingFeatures & ClipFeatures.Emotions) == ClipFeatures.Emotions)
                {
                    Debug.Log("Missing Emotions. This module requires Emotion markers in order to work. You will either need to add some using the Emotions tab of the Clip Editor, or by adding a module first that will create them.");
                }

                if ((missingFeatures & ClipFeatures.Gestures) == ClipFeatures.Gestures)
                {
                    Debug.Log("Missing Gestures. This module requires Gesture markers in order to work. You will either need to add some using the Gestures tab of the Clip Editor, or by adding a module first that will create them.");
                }

                if ((missingFeatures & ClipFeatures.Phonemes) == ClipFeatures.Phonemes)
                {
                    Debug.Log("Missing Phonemes. This module requires Phoneme markers in order to work. You will either need to add some using the Phonemes tab of the Clip Editor, or by adding a module first that will create them.");
                }

                if ((missingFeatures & ClipFeatures.Transcript) == ClipFeatures.Transcript)
                {
                    Debug.Log("Missing Transcript. This module requires a transcript in order to work. The Clip Editor can load one from a text file with the same name as your AudioClip, or you can either add one from Edit>Clip Settings or add a module first that will create them.");
                }

                moduleSequence = null;
                finalData      = null;
            }
        }
Exemple #4
0
        /// <summary>
        /// Check if the supplied LipSyncData clip is compatible with a particular module.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="module"></param>
        /// <returns></returns>
        public static bool CheckIsClipCompatible(LipSyncData data, AutoSyncModule module)
        {
            var          req         = module.GetCompatibilityRequirements();
            ClipFeatures metCriteria = 0;

            if (data.clip)
            {
                metCriteria |= ClipFeatures.AudioClip;
            }

            if (!string.IsNullOrEmpty(data.transcript))
            {
                metCriteria |= ClipFeatures.Transcript;
            }

            if (data.phonemeData != null && data.phonemeData.Length > 0)
            {
                metCriteria |= ClipFeatures.Phonemes;
            }

            if (data.emotionData != null && data.emotionData.Length > 0)
            {
                metCriteria |= ClipFeatures.Emotions;
            }

            if (data.gestureData != null && data.gestureData.Length > 0)
            {
                metCriteria |= ClipFeatures.Gestures;
            }

            // Compare masks
            var isFeatureCompatible = ((req & metCriteria) ^ req) == ClipFeatures.None;

            if (isFeatureCompatible)
            {
                if ((req & ClipFeatures.AudioClip) == ClipFeatures.AudioClip)
                {
                    var outcome = true;

                    return(outcome);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// Check if the supplied LipSyncData clip is compatible with a particular module.
 /// </summary>
 /// <param name="data"></param>
 /// <param name="module"></param>
 /// <returns></returns>
 public static bool CheckIsClipCompatible(LipSyncData data, AutoSyncModule module)
 {
     return(GetMissingClipFeatures(data, module) == ClipFeatures.None);
 }