mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-10 14:48:40 +00:00
implement voice navigation
This commit is contained in:
parent
6691f99f40
commit
1174a90dfe
|
|
@ -59,12 +59,18 @@ export class VoiceManager
|
||||||
}
|
}
|
||||||
|
|
||||||
this.recognition.onstart = function() {};
|
this.recognition.onstart = function() {};
|
||||||
|
this.recognition.addEventListener('end', this.recognition.start);
|
||||||
|
|
||||||
this.recognition.onresult = function(event)
|
this.recognition.onresult = function(event)
|
||||||
{
|
{
|
||||||
let result = jsOMS.trim(event.results[event.resultIndex][0].transcript);
|
let result = jsOMS.trim(event.results[event.resultIndex][0].transcript);
|
||||||
|
|
||||||
if (self.commands.hasOwnProperty(result)) {
|
const commands = Object.keys(self.commands);
|
||||||
self.commands[result]();
|
|
||||||
|
for (let command of commands) {
|
||||||
|
if (result.startsWith(command)) {
|
||||||
|
self.commands[command](result.substr(command.length).trim());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user