public void OnStartRecordingPressed(string name)
        {
            if (name.Equals("cashier"))
            {
                this.modelkey  = modelKeys ["salesgirl"];
                this.voiceType = voice ["security"];
            }
            else
            {
                this.modelkey  = modelKeys [name];
                this.voiceType = voice [name];
            }



            if (SpeechRecognizer.IsRecording())
            {
                SpeechRecognizer.StopIfRecording();
                startRecordingButton.GetComponentInChildren <Text>().text = "Start Recording";
            }
            else
            {
                SpeechRecognizer.StartRecording(true);
                startRecordingButton.GetComponentInChildren <Text>().text = "Stop Recording";
                resultText.text = "Say something :-)";
            }
        }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (SpeechRecognizer.IsRecording())
            {
                SpeechRecognizer.StopIfRecording();
                //resultText.text = "I stopped recording";
            }
            Application.Quit();
            //Application.LoadLevel ("MainActivity.class");
        }

        if (wordInputTimer > 5)
        {
            if (!t.IsAlive && sentence_queue.Count != 0)
            {
                String sentence = sentence_queue.Dequeue();
                t = new Thread(() => ActionPerformer(sentence));
                t.Start();
            }
        }
        wordInputTimer++;
        if (!t.IsAlive && sentence_queue.Count == 0 && wordInputTimer > 1500)
        {
            resultText.text = "no speech input: close app and try again :)";
            if (SpeechRecognizer.IsRecording())
            {
                SpeechRecognizer.StopIfRecording();
                //resultText.text = "I stopped recording";
            }
            Thread.Sleep(500);
            Application.Quit();
        }
    }
Exemple #3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "door")
        {
            dooraudio.Play();
            EasyTTSUtil.SpeechAdd("this is door.");

            SpeechRecognizerListener listener = GameObject.FindObjectOfType <SpeechRecognizerListener>();
            listener.onFinalResults.AddListener(OnFinalResult);
            listener.onPartialResults.AddListener(OnPartialResult);
            SpeechRecognizer.RequestAccess();

            EasyTTSUtil.SpeechAdd("passed request");

            if (SpeechRecognizer.IsRecording())
            {
                EasyTTSUtil.SpeechAdd("Stoping recording");
                SpeechRecognizer.StopIfRecording();
            }
            else
            {
                SpeechRecognizer.StartRecording(true);
                EasyTTSUtil.SpeechAdd("Start recording");
            }


            EasyTTSUtil.SpeechAdd(resultText);

            EasyTTSUtil.SpeechAdd("and finihsed testing");
        }
    }
    ///<summary>
    ///speechrec functions below
    /// </summary>
    public void OnFinalResult(string result)
    {
        wordInputTimer=0;
        sentence_queue.Enqueue(result); 

        if (!t.IsAlive)
        {
            String sentence = sentence_queue.Dequeue();
            t = new Thread(()=>ActionPerformer(sentence));
            t.Start();
        }

        //resultText.text = "I am running final Results";

        if (SpeechRecognizer.IsRecording())
        {
            SpeechRecognizer.StopIfRecording();
            //resultText.text = "I stopped recording";
        }
        else
        {
            SpeechRecognizer.StartRecording(true);
            //resultText.text = "Say something :-)";
        }
    }
 private void Update()
 {
     if (spawnAndGuide.isMoving && !SpeechRecognizer.IsRecording() && !partialTriggered)
     {
         StartCoroutine(VoiceCommands());
     }
 }
 public void OnStartRecordingPressed()
 {
     if (SpeechRecognizer.IsRecording())
     {
         DesactivarEscucha();
     }
     else
     {
         ActivarEscucha();
     }
 }
Exemple #7
0
 void recordMic()
 {
     if (SpeechRecognizer.IsRecording())
     {
         SpeechRecognizer.StopIfRecording();
     }
     else
     {
         SpeechRecognizer.StartRecording(true);
     }
 }
 /*COMIENZA RECONOCIMIENTO DE VOZ*/
 public void OnStartRecordingPressed()
 {
     //SI ESTA ACTIVA LA ESCUCHA
     if (SpeechRecognizer.IsRecording())
     {
         DesactivarEscucha();
     }
     else
     {
         ActivarEscucha();
     }
 }
 public void OnStartRecordingPressed()
 {
     if (SpeechRecognizer.IsRecording())
     {
         SpeechRecognizer.StopIfRecording();
         resultText.text = "Press\n to Ask your\n Question";
     }
     else
     {
         SpeechRecognizer.StartRecording(true);
         resultText.text = "";
     }
 }
Exemple #10
0
 public void OnStartRecordingPressed()
 {
     if (SpeechRecognizer.IsRecording())
     {
         SpeechRecognizer.StopIfRecording();
         startRecordingButton.GetComponentInChildren <Text>().text = "Start Recording";
     }
     else
     {
         SpeechRecognizer.StartRecording(true);
         startRecordingButton.GetComponentInChildren <Text>().text = "Stop Recording";
         resultText.text = "Recording... ";
     }
 }
