// Use this for initialization
    void Start()
    {
        if (Application.isEditor)
        {
            endGame();
        }
        if (Application.platform != RuntimePlatform.Android)
        {
            Debug.Log("Speech recognition is only available on Android platform.");
        }

        if (!SpeechRecognizerManager.IsAvailable())
        {
            Debug.Log("Speech recognition is not available on this device.");
        }

        // We pass the game object's name that will receive the callback messages.
        speech        = new SpeechRecognizerManager(gameObject.name);
        sentenceAudio = new List <AudioClip>();

        sentenceAudio.Add(Resources.Load <AudioClip>("Sentences/phrase 08_eng"));
        sentenceAudio.Add(Resources.Load <AudioClip>("Sentences/phrase 15_eng"));
        sentenceAudio.Add(Resources.Load <AudioClip>("Sentences/phrase 31_eng"));
        sentenceAudio.Add(Resources.Load <AudioClip>("Sentences/phrase 35_eng"));

        // Adds sentences to the game
        sentences = new List <string>();
        sentences.Add("Peach is sad");
        sentences.Add("She will make a wish at the river.");
        sentences.Add("I wish I had a friend");
        sentences.Add("I like pink.");
        movement  = (Screen.width - 200) / 2 / sentences.Count; // calculates the movement of the characters based on the screen size
        origLamon = lamon.transform.position;
        origRudee = rudee.transform.position;
    }
    private void NextWord()
    {
        listenButton.SetActive(false);
        nextButton.SetActive(false);
        audioSource.Stop();

        Debug.Log("Made it to the NextWord()");
        currWord    = "";
        status.text = "";
        int index = Random.Range(0, words.Count);

        currWord         = words[index];
        gameText.text    = currWord;
        audioSource.clip = Resources.Load(currWord + "_eng") as AudioClip;
        if (SpeechRecognizerManager.IsAvailable())
        {
            if (!isListening)
            {
                isListening = true;
                endSpeechButton.GetComponentInChildren <Text>().text = "Touch here when finished speaking.";
                endSpeechButton.SetActive(true);
                speechManager.StartListening(3, "en-US");
            }
        }
    }
    /// <summary>
    /// Moves on the the next sentence in the list.  This is called at the beginning of the game and after each correct sentence
    /// </summary>
    /// <returns></returns>
    private IEnumerator NextSentence()
    {
        listenButton.SetActive(false);
        nextButton.SetActive(false);
        tryAgainButton.SetActive(false);
        audioSource.Stop();

        resetTMs();
        yield return(new WaitForSeconds(1));

        misses      = 0;
        status.text = "";
        voiceOpen   = true;
        int             index = Random.Range(0, 3);
        TextMeshProUGUI TMP   = SentenceTextMesh[index];

        TMP.text         = sentences[progress];
        audioSource.clip = sentenceAudio[progress];
        if (SpeechRecognizerManager.IsAvailable())
        {
            if (!listening)
            {
                listening = true;
                endSpeechButton.GetComponentInChildren <Text>().text = "Touch here when finished speaking.";
                endSpeechButton.SetActive(true);
                speech.StartListening(3, "en-US");
            }
        }
    }
