From 1174a90dfe1966b032abebfb9bea482f5e50f165 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 10 Jun 2020 23:54:13 +0200 Subject: [PATCH] implement voice navigation --- UI/Input/Voice/VoiceManager.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/UI/Input/Voice/VoiceManager.js b/UI/Input/Voice/VoiceManager.js index a219e68..750e8b5 100644 --- a/UI/Input/Voice/VoiceManager.js +++ b/UI/Input/Voice/VoiceManager.js @@ -59,12 +59,18 @@ export class VoiceManager } this.recognition.onstart = function() {}; + this.recognition.addEventListener('end', this.recognition.start); + this.recognition.onresult = function(event) { let result = jsOMS.trim(event.results[event.resultIndex][0].transcript); - if (self.commands.hasOwnProperty(result)) { - self.commands[result](); + const commands = Object.keys(self.commands); + + for (let command of commands) { + if (result.startsWith(command)) { + self.commands[command](result.substr(command.length).trim()); + } } };