Answer the question
In order to leave comments, you need to log in
Speech recognition in chrome extension?
How can I implement speech recognition in a chrome extension? What kind of permission is needed?
Answer the question
In order to leave comments, you need to log in
You can use any third-party service by embedding it into your extension: after all, extensions have full access to sites. For example, you can place an invisible iframe inside the extension's popup window, where the Yandex.Translate website will be opened, and then it's a matter of technique - at the user's signal, record the voice by programmatically clicking on the button (voice input) and simply read the result from the text field
: that some sites forbid opening themselves inside an iframe, but this ban can be bypassed by removing the prohibiting header. To do this, place the following code in background.js:
chrome.webRequest.onHeadersReceived.addListener(
function(info) {
var headers = info.responseHeaders; // Получаем массив отсылаемых заголовков
// Обходим массив полученных заголовков:
for (var i=headers.length-1; i>=0; --i) {
var header = headers[i].name.toLowerCase(); // Считываем название того или иного заголовка
// При наличии совпадений, удаляем заголовок:
if (header == 'x-frame-options' || header == 'frame-options') {
headers.splice(i, 1);
}
}
return {responseHeaders: headers}; // Вовращаем почищенный массив заголовков назад
},
{ urls: [ '<all_urls>' ], types: [ 'sub_frame' ] },
['blocking', 'responseHeaders']
);
"permissions" : [ "webRequest", "webRequestBlocking", "https://web.whatsapp.com/*" ],
"background" : { "persistent": true, "scripts": [ "background.js" ] },
...
"content_scripts" : [ { "matches" : [ "https://web.whatsapp.com/*" ], "all_frames": true, "js" : [ "load.js" ] } ]
In principle, you can try any extension that you find in the Google store, such as Voisnot. I’ll add on my own that once I had the task of converting a record to text, so not a single resolution came up - everyone recognizes Russian speech very clumsily.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question