Exemple #11
0
 ////user stops recording speech
 public void OnEndOfSpeech()
 {
     //resultText.text = "I am running onEndofSpeech";
     if (SpeechRecognizer.IsRecording())
     {
         SpeechRecognizer.StopIfRecording();
         resultText.text = "I stopped recording";
     }
     else
     {
         SpeechRecognizer.StartRecording(true);
         resultText.text = "Say something :-)";
     }
 }
 ////user stops recording speech
 public void OnEndOfSpeech()
 {
     //resultText.text = "Exit app and try again";
     if (SpeechRecognizer.IsRecording())
     {
         resultText.text = "end of speech turning off recording";
         SpeechRecognizer.StopIfRecording();
         //resultText.text = "I stopped recording";
     }
     else
     {
         //SpeechRecognizer.StartRecording(true);
         //resultText.text = "Say something :-)";
     }
 }
 ///<summary>
 ///speechrec functions below
 /// </summary>
 public void OnFinalResult(string result)
 {
     resultText.text = result;
     //word = result;
     //ActionPerformer(result);
     //resultText.text = "I am running final Results";
     if (SpeechRecognizer.IsRecording())
     {
         SpeechRecognizer.StopIfRecording();
         //resultText.text = "I stopped recording";
     }
     else
     {
         SpeechRecognizer.StartRecording(true);
         //resultText.text = "Say something :-)";
     }
 }
    public void OnStartRecordingPressed()
    {
        print("Starting Speech Recognition!!");

        if (SpeechRecognizer.IsRecording())
        {
            micIsActive = false;
            SpeechRecognizer.StopIfRecording();
            animController.MicUI();
        }
        else
        {
            debugText.text = "Starting Speech Recognition";
            micIsActive    = true;
            SpeechRecognizer.StartRecording(true);
            animController.MicUI();
        }
    }
