From: Cedric Godin Date: Wed, 28 Feb 2018 15:51:50 +0000 (-0500) Subject: Fixed google speech toggle X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=7a75cc234d7a410ed32097b143973e7f072f1a7f;p=yn%2Fyn-odasweb.git Fixed google speech toggle --- diff --git a/resources/js/configure-model.js b/resources/js/configure-model.js index 1a5b911..31cfbe3 100644 --- a/resources/js/configure-model.js +++ b/resources/js/configure-model.js @@ -102,7 +102,7 @@ saveButton.addEventListener('click', event => { } }); -keyfileInput.addEventListener('click', event => { +const browseKey = function(event) { dialog.showOpenDialog( {properties: ['openFile'], title: 'Select Google Api key file'}, @@ -111,7 +111,7 @@ keyfileInput.addEventListener('click', event => { configureModel.apiKeyfile = files[0]; } ); -}); +} /* * Get settings from main process diff --git a/resources/js/speech-to-text.js b/resources/js/speech-to-text.js index 22bb077..fc50836 100644 --- a/resources/js/speech-to-text.js +++ b/resources/js/speech-to-text.js @@ -45,9 +45,9 @@ const processData = function(data) { } exports.processFile = function(filepath) { - if(appSettings.useSpeech == true) { + if(appSettings.useSpeech) { return readFile(filepath).then(content => processData(content)); } else - return ''; + return Promise.resolve(''); } diff --git a/settings.js b/settings.js index cd191ae..c831154 100644 --- a/settings.js +++ b/settings.js @@ -30,7 +30,7 @@ class AppSettings { } get sampleRate() { - return localStorage.getItem('sample-rate'); + return parseInt(localStorage.getItem('sample-rate')); } set apiKeyfile(apiKeyfile) { @@ -46,7 +46,7 @@ class AppSettings { } get useSpeech() { - return localStorage.getItem('use-speech'); + return localStorage.getItem('use-speech') === 'true'; } } diff --git a/stream-to-text.js b/stream-to-text.js index 52e2bea..583373e 100644 --- a/stream-to-text.js +++ b/stream-to-text.js @@ -10,7 +10,7 @@ exports.Transcripter = class Transcripter extends EventEmitter { } start() { - if(appSettings.useSpeech == true) { + if(appSettings.useSpeech) { const client = new speech.SpeechClient({ keyFilename: appSettings.apiKeyfile diff --git a/views/configure.html b/views/configure.html index a70b9ad..93fe6c3 100644 --- a/views/configure.html +++ b/views/configure.html @@ -32,7 +32,7 @@
- +