webkitSpeechRecognition throws error “network”

血红的双手。 提交于 2019-12-11 06:21:48

问题


I have an speech recognition (using webkitSpeechRecognition) application which works great when ran on the standalone chrome browser.

I converted my application into a electron package and it stops listening to the microphone and sends back an error with message "network". The documentation says "Network communication required for completing the recognition failed.". However it works good in chrome directly without any issues.

I have also used "SpeechSynthesisUtterance" for text to speech and that works without any issue on electron.

I had the solution working good couple of weeks ago during generating Proof Of Concept and it stopped working as well.

Anybody has any idea what could be the wrong?


回答1:


I got it working with my own Google Speech API key.

Please obtain as per the instruction given on https://docs.smart-mirror.io/docs/howto/how_to_obtain_chromium_speech_keys.html

Once you have API Key, ClientID and ClientSecret set them into your computer's environment variables with key GOOGLE_API_KEY, GOOGLE_DEFAULT_CLIENT_ID, GOOGLE_DEFAULT_CLIENT_SECRET respectively.

Make sure to restart your system after configuring the environment variables. Sometimes they don't get into affect immediately.




回答2:


From https://www.chromium.org/developers/how-tos/api-keys

It is NOT possible to get additional quota for Chrome's Speech API. Look at the Cloud Speech API instead.

Do NOT post to any Chromium groups/mailing lists for questions about the Speech API.

And

Many of the Google APIs used by Chromium code are specific to Google Chrome and not intended for use in derived products. In the API Console (http://developers.google.com/console) you may be able to purchase additional quota for some of the APIs listed above. For APIs that do not have a "Pricing" link, additional quota is not available for purchase.

So I think you're simply out of luck, you'll have to use something else. If you need something that works offline you might want to take a look at Sphinx.



来源:https://stackoverflow.com/questions/39835083/webkitspeechrecognition-throws-error-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!