3

I have built one aplication using webkitSpeechRecognition. Record audio were fine and everything were ok until chrome update to 60.

The error occurs only on Windows 10 but not on MacOS whith the same update. (Update Chrome 59 to Chrome 60)

When I try to use the lib it give the error "not-allowed". I have manage chrome settings and set it to always ask for permission, but results goes to always block. So the error on Chrome persist and chrome does not allow the app to use mic settings.

On Chrome 59 (Windows 10), this behavor does not occurs!

Here is the angular speech service used to call the api:

import { UserService } from './user.service';
import { Injectable, NgZone } from '@angular/core';
import { Observable } from 'rxjs/Rx';


interface IWindow extends Window {
    webkitSpeechRecognition: any;
    SpeechRecognition: any;
}

@Injectable()
export class SpeechRecognitionService {
    speechRecognition: any;
    _me: any;

    constructor(private userService: UserService, private zone: NgZone) {
        this._me = userService.profile;
    }

    record(): Observable<string> {

        return Observable.create(observer => {
            const { webkitSpeechRecognition }: IWindow = <IWindow>window;
            this.speechRecognition = new webkitSpeechRecognition();
            this.speechRecognition.continuous = false;
            // this.speechRecognition.interimResults = true;
            this.speechRecognition.lang = this._me.lang;
            this.speechRecognition.maxAlternatives = 1;

            this.speechRecognition.onresult = speech => {
                let term = '';
                if (speech.results) {
                    const result = speech.results[speech.resultIndex];
                    const transcript = result[0].transcript;
                    if (result.isFinal) {
                        if (result[0].confidence < 0.3) {
                            console.log('Unrecognized result - Please try again');
                        } else {
                            term = transcript.trim();
                            console.log('Did you said? -> ' + term + ' , If not then say something else...');
                        }
                    }
                }
                this.zone.run(() => {
                    observer.next(term);
                });
            };

            this.speechRecognition.onerror = error => {
                observer.error(error);
            };

            this.speechRecognition.onend = () => {
                observer.complete();
            };

            this.speechRecognition.start();
            console.log('Say something - We are listening !!!');
        });
    }


    stop() {
        if (this.speechRecognition) {
            this.speechRecognition.stop();
        }
    }

}

Here is the log error on console when using it on Windows 10 with Chrome 60

enter image description here

liam
  • 1,918
  • 3
  • 22
  • 28
calebeaires
  • 1,972
  • 1
  • 22
  • 34
  • I know that this might seem dumb but have you given access to your microphone? – liam Aug 02 '17 at 16:07
  • Yes, I have tried to do that. Both on Chrome and Windows Settings. No defender, no anti-virus... not that I could release is blocking. Just the Chrome version 60 that block the mic. – calebeaires Aug 03 '17 at 20:59
  • That is very weird. I would love to help you with this issue but since I can't have you talked to Google's support? – liam Aug 03 '17 at 21:01

2 Answers2

1

My Chrome Browser do the same and i tried it in chrome 59 (works) and after update to 60 it gets blocked.

Additionally: I tried it on my local Server with audio input with WebSpeech Api. If i connect via localhost:XXXX it works but it gets blocked when i connect via ip:XXXX

AdeD
  • 11
  • 2
  • Also found this [Link](https://stackoverflow.com/questions/34197653/getusermedia-in-chrome-47-without-using-https). For some reason, they have already made such a change and deleted it again. – AdeD Aug 09 '17 at 13:40
1

I have found that if the site is under SSL the SpeechRecognition works as expected on Chrome 60.

calebeaires
  • 1,972
  • 1
  • 22
  • 34