Fixed google speech toggle
authorCedric Godin <cedric.godin@usherbrooke.ca>
Wed, 28 Feb 2018 15:51:50 +0000 (10:51 -0500)
committerCedric Godin <cedric.godin@usherbrooke.ca>
Wed, 28 Feb 2018 15:51:50 +0000 (10:51 -0500)
resources/js/configure-model.js
resources/js/speech-to-text.js
settings.js
stream-to-text.js
views/configure.html

index 1a5b9118b29404270256e4cc258885756f757dde..31cfbe3d37b07655aa2fb320ead7d19ae8a1230b 100644 (file)
@@ -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
index 22bb07785b1762eac770acf66469ec183cd6ccd0..fc50836af73bbf6bbda4499feb8c9376b294340c 100644 (file)
@@ -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('');
 }
index cd191ae1858c14937837706a4c03b8adb4c3f923..c831154286916f4170c94275d797a8cf35447c8c 100644 (file)
@@ -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';
     }
 }
 
index 52e2bead69b2f3934a1f2aed341c281f6682e9f6..583373eede67816a8b4dc8696fabe2a1b611e0bf 100644 (file)
@@ -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
index a70b9ad2538b7a0a6564f6675c5841f9876feaeb..93fe6c385e14b804cb77531e6cd9f94a4d0e9b44 100644 (file)
@@ -32,7 +32,7 @@
                 <div class="form-group" v-bind:class="{ 'has-error' : apiKeyfileError}" v-if="useSpeech">
                     <label for="api-keyfile-input" class="col-xs-3 control-label">Google API Keyfile</label>
                     <div class="col-xs-9">
-                        <input type="url" class="form-control" id="api-keyfile-input" v-model="apiKeyfile"/>
+                        <input type="url" class="form-control" id="api-keyfile-input" v-model="apiKeyfile" onclick="browseKey()"/>
                     </div>
                 </div>
                 <div class="form-group" v-bind:class="{ 'has-error' : languageStringError}" v-if="useSpeech">