-
Notifications
You must be signed in to change notification settings - Fork 289
Doesn't work in electron (or with fallback set to true) #547
Comments
@alexander-fenster potentially worth creating a tracking bug in |
@sebakerckhof For browser / electron users, const client = new speech.SpeechClient({fallback: true}); If Also, make sure you take care of authentication properly, in non-Node.js context you might need to use OAuth2. More details here. |
This comment has been minimized.
This comment has been minimized.
I have the same issue. And I noticed one weirdness. Line 47 in bec2561
google-gax version in module via yarn add @google-cloud/speech is:1.11.2 so... v2 have breaking changes, but for some reason, the wrong version is indicated in the package.json npm module ... I tried to install the package directly from a GIT using: But apparently, due to WinOs, I get an error: |
@gormonn A few problems listed here, let's go one by one :)
|
@alexander-fenster Tnx for advice. I'm downloading cygwin and packages now. While it is downloading, I want to clarify a couple of points. In the Electron Main process (NodeJs v12), the module works without problems. When I try to use this module in the Renderer process (Frontend - browser), I get the main problem. I watched the call stack. And I found that I tried to do as you said: |
Oh, I think I figured out what's wrong. Apparently, Electron does not support nodejs-speech/src/v1/speech_client.ts Lines 101 to 108 in 4abdb5c
The real browser would've followed the This indeed looks like a bug, I'll think how to fix it properly and will update this issue. As a workaround, can you try packing the code with |
I make it by Tell me, do I understand the reasons for using OAuth2 on the client side correctly? We have a slightly different principle of software delivery. For example: Is there a way around this limitation? Using our client-side credentials. |
@gormonn In your specific case (kiosk application), you can use API keys for authentication. We don't advertise this option too much because we really don't want it to be used in browsers (where users could easily see the api key in the source code). For those who read it: the example below can only be used in kiosk usecase. For regular browsers, please use Quick'n'dirty example: https://gist.github.com/alexander-fenster/5ee5f04423ede10f008ae59e4b10d9c4 (I tested this in Chrome but not in Electron, but should be pretty much the same) Let me know if you need help! |
@sebakerckhof @gormonn closing this, since it looks like @alexander-fenster's approach should work. Please let us know if you bump in to any issues. |
apikey approach still failing for me, node 12, electron 6.0.12, same path error works ok when the code is run from terminal window node xxx.js but not inside electron just trying to enable GoogleAssistant conversation (ended=continueConversation) when we have an external speech recognizer inside https://github.com/evancohen/smart-mirror.. the main process spins off reco into background task, with emitted recognized words. i need to ask it to stop, as it does hotword detection. and then turn on replica engine with no hotword detection.. I am using GA in console input mode, so can't switch to audio mode in the middle of the conversation browserWindow is in kiosk mode |
@sdetweil Webpacking the source code would've helped, but if you're unable to, then please just wait for the fix for this which is coming soon (I have a tracking issue for nodejs-vision here, this one is exactly the same problem - but I'll reopen it just to make sure it's tracked properly). As a workaround, you can fix the module locally to do this._gaxModule = gax.fallback; instead of what is written in the line 108 below. https://github.com/googleapis/nodejs-speech/blob/master/src/v1/speech_client.ts#L108 |
I don't see that file // If we are in browser, we are already using fallback because of the well, it got closer
|
I decided that I would spin off a background node process to handle this until such time as in browser support comes along.. minor change to my package |
@sdetweil If you can move the logic to the background process, this is the best possible solution here. Two more points:
|
2, thanks the code is not mine that does the speech reco.. spun off to background task |
Hello there, |
Environment details
@google-cloud/speech
version: 3.6.0Steps to reproduce
it throws following error:
This happens because:
First there is this check setting the fallback option to true in a browser window:
https://github.com/googleapis/nodejs-speech/blob/master/src/v1/speech_client.ts#L94-L96
Next there is this line loading the proto's:
https://github.com/googleapis/nodejs-speech/blob/master/src/v1/speech_client.ts#L135-L137
So in the case
fallback
istrue
, it will load the json file and pass that toloadProto
. ButloadProto
expects a filepath. So I think the require in this line should just not be there:https://github.com/googleapis/nodejs-speech/blob/master/src/v1/speech_client.ts#L136
However, this is not yet sufficient, since it then will still fail in electron environments.
isBrowser
should just be false for electron.The text was updated successfully, but these errors were encountered: