Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Chrome extensions support WebSpeech API?

Do google Chrome extensions support Chrome's Web Speech speech recognition API? I have included some javascript to create a speech recognition object, but when I launch my extension, I am not prompted for microphone access.

This is not an issue with my code. I have searched on google, but I can't find any information on whether Chrome extensions support the Web Speech API. I just want a yes/no answer.

Note: I believe the WebSpeech API won't work for local files.

like image 595
Michael Zhao Avatar asked Jul 30 '13 18:07

Michael Zhao


People also ask

Is there a Chrome extension for text to speech?

Speechify is the leading text-to-speech extension for Google Chrome. With about a million users and 6,000+ reviews, it is one of the fastest growing app in the Chrome Web Store.

Are Chrome extensions APIs?

Chrome provides extensions with many special-purpose APIs like chrome. runtime and chrome.

Is Google speech API free?

Accurately convert speech into text with an API powered by the best of Google's AI research and technology. New customers get $300 in free credits to spend on Speech-to-Text. All customers get 60 minutes for transcribing and analyzing audio free per month, not charged against your credits.


Video Answer


1 Answers

The Web Speech API can already be used by Chrome extensions, even in the background page and extension button popups. The fact that it works is not necessarily an intended feature, and I have previously explained how it works and why it works in this answer to How to use webrtc insde google chrome extension?. The previous explanation is about WebRTC, but it applies equally to Web Speech, and can be used as follows:

  1. Instantiate a webkitSpeechRecognition instance and start recording.
  2. If a permission error is detected (onerror being triggered with event.error === 'not-allowed'), open an extension page (chrome-extension://[ID]/yourpage.html). This extension page can be opened in a new window, tab or iframe.
  3. From this page, request access to the microphone. getUserMedia and SpeechRecognition both share the (persistent) audio permission, so to detect whether audio recording is allowed, you could use getUserMedia to request the permission without activating speech recognition. For instance:

    navigator.webkitGetUserMedia({
        audio: true,
    }, function(stream) {
        stream.stop();
        // Now you know that you have audio permission. Do whatever you want...
    }, function() {
        // Aw. No permission (or no microphone available).
    });
    
like image 183
Rob W Avatar answered Oct 13 '22 02:10

Rob W