Пример #1
0
    public void StartConversation()
    {
        textInvestorLabel.gameObject.SetActive(false);
        textToSayLabel.gameObject.SetActive(true);
        textSaidLabel.gameObject.SetActive(true);

        // Turn the microphone on, which returns the recorded audio.
        textToSayLabel.text = initialSentences [sceneScript.GetCurrDictationState()];
        textSaidLabel.text  = "";

        if (!microphoneManager.IsDictationRunning())
        {
            dictationAudio.clip = microphoneManager.StartRecording();
        }
    }
Пример #2
0
 void Start()
 {
     speechBubblePos = Camera.main.transform.position;
     //This needs to be scraped from server at some point
     url            = "http://172.25.53.167:8000/sounds.json";
     soundObjects   = new List <GameObject>();
     soundThreshold = 1000;
     bestPosition   = new Vector3(0, 0, 0);
     //These three components are needed to record speech
     dictationAudio      = gameObject.GetComponent <AudioSource>();
     microphoneManager   = GetComponent <MicrophoneManager>();
     dictationAudio.clip = microphoneManager.StartRecording();
 }
Пример #3
0
    public void Record()
    {
        if (RecordButton.IsOn())
        {
            // Turn the microphone on, which returns the recorded audio.
            dictationAudio.clip = microphoneManager.StartRecording();

            // Set proper UI state and play a sound.
            SetUI(true, Message.PressStop, startAudio);

            RecordButton.gameObject.SetActive(false);
            RecordStopButton.gameObject.SetActive(true);
        }
    }
Пример #4
0
 /// <summary>
 /// Resets the microphone if conditions require it to be reset
 /// </summary>
 private void resetMicrophone()
 {
     if (microphoneManager != null)
     {
         if (microphoneManager.speechText.GetComponent <TextMesh>().text.Equals("Speech has ended."))
         {
             microphoneManager   = GetComponent <MicrophoneManager>();
             dictationAudio.clip = microphoneManager.StartRecording();
         }
     }
     else
     {
         dictationAudio      = gameObject.GetComponent <AudioSource>();
         microphoneManager   = GetComponent <MicrophoneManager>();
         dictationAudio.clip = microphoneManager.StartRecording();
     }
 }
Пример #5
0
    public void UIPressed()
    {
        isPressed = !isPressed;

        recordingButton.Play("Highlighted");
        if (microphoneManager)
        {
            if (isPressed)
            {
                microphoneManager.StartRecording();
                imageButton.color = Color.red;
            }
            else
            {
                microphoneManager.StopRecording();
                imageButton.color = Color.white;
            }
        }
        else
        {
            StartRecording(isPressed);
        }
    }
Пример #6
0
 private void Recognizer_HoldStartedEvent(InteractionSourceKind source, Ray headRay)
 {
     Debug.Log("recording started");
     microphoneManager.StartRecording();
 }
Пример #7
0
    private bool typeAProtocol()
    {
        if (protocolStep < 2)
        {
            dialogScreen.SendMessage("AdvanceText");
        }
        else if (protocolStep <= 2)
        {
            activateActionScreen("Think back to your traumatic experience. (Tap to Continue)");
            child.SendMessage("SetScaredEmotion");
        }
        else if (protocolStep <= 3)
        {
            activateDialogScreen();
            dialogScreen.SendMessage("AdvanceText");
        }
        else if (protocolStep <= 4)
        {
            child.SendMessage("showZones");
            activateActionScreen("---");

            hugProtocolCoroutine = hugProtocol();
            StartCoroutine(hugProtocolCoroutine);
        }
        else if (protocolStep <= 5)
        {
            if (!hugProtocolComplete)
            {
                return(false);
            }

            StopCoroutine(hugProtocolCoroutine);
            activateDialogScreen();
            dialogScreen.SendMessage("AdvanceText");
            child.SendMessage("SetNeutralEmotion");
        }
        else if (protocolStep <= 6)
        {
            dialogScreen.SendMessage("AdvanceText");
        }
        else if (protocolStep <= 7)
        {
            phraseDetected = false;
            microphoneManager.StartRecording();
            activateActionScreen("Say these words to your inner-child: 'I will support you'");
            microphoneManager.detectPhrase(phrase1Id, new string[] { "I", "will", "support", "you" });
            phraseProtocolCoroutine = phraseProtocol(phrase1Id);
            StartCoroutine(phraseProtocolCoroutine);
        }
        else if (protocolStep <= 8)
        {
            if (!phraseDetected)
            {
                return(false);
            }
            StopCoroutine(phraseProtocolCoroutine);
            microphoneManager.deletePhrase(phrase1Id);
            microphoneManager.StopRecording();
            phraseDetected = false;

            child.SendMessage("SetHappyEmotion");
            activateActionScreen("Great! now encourage and reassure your inner-child. (Tap to Continue)");
        }
        else if (protocolStep <= 9)
        {
            activateDialogScreen();
            dialogScreen.SendMessage("AdvanceText");
        }

        return(true);
    }
