Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return false for non supported browsers #30

Closed
Danny-Engelman opened this issue May 15, 2017 · 1 comment
Closed

return false for non supported browsers #30

Danny-Engelman opened this issue May 15, 2017 · 1 comment

Comments

@Danny-Engelman
Copy link

I load the library by default for different distributions, had to make a change so the library does not cause errors.

Would this be valid for a PR ?

    if (window.hasOwnProperty('speechSynthesis')) {
        speechSynthesis.getVoices();
    } else {
        console.error('this browser does not support speechSyntesis');
        return false;
    }

    if (window.hasOwnProperty('webkitSpeechRecognition')) {
        var reconocimiento = new webkitSpeechRecognition();
    } else {
        console.error('this browser does not support webkitSpeechRecognition');
        return false;
    }

@sdkcarlos
Copy link
Owner

Hi @Danny-Engelman ,

artyom shouldn't generate any error when loaded from unsupported browsers (if it does, you are triggering some function of Artyom that use the APIs without verifying if they're supported or not). To verify if the browser supports any of the APIs use respectively the methods recognizingSupported (for voice commands) and speechSupported (for voice synthesis):

function Talk(text){
    if(!artyom.speechSupported()){
        console.log("Cannot talk");
        return;
    }

    artyom.say(text);
}


function StartRecognition(){
    if(!artyom.recognizingSupported()){
        console.log("Cannot process commands");
        return;
    }

    artyom.initialize({
        lang:"en-GB",
        continuous:true,
        debug:true,
        soundex:true,
        listen:true
    }).then(function(){
        console.log("Artyom is listening !");
    });
}

It shouldn't return false because there are other functions used by developers like simulateInstruction, besides some browsers provide partial support for only one of the APIs, that means that returning false when the browser doesn't support Speech Synthesis would leave out the Speech Recognition and there won't be support for voice commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants