0

I'm trying to develop a Chrome extension that recognises speech in Google meet using Microsoft cognitive speech service. While trying to implement this, I'm getting the following errors

ERROR:

Refused to create a worker from 'blob:https://meet.google.com/4f586067-ea8f-4e7f-9215-51ef426d3c9a' because it violates the following Content Security Policy directive: "worker-src 'self'".

Refused to create a worker from 'blob:https://meet.google.com/4f586067-ea8f-4e7f-9215-51ef426d3c9a' because it violates the following Content Security Policy directive: "script-src 'nonce-+MDEaQqsMKs++6oR20YT3Q' 'unsafe-eval' 'self' ". Note that 'worker-src' was not explicitly set, so 'script-src' is used as a fallback.

I tried to resolve this error by adding "content_security_policy" in manifest.json.

"content_security_policy" : "script-src 'self'; script-src-elem 'self' data: blob:; worker-src 'self' data: blob:; object-src 'self'"

I am getting security error in cancel event of Azure speech recognition

SecurityError: Failed to construct 'Worker': Access to the script at 'blob:' is denied by the document's Content Security Policy

Also tried by downloading the sdk to my extension package and using it from there instead using the cdn link below directly in the script. But still the same error is throwing.

Azure speech service cdn: https://cdn.jsdelivr.net/npm/microsoft-cognitiveservices-speech-sdk@latest/distrib/browser/microsoft.cognitiveservices.speech.sdk.bundle-min.js

Can anybody please help me to solve this CSP issue with chrome extension?

Sulabha
  • 1
  • 1
  • The `content_security_policy` key won't help here because it's for extension pages not for web pages. You can try creating the worker in the background script or [add an extension iframe on the page](https://stackoverflow.com/a/15876614/) and create the worker inside. – wOxxOm Mar 17 '21 at 06:21
  • @wOxxOm Instead of creating a script tag to add the **sdk** link to web page I have to create an _iframe_ element as specified in this [link](https://stackoverflow.com/questions/15873904/adding-complex-html-using-a-chrome-content-script/15876614#15876614) – Sulabha Mar 17 '21 at 06:54
  • Yes. Inside that iframe you will have a standard extension page (like the popup page) where you can load js using the standard `` and create workers. – wOxxOm Mar 17 '21 at 06:56
  • @wOxxOm Tried the solution of `iframe` to resolve the CSP issue. The problem I am facing now is the communication between `iframe` and my `extension page`. So not able to start speech recognition. Also while trying to start speech recognition inside `iframe`, it is showing `AudioContext not available`. Is there any other solution to resolve this issue? – Sulabha Mar 19 '21 at 06:11

0 Answers0