vendredi 24 février 2017

Web Speech API and Ember - continuous recognition

I am using Web Speech API and ember:

init: function () {
    this._super();

    var self = this;
    var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
    var recognition = new SpeechRecognition();

    recognition.continuous = true;
    recognition.interimResults = true;

    this.set("recognition", recognition);

    this.get("recognition").start();

    recognition.onstart = function () {
        console.info('recognition:start');
        self.set("isActive", true);
        self.trigger("start");
    };


    recognition.onend = function (event) {
        console.info('recognition:end', event);

        alert("recognition stopped");

        this.get("recognition").start();


    };


},

The above code starts voice recognition and I thought should make it continuous (ie. keeps listening forever), but it stops after 15 seconds or so. The recognition.onend function I thought is supposed to be called when voice recognition stops, but it never runs the code I have in there. How can I make the web speech API continue recording?




Aucun commentaire:

Enregistrer un commentaire