/// <summary> /// Spawns cursor for the Main Camera /// </summary> // private void CreateLabel() // { // // Create a sphere as new cursor // GameObject newLabel = new GameObject(); // // // Attach the label to the Main Camera // newLabel.transform.parent = gameObject.transform; // // // Resize and position the new cursor // newLabel.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f); // newLabel.transform.position = new Vector3(0f, 3f, 60f); // // // Creating the text of the Label // labelText = newLabel.AddComponent<TextMesh>(); // labelText.anchor = TextAnchor.MiddleCenter; // labelText.alignment = TextAlignment.Center; // labelText.tabSize = 4; // labelText.fontSize = 50; // labelText.text = "."; // } public void PlayTextToSpeechMessage(FaceObject faceObj) { string message = string.Empty; string emotionName = string.Empty; int numOfFaces = faceObj.faces.Count; if (numOfFaces > 0) { // StartCoroutine(IdentifyFaces(faceObj.faces)); message += "There are " + numOfFaces + " people here."; foreach (Face face in faceObj.faces) { EmotionAttributes emotionAttributes = face.emotionAttributes; Dictionary <string, float> emotions = new Dictionary <string, float> { { "neutral", emotionAttributes.neutral }, { "angry", emotionAttributes.anger }, { "argumentive", emotionAttributes.contempt }, { "disgusted", emotionAttributes.disgust }, { "scared", emotionAttributes.fear }, { "happy", emotionAttributes.happiness }, { "sad", emotionAttributes.sadness }, { "suprised", emotionAttributes.surprise } }; emotionName = emotions.Aggregate((x, y) => x.Value > y.Value ? x : y).Key; //Message message += string.Format("A {0} year old {1} who is feeling {2}", face.faceAttributes.age, face.faceAttributes.gender == 0 ? "man" : "woman", emotionName); } } else { message = "I couldn't detect anyone."; } // Try and get a TTS Manager // TextToSpeech tts = ttsManager; if (ttsManager != null) { //Play voice message ttsManager.StartSpeaking(message); } }
public void PlayTextToSpeechMessage(MCSFaceDto face) { string message = string.Empty; string emotionName = string.Empty; if (face.faces.Count > 0) { EmotionAttributes emotionAttributes = face.faces[0].emotionAttributes; Dictionary <string, float> emotions = new Dictionary <string, float> { { "anger", emotionAttributes.anger }, { "contempt", emotionAttributes.contempt }, { "disgust", emotionAttributes.disgust }, { "fear", emotionAttributes.fear }, { "happiness", emotionAttributes.happiness }, { "sadness", emotionAttributes.sadness }, { "suprise", emotionAttributes.surprise } }; emotionName = emotions.Keys.Max(); //Message message = string.Format("{0} is pretty much {1} years old and looks {2}", face.faces[0].faceAttributes.gender == 0 ? "He" : "She", face.faces[0].faceAttributes.age, emotionName); } else { message = "I could't detect anyone."; } // Try and get a TTS Manager TextToSpeechManager tts = null; if (photoCaptureManagerGmObj != null) { tts = photoCaptureManagerGmObj.GetComponent <TextToSpeechManager>(); } if (tts != null) { //Play voice message tts.SpeakText(message); } }