stephenlb / spoken

Spoken - JavaScript Text-to-Speech and Speech-to-Text for AI Artificial Intelligence Apps
https://stephenlb.github.io/spoken/
70 stars 11 forks source link

Failed to run in electron environment. #9

Open chroma9 opened 3 years ago

chroma9 commented 3 years ago

When running in a test environment for Electron, spoken runs into an error quickly. Here is the code used.

spoken.listen.on.start( voice => { console.log('Started Listening') } );
spoken.listen.on.end(   voice => { console.log('Ended Listening')   } );
spoken.listen.on.error( voice => { console.log('Error Listening', voice)   } );
spoken.listen.on.partial( ts => console.log(ts) );
spoken.listen()
    .then(     ts => console.log("Partial: " + ts) )
    .catch( error => console.warn(error.message)   )

I then received the following error.

bubbles: false
cancelBubble: false
cancelable: false
composed: false
currentTarget: SpeechRecognition {grammars: SpeechGrammarList, lang: "en-US", continuous: false, interimResults: true, maxAlternatives: 1, …}
defaultPrevented: false
error: "network"
eventPhase: 0
isTrusted: true
message: ""
path: []
returnValue: true
srcElement: SpeechRecognition {grammars: SpeechGrammarList, lang: "en-US", continuous: false, interimResults: true, maxAlternatives: 1, …}
target: SpeechRecognition {grammars: SpeechGrammarList, lang: "en-US", continuous: false, interimResults: true, maxAlternatives: 1, …}
timeStamp: 472.00499998871237
type: "error"

I hope you can get back to me.

stephenlb commented 3 years ago

error: "network" looks like may be a permissions issue. In electron config/system this may be needed: https://www.electronjs.org/docs/api/system-preferences#systempreferencesgetmediaaccessstatusmediatype-windows-macos

stephenlb commented 3 years ago

https://stackoverflow.com/questions/47226889/speechrecognition-network-error-when-working-with-electron-chromium-browser

Everything must be done over HTTPS to allow this technology to work.

HTTPS details: https://github.com/stephenlb/spoken#speech-to-text