Web Speech API in Chrome in iOS throws "service-not-allowed" error

612 views Asked by At

i am currently implementing speech input on a website and using the web speech API for it.

voice recognition works as expected in Chrome on desktop and android. Firefox does not have support for the API so it is not being used there.

the problem is with chrome on iOS where the service throws a "service-not-allowed" error.

this error seems to be distinctly different from the "not-allowed" error that is being thrown when the browser does not have permission to use the microphone.

in my case chrome has all permissions it would need (microphone permission, pop-ups are not blocked).

at first i thought the problem was, that for some reason chrome on iOS does not show me the permission pop-up, specifically for microphone usage, directly on the web page, but now i am not so sure anymore.

does anyone have experience with this problem or have a solution for this?

here is the working code for android/desktop, the function gets triggered by a button click:

function startDictation() {
    try {
        var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition;
        var recognition = new SpeechRecognition();
    } catch (e) {
        console.log(e);
    }

    if (recognition) {
        recognition.continuous = false;
        recognition.interimResults = true;

        recognition.lang = $('html').attr('lang');
        recognition.start();

        recognition.onresult = function(e) {
            $('#searchInput').val(e.results[0][0].transcript);
            console.log(e.results[0][0].transcript);
        };

        recognition.onerror = (e) => {
            console.error('Speech recognition error detected: ' + e.error);
            recognition.stop();
        };

        recognition.onend = () => {
            console.log('Speech recognition service disconnected');
        }

    }
}

a few helpful links

i have tried various end devices at this point, two different iPads and an iPhone and the same error gets thrown everywhere.

any help is appreciated, thanks!

0

There are 0 answers