Exemple #4
0
    public void OnSpeechEventEnded(bool isPassed)
    {
        GameScreen.Instance.OnSpeechEventEnded(isPassed);

        if (SpeechRecognizerManager.IsAvailable())
        {
            MySpeechRecognizer.Instance._speechManager.StopListening();
        }

        _totalLetters++;

        if (isPassed)
        {
            //CancelInvoke("OnWrongSpeech");
            Score++;
        }

        Color letterHighlight = isPassed ? Color.green : Color.red;

        Time.timeScale = 1f;
        _currentListenLetter.gameObject.GetComponent <SpriteRenderer>().color = letterHighlight;
        iTween.ColorTo(_currentListenLetter.gameObject, new Color(0f, 1f, 0f, 0f), 0.6f);
        iTween.MoveBy(_currentListenLetter.gameObject, new Vector3(0f, 7f, 0f), 0.6f);

        _currentListenLetter = null;
        IsListening          = false;
    }
    // Use this for initialization
    void Start()
    {
        if (Application.platform != RuntimePlatform.Android)
        {
            Debug.Log("Speech recognition is only available on Android platform.");
            return;
        }

        if (!SpeechRecognizerManager.IsAvailable())
        {
            Debug.Log("Speech recognition is not available on this device.");
            return;
        }

        // We pass the game object's name that will receive the callback messages.
        _speechManager = new SpeechRecognizerManager(gameObject.name);

        quote.SetActive(false);
        starfield.SetActive(false);
        starfieldred.SetActive(false);
        metoo.SetActive(false);
        christmas.SetActive(false);
        lip.SetActive(false);
        speaknow.SetActive(false);

        //vb = gameObject.GetComponent<VolumeButton>();

        InvokeRepeating("RecogStart", 0f, 3f);
    }
 // Update is called once per frame
 void Update()
 {
     // allows for a reprompt of the phrase if the speech recognizer times out
     if (SpeechRecognizerManager.IsAvailable() && voiceOpen)
     {
         if (!listening)
         {
             listening = true;
             speech.StartListening(3, "en-US");
         }
     }
 }
Exemple #7
0
    public void OnSpeechEvent(Letter letterToListen)
    {
        Time.timeScale       = 0.4f;
        _currentListenLetter = letterToListen;
        IsListening          = true;
        //Invoke("OnWrongSpeech", 1.7f);
        //Invoke("StopListen", 1.1f);

        if (SpeechRecognizerManager.IsAvailable())
        {
            MySpeechRecognizer.Instance._speechManager.StartListening(5, "en-US");
        }
    }
Exemple #8
0
    void Start()
    {
        if (Application.platform != RuntimePlatform.Android)
        {
            Debug.Log("Speech recognition is only available on Android platform.");
            return;
        }

        if (!SpeechRecognizerManager.IsAvailable())
        {
            Debug.Log("Speech recognition is not available on this device.");
            return;
        }

        speechManager = new SpeechRecognizerManager(gameObject.name);
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Q))
        {
            matchedCount--;
        }
        if (Input.GetKeyDown(KeyCode.W))
        {
            matchedCount++;
        }

        if (SpeechRecognizerManager.IsAvailable() && isListening)
        {
            speechManager.StartListening(3, "en-US");
        }
    }
Exemple #10
0
    void Start()
    {
        if (Application.platform != RuntimePlatform.Android)
        {
            Debug.Log("Speech recognition is only available on Android platform.");
            return;
        }

        if (!SpeechRecognizerManager.IsAvailable())
        {
            Debug.Log("Speech recognition is not available on this device.");
            return;
        }

        // We pass the game object's name that will receive the callback messages.
        _speechManager = new SpeechRecognizerManager(gameObject.name);
    }
Exemple #11
0
    void Start()
    {
        panel         = transform.GetChild(0).gameObject;
        startSpeech   = transform.GetChild(1).gameObject;
        cancelSpeech  = transform.GetChild(2).gameObject;
        speechHandler = UnityEngine.Object.FindObjectOfType <SpeechHandler>();

                #if UNITY_EDITOR
        GameObject debugObject = GameObject.Find("DebugMesh");
        if (debugObject != null)
        {
            debugText = debugObject.GetComponent <Text>();
        }
                #endif

        IsListening = false;
        Enabled     = true;

        SpeechManager = new SpeechRecognizerManager(gameObject.name);

        DebugLog("Devices: " + String.Join(", ", Microphone.devices));


        if (Application.platform != RuntimePlatform.Android)
        {
            Debug.Log("Speech recognition is only available on Android platform.");
            Enabled = false;
            return;
        }

        if (!SpeechRecognizerManager.IsAvailable())
        {
            Debug.Log("Speech recognition is not available on this device.");
            Enabled = false;
            return;
        }

        if (!GameState.Instance.SpeechEnabled)
        {
            Enabled = false;
        }

        // We pass the game object's name that will receive the callback messages.
        SpeechManager = new SpeechRecognizerManager(gameObject.name);
    }