Exemple #15
0
    public void OnStartRecordingPressed()
    {
        if (SpeechRecognizer.IsRecording())
        {
            SpeechRecognizer.StopIfRecording();
            startRecordingButton.GetComponentInChildren <Text>().text = "";

            startRecordingButton.gameObject.SetActive(true);
            microfono.gameObject.SetActive(false);
        }
        else
        {
            startRecordingButton.gameObject.SetActive(false);
            microfono.gameObject.SetActive(true);
            SpeechRecognizer.StartRecording(true);
            startRecordingButton.GetComponentInChildren <Text>().text = "";
        }
    }
        public void OnQRecordingPressed(string question, GameObject target)
        {
            this.modelkey = "q";
            //this.voiceType = voice ["q"];
            this.question = question;
            this.target   = target;

            if (SpeechRecognizer.IsRecording())
            {
                SpeechRecognizer.StopIfRecording();
                startRecordingButton.GetComponentInChildren <Text>().text = "Start Recording";
            }
            else
            {
                SpeechRecognizer.StartRecording(true);
                startRecordingButton.GetComponentInChildren <Text>().text = "Stop Recording";
                resultText.text = "Say something :-)";
            }
        }
 public void OnStartRecordingPressed()
 {
     if (SpeechRecognizer.IsRecording())
     {
         listenUI.SetActive(false);
         animator.SetBool("Recording", false);
         SpeechRecognizer.StopIfRecording();
         startRecordingButton.GetComponentInChildren <Text>().text = "Start Recording";
         Recording = false;
     }
     else
     {
         listenUI.SetActive(true);
         Recording = true;
         animator.SetBool("Recording", true);
         SpeechRecognizer.StartRecording(true);
         startRecordingButton.GetComponentInChildren <Text>().text = "Stop Recording";
         resultText.text = "Say something :)";
     }
 }
    public void OnToggleSpeechRecognition()
    {
        if (SpeechRecognizer.IsRecording())
        {
            SpeechRecognizer.StopIfRecording();

            if (StatusText != null)
            {
                StatusText.text = "IDLE - VOICE COMMAND INPUT STOPPED";
                _StaticStatus   = StatusText.text;
            }
        }
        else
        {
            SpeechRecognizer.StartRecording(true);

            if (StatusText != null)
            {
                StatusText.text = "IDLE - VOICE COMMAND INPUT INITIALIZED";
                _StaticStatus   = StatusText.text;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (webCamTextureToMatHelper.IsPlaying() && webCamTextureToMatHelper.DidUpdateThisFrame())
        {
            Mat rgbaMat = webCamTextureToMatHelper.GetMat();

            //convert image to greyscale
            Imgproc.cvtColor(rgbaMat, grayMat, Imgproc.COLOR_RGBA2GRAY);


            if (isAutoResetMode || faceTracker.getPoints().Count <= 0)
            {
//                    Debug.Log ("detectFace");

                //convert image to greyscale
                using (Mat equalizeHistMat = new Mat()) using (MatOfRect faces = new MatOfRect()) {
                        Imgproc.equalizeHist(grayMat, equalizeHistMat);

                        cascade.detectMultiScale(equalizeHistMat, faces, 1.1f, 2, 0
                                                 //                                                                                 | Objdetect.CASCADE_FIND_BIGGEST_OBJECT
                                                 | Objdetect.CASCADE_SCALE_IMAGE, new Size(equalizeHistMat.cols() * 0.15, equalizeHistMat.cols() * 0.15), new Size());

                        if (faces.rows() > 0)
                        {
//                            Debug.Log ("faces " + faces.dump ());

                            List <OpenCVForUnity.CoreModule.Rect> rectsList = faces.toList();
                            List <Point[]> pointsList = faceTracker.getPoints();

                            if (isAutoResetMode)
                            {
                                //add initial face points from MatOfRect
                                if (pointsList.Count <= 0)
                                {
                                    faceTracker.addPoints(faces);
//                                    Debug.Log ("reset faces ");
                                }
                                else
                                {
                                    for (int i = 0; i < rectsList.Count; i++)
                                    {
                                        OpenCVForUnity.CoreModule.Rect trackRect = new OpenCVForUnity.CoreModule.Rect(rectsList [i].x + rectsList [i].width / 3, rectsList [i].y + rectsList [i].height / 2, rectsList [i].width / 3, rectsList [i].height / 3);
                                        //It determines whether nose point has been included in trackRect.
                                        if (i < pointsList.Count && !trackRect.contains(pointsList [i] [67]))
                                        {
                                            rectsList.RemoveAt(i);
                                            pointsList.RemoveAt(i);
//                                                                                      Debug.Log ("remove " + i);
                                        }
                                        //uncomment below for rectangle around face
                                        Imgproc.rectangle(rgbaMat, new Point(trackRect.x, trackRect.y), new Point(trackRect.x + trackRect.width, trackRect.y + trackRect.height), new Scalar(0, 0, 255, 255), 2);
                                    }
                                }
                            }
                            else
                            {
                                faceTracker.addPoints(faces);
                            }
                            //draw face rect
                            for (int i = 0; i < rectsList.Count; i++)
                            {
                                //uncomment below for rectangle around face
                                Imgproc.rectangle(rgbaMat, new Point(rectsList [i].x, rectsList [i].y), new Point(rectsList [i].x + rectsList [i].width, rectsList [i].y + rectsList [i].height), new Scalar(255, 0, 0, 255), 2);
                            }
                        }
                        else
                        {
                            if (isAutoResetMode)
                            {
                                faceTracker.reset();
                            }
                        }
                    }
            }

            //track face points.if face points <= 0, always return false.
            if (faceTracker.track(grayMat, faceTrackerParams))
            {
                //GameObject.FindGameObjectWithTag("left hand").transform.localScale = new Vector3(0.05f, 0.05f, 50);
                //GameObject.FindGameObjectWithTag("right hand").transform.localScale = new Vector3(0.05f, 0.05f, 50);
                //facecount = 0;
                if (facerec > 15)
                {
                    GameObject.FindGameObjectWithTag("left hand").transform.localScale  = new Vector3(0.2f, 0.2f, 50);
                    GameObject.FindGameObjectWithTag("right hand").transform.localScale = new Vector3(0.2f, 0.2f, 50);
                    facecount = 0;
                }
                else
                {
                    facerec++;
                }
                //uncomment below for rectangle around face
                //faceTracker.draw(rgbaMat, new Scalar(255, 0, 0, 255), new Scalar(0, 255, 0, 255));
            }
            else
            {
                //facecount prevents flickering of hand from poor face recognition
                if (facecount > 15)
                {
                    facerec = 0;
                    GameObject.FindGameObjectWithTag("left hand").transform.localScale  = new Vector3(0f, 0f, 0);
                    GameObject.FindGameObjectWithTag("right hand").transform.localScale = new Vector3(0f, 0f, 0);                    facecount++;
                }
                else
                {
                    facecount++;
                }
            }

            //Imgproc.putText (rgbaMat, "'Tap' or 'Space Key' to Reset", new Point (5, rgbaMat.rows () - 5), Imgproc.FONT_HERSHEY_SIMPLEX, 0.8, new Scalar (255, 255, 255, 255), 2, Imgproc.LINE_AA, false);

//                Imgproc.putText (rgbaMat, "W:" + rgbaMat.width () + " H:" + rgbaMat.height () + " SO:" + Screen.orientation, new Point (5, rgbaMat.rows () - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar (255, 255, 255, 255), 2, Imgproc.LINE_AA, false);

            Utils.fastMatToTexture2D(rgbaMat, texture);
        }

        //facetrac resets upon screen click and space bar
        if (Input.GetKeyUp(KeyCode.Space) || Input.touchCount > 0)
        {
            faceTracker.reset();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (SpeechRecognizer.IsRecording())
            {
                SpeechRecognizer.StopIfRecording();
                //resultText.text = "I stopped recording";
            }
            Application.Quit();
            //Application.LoadLevel ("MainActivity.class");
        }
    }
Exemple #20
0
 void Update()
 {
     instruction.text = SpeechRecognizer.IsRecording() ? "Stop." : "Record!";
 }