コード例 #1
0
        private Gesture transformGesture(KeyFramedGesture gesture, float duration, float intensity)
        {
            List <Frame> frames = new List <Frame>();

            for (int i = 0; i < gesture.keyFrameTimes.Count; i++)
            {
                Dictionary <string, dynamic> parameters = new Dictionary <string, dynamic>();

                foreach (var kfParam in gesture.frames)
                {
                    if (i > 0)
                    {
                        //Check if the previous keyframe was the same. If so there is no need to add the parameter.
                        if (kfParam.keyFrameValues[i - 1] == kfParam.keyFrameValues[i])
                        {
                            continue;
                        }
                    }
                    parameters.Add(kfParam.param.ToString(), kfParam.keyFrameValues[i] * intensity);
                }

                frames.Add(new Frame(true, new List <float> {
                    gesture.keyFrameTimes[i] * duration
                }, parameters));
            }
            Gesture transformedGesture = new Gesture(gesture.name, frames);

            return(transformedGesture);
        }
コード例 #2
0
        /// <summary>
        ///Sends a text speech event to the synthesizer, adds an utterance to the speech queue and blocks the current thread until the speech is over
        /// </summary>
        /// <param name="text"> The text to speak </param>
        public void SayBlock(string toSay, KeyFramedGesture mood = null, Dictionary <string, string> keyValuePairs = null)
        {
            Say(toSay, mood, keyValuePairs);

            while (inMiddleOfSpeaking)
            {
                Thread.Sleep(50);
            }
        }
コード例 #3
0
        public void ChangeParameter(PARAMS parameter, float duration, float intensity, int priority = 0)
        {
            // Duration and priority will be set to one
            KeyFramedGesture changeParam = new KeyFramedGesture("Change " + parameter.ToString(), new List <float> {
                1
            },
                                                                new List <keyFramedPARAM> {
                new keyFramedPARAM(parameter, new List <float> {
                    1
                })
            });

            //Call the gesture with the right duration and intensity
            Gesture(changeParam, priority, duration, intensity);
        }
コード例 #4
0
        /// <summary>
        ///Sends a text speech event to the synthesizer and adds an utterance to the speech queue
        /// </summary>
        public void Say(string text, KeyFramedGesture mood = null, Dictionary <string, string> keyValuePairs = null)
        {
            if (inMiddleOfSpeaking)
            {
                SayQueue.Enqueue(new Tuple <string, KeyFramedGesture, Dictionary <string, string> >(text, mood, keyValuePairs));
            }
            else
            {
                if (mood != null)
                {
                    Gesture(mood);
                    CurrentMood = mood.name;
                }
                else
                {
                    CurrentMood = null;
                }

                //midtextaction are divided by | if there is such separator we should process them
                var midTextActions = text.Split('|');

                if (midTextActions.Count() > 1)
                {
                    if (keyValuePairs != null)
                    {
                        text = replaceVariables(text, keyValuePairs);
                    }
                    FillMidTextActions(text);
                    text = Regex.Replace(text, @"\|.*?\|", String.Empty);
                    Say(text);
                    SentSayEvent?.Invoke(text);
                }
                else
                {
                    Say(text);
                    SentSayEvent?.Invoke(text);
                }
            }
        }
コード例 #5
0
        public void SayDialogAct(string dialogAct, Dictionary <string, string> keyValuePairs = null)
        {
            Behavior behaviorToSay = dialogActs?.getRandomBehavior(dialogAct);

            if (behaviorToSay == null)
            {
                return;
            }

            KeyFramedGesture mood = null;

            if (GESTURES.customGestures.ContainsKey(behaviorToSay.emotion))
            {
                mood = GESTURES.customGestures[behaviorToSay.emotion];
            }

            if (behaviorToSay.customEvent != "")
            {
                CustomEvent?.Invoke(behaviorToSay.customEvent);
            }

            Say(behaviorToSay.text, mood, keyValuePairs);
        }
コード例 #6
0
 internal void GestureCustom(KeyFramedGesture gesture, int priority = 0, float duration = 0, float intensity = 0)
 {
     SendEvent(new ActionEvents.PerformCustomGesture(transformGesture(gesture, duration, intensity), priority));
 }
コード例 #7
0
 /// <summary>
 /// Makes the agent perform a specific gesture.
 /// </summary>
 /// <param name="gesture"> The name of the gesture </param>
 public void Gesture(KeyFramedGesture gesture, int priority = 0, float duration = 1, float intensity = 1)
 {
     GestureCustom(gesture, priority, duration, intensity);
 }