Exemple #12
0
    void Start()
    {
        if (Application.platform != RuntimePlatform.Android)
        {
            Debug.Log("Reconocimiento de voz solo disponible en plataformas Android.");
            return;
        }

        if (!SpeechRecognizerManager.IsAvailable())
        {
            Debug.Log("Reconocimiento de voz no disponible en este dispositivo.");
            return;
        }

        // We pass the game object's name that will receive the callback messages.
        _speechManager = new SpeechRecognizerManager(gameObject.name);
        startingPoint  = transform.position;
    }
Exemple #13
0
    private void Start()
    {
        if (Application.platform != RuntimePlatform.Android)
        {
            Debug.Log("What a heck man? Available only on Andoid.");
            return;
        }

        if (!SpeechRecognizerManager.IsAvailable())
        {
            GameScreen.Instance.Status = "Speech recognition is not available on this device.";
            //Debug.Log("Speech recognition is not available on this device.");
            return;
        }

        GameScreen.Instance.Status = "Speech recognizer initialized";
        _speechManager             = new SpeechRecognizerManager(gameObject.name);
    }
Exemple #14
0
 ///<summary>
 /// Starts/finishes the recording/recognizing.
 ///</summary>
 public void ToggleListening()
 {
     DebugLog("Toggle Listening");
     if (SpeechRecognizerManager.IsAvailable() && Enabled)
     {
         DebugLog("Available and Enabeld");
         if (!IsListening)
         {
             DebugLog("Listening");
             IsListening = true;
             SpeechManager.StartListening(3, "en-UK");                 // Return 3 results maximum, and use English
         }
         else
         {
             DebugLog("Stopped");
             IsListening = false;
             SpeechManager.StopListening();
         }
     }
 }
Exemple #15
0
    void OnGUI()
    {
        float     originalScreenWidth  = 400f;
        float     originalScreenHeight = (originalScreenWidth / Screen.width) * Screen.height;
        float     scale = Screen.width / originalScreenWidth;
        Matrix4x4 svMat = GUI.matrix;         // save current matrix

        GUI.matrix = Matrix4x4.Scale(Vector3.one * scale);

        GUI.skin.label.fontStyle = FontStyle.Bold;
        GUI.skin.label.alignment = TextAnchor.MiddleCenter;
        GUI.Label(new Rect(0f, 0f, originalScreenWidth, originalScreenHeight * 0.05f), "Android Speech Recognizer Plugin");

        GUI.skin.label.fontStyle = FontStyle.Normal;
        GUI.skin.label.alignment = TextAnchor.LowerLeft;
        Rect layoutRect = new Rect(originalScreenWidth * 0.05f, originalScreenHeight * 0.1f, originalScreenWidth * 0.9f, originalScreenHeight * 0.85f);

        GUILayout.BeginArea(layoutRect, GUI.skin.box);

        GUILayout.BeginVertical();

        GUILayout.Label("Available: " + SpeechRecognizerManager.IsAvailable());

        if (SpeechRecognizerManager.IsAvailable())
        {
            GUILayout.Label(_message);

            GUILayout.Space(35f);

            if (!_isListening && GUILayout.Button("Start Listening"))
            {
                _isListening = true;
                _speechManager.StartListening(3, "en-US");                  // Use english and return maximum three results.
                // _speechManager.StartListening (); // No parameters will use the device default language and returns maximum 5. results
            }

            /*
             * Speech captured so far will be recognized as if the user had stopped speaking at this point.
             * This does not need to be called, as it will automatically stop the recognizer listening when it determines speech has completed.
             */
            if (_isListening && GUILayout.Button("Stop Listening"))
            {
                _speechManager.StopListening();
                _isListening = false;
            }

            /*
             * Cancels the speech recognition.
             */
            if (_isListening && GUILayout.Button("Cancel"))
            {
                _speechManager.CancelListening();
                _isListening = false;
            }
        }

        GUILayout.EndVertical();

        GUILayout.EndArea();

        GUI.matrix = svMat;
    }