ghcjs / ghcjs-dom

Make Document Object Model (DOM) apps that run in any browser and natively using WebKitGtk
74 stars 41 forks source link

Enhancement request: Provide SpeechRecognition APIs in ghcjs-dom-ffi #81

Closed dfordivam closed 6 years ago

dfordivam commented 7 years ago

As specified here

https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition

This is a heads up to all that I am working on adding the support of these APIs.

I think this feature is only available on the browsers (and not on webkit), and therefore I am only putting this in the ghcjs-dom-ffi

If anyone has worked on this before let me know :)

dfordivam commented 7 years ago

One question: the current speech recognition interface require code like this

var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition
var recognition = new SpeechRecognition();

as the chrome prepends "webkit" to every object and firefox doesnt. How can we support this with our FFI calls?

Right now I did this for the chrome

foreign import javascript unsafe
    "new window[\"webkitSpeechRecognition\"]()"
    js_newSpeechRecognition :: IO SpeechRecognition
3noch commented 7 years ago

@dfordivam Sometimes I write my own shims.js and present a different API that is easier to work with from FFI.