Пример #8
0
    public void AdvanceProtocol()
    {
        if (!enabled)
        {
            return;
        }

        if (protocolStep < numberFirstSectionDialog - 1)
        {
            dialogScreen.SendMessage("AdvanceText");
        }
        else if (protocolStep == numberFirstSectionDialog - 1)
        {
            activateActionScreen("Think of your song... sing it to your inner-child. Also slowly dance along to your song");
            microphoneManager.StartRecording();
            songProtocolCoroutine = songProtocol(false);
            StartCoroutine(songProtocolCoroutine);
        }
        else if (protocolStep == numberFirstSectionDialog)
        {
            if (!songDetected)
            {
                return;
            }

            StopCoroutine(songProtocolCoroutine);
            microphoneManager.StopRecording();
            activateDialogScreen();
            dialogScreen.SendMessage("AdvanceText");

            child.SendMessage("SetHappyEmotion");
        }
        else if (protocolStep < numberFirstSectionDialog + 2)
        {
            child.SendMessage("SetNeutralEmotion");
            dialogScreen.SendMessage("AdvanceText");
        }
        else if (protocolStep == numberFirstSectionDialog + 3)
        {
            activateActionScreen("Please give yourself a self-massage. Feel free to remove the headset if you need to (Tap to continue)");
        }
        else if (protocolStep == numberFirstSectionDialog + 4)
        {
            activateDialogScreen();
            child.SendMessage("SetHappyEmotion");
            dialogScreen.SendMessage("AdvanceText");
        }
        else if (protocolStep < numberFirstSectionDialog + 6)
        {
            child.SendMessage("SetNeutralEmotion");
            dialogScreen.SendMessage("AdvanceText");
        }
        else if (protocolStep == numberFirstSectionDialog + 7)
        {
            child.SendMessage("SetSadEmotion");
            activateActionScreen("Recall a distressing memory from your past... (Tap to continue)");
        }
        else if (protocolStep == numberFirstSectionDialog + 8)
        {
            songDetected = false;
            child.SendMessage("SetScaredEmotion");
            activateActionScreen("Now sing the song you associate with happy memories and feelings to make your inner-child feel loved");

            microphoneManager.StartRecording();
            songProtocolCoroutine = songProtocol(true);
            StartCoroutine(songProtocolCoroutine);
        }
        else if (protocolStep == numberFirstSectionDialog + 9)
        {
            if (!songDetected)
            {
                return;
            }

            StopCoroutine(songProtocolCoroutine);
            microphoneManager.StopRecording();
            activateDialogScreen();
            dialogScreen.SendMessage("AdvanceText");

            child.SendMessage("SetHappyEmotion");
        }
        else if (protocolStep <= numberFirstSectionDialog + 11)
        {
            dialogScreen.SendMessage("AdvanceText");
        }
        else if (protocolStep == numberFirstSectionDialog + 12)
        {
            phraseDetected = false;
            microphoneManager.StartRecording();
            child.SendMessage("SetNeutralEmotion");
            activateActionScreen("Say these words to your inner-child: 'I love you'");
            microphoneManager.detectPhrase(phrase1Id, new string[] { "I", "love", "you" });
            phraseProtocolCoroutine = phraseProtocol(phrase1Id);
            StartCoroutine(phraseProtocolCoroutine);
        }
        else if (protocolStep == numberFirstSectionDialog + 13)
        {
            if (!phraseDetected)
            {
                return;
            }
            StopCoroutine(phraseProtocolCoroutine);
            microphoneManager.deletePhrase(phrase1Id);
            phraseDetected = false;

            child.SendMessage("SetHappyEmotion");
            activateActionScreen("Great! now say these words: 'I vow to protect you'");
            microphoneManager.detectPhrase(phrase2Id, new string[] { "I", "vow", "to", "protect", "you" });
            phraseProtocolCoroutine = phraseProtocol(phrase2Id);
            StartCoroutine(phraseProtocolCoroutine);
        }
        else if (protocolStep == numberFirstSectionDialog + 14)
        {
            if (!phraseDetected)
            {
                return;
            }
            StopCoroutine(phraseProtocolCoroutine);
            microphoneManager.StopRecording();

            activateDialogScreen();
            dialogScreen.SendMessage("AdvanceText");
        }
        else if (protocolStep == numberFirstSectionDialog + 15)
        {
            sceneManager.SendMessage("OpenStartPageScene");
        }

        protocolStep++;
    }