update voice
This commit is contained in:
parent
9ff21cf7b8
commit
79240b1a24
8 changed files with 90 additions and 125 deletions
|
@ -10,13 +10,15 @@
|
|||
items = shuffleArray(items);
|
||||
}
|
||||
|
||||
items = items.map(function (i) {
|
||||
return i.Id;
|
||||
});
|
||||
|
||||
if (items.length) {
|
||||
var serverId = items[0].ServerId;
|
||||
items = items.map(function (i) {
|
||||
return i.Id;
|
||||
});
|
||||
|
||||
playbackManager.play({
|
||||
ids: items
|
||||
ids: items,
|
||||
serverId: serverId
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
@ -63,6 +65,7 @@
|
|||
}
|
||||
|
||||
var apiClient = connectionManager.currentApiClient();
|
||||
|
||||
if (result.item.sourceid === 'nextup') {
|
||||
|
||||
apiClient.getNextUpEpisodes(query).then(function (queryResult) {
|
||||
|
@ -90,7 +93,6 @@
|
|||
query.Filters = 'IsFavorite';
|
||||
}
|
||||
|
||||
|
||||
apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (queryResult) {
|
||||
|
||||
playItems(queryResult.Items, result.item.shuffle);
|
||||
|
|
|
@ -85,7 +85,6 @@ define([], function () {
|
|||
},
|
||||
command: null,
|
||||
text: text,
|
||||
userId: Dashboard.getCurrentUserId(),
|
||||
success: false
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['dialogHelper', './voicereceiver', './voiceprocessor', 'globalize', 'emby-button', 'css!./voice.css', 'material-icons', 'css!./../formdialog'], function (dialogHelper, voicereceiver, voiceprocessor, globalize) {
|
||||
define(['dialogHelper', 'voiceReceiver', 'voiceProcessor', 'globalize', 'emby-button', 'css!./voice.css', 'material-icons', 'css!./../formdialog'], function (dialogHelper, voicereceiver, voiceprocessor, globalize) {
|
||||
|
||||
var lang = 'en-US';
|
||||
|
||||
|
@ -244,7 +244,11 @@ define(['dialogHelper', './voicereceiver', './voiceprocessor', 'globalize', 'emb
|
|||
listen();
|
||||
}
|
||||
function listen() {
|
||||
voicereceiver.listenForCommand(lang || "en-US").then(processInput).then(function (result) {
|
||||
voicereceiver.listen({
|
||||
|
||||
lang: lang || "en-US"
|
||||
|
||||
}).then(processInput).then(function (result) {
|
||||
|
||||
closeDialog();
|
||||
|
||||
|
|
|
@ -23,24 +23,27 @@
|
|||
/// <returns> . </returns>
|
||||
function processTranscript(text) {
|
||||
if (text) {
|
||||
var processor = grammarprocessor(commandgroups, text);
|
||||
if (processor && processor.command) {
|
||||
console.log("Command from Grammar Processor", processor);
|
||||
return voicecommands(processor)
|
||||
.then(function (result) {
|
||||
|
||||
console.log("Result of executed command", result);
|
||||
if (result.item.actionid === 'show' && result.item.sourceid === 'group') {
|
||||
return Promise.resolve({ error: "group", item: result.item, groupName: result.name, fn: result.fn });
|
||||
} else {
|
||||
return Promise.resolve({ item: result.item, fn: result.fn });
|
||||
}
|
||||
}, function () {
|
||||
return Promise.reject({ error: "unrecognized-command", text: text });
|
||||
});
|
||||
} else {
|
||||
return Promise.reject({ error: "unrecognized-command", text: text });
|
||||
}
|
||||
return getCommandGroups().then(function (commandgroups) {
|
||||
var processor = grammarprocessor(commandgroups, text);
|
||||
if (processor && processor.command) {
|
||||
console.log("Command from Grammar Processor", processor);
|
||||
return voicecommands(processor)
|
||||
.then(function (result) {
|
||||
|
||||
console.log("Result of executed command", result);
|
||||
if (result.item.actionid === 'show' && result.item.sourceid === 'group') {
|
||||
return Promise.resolve({ error: "group", item: result.item, groupName: result.name, fn: result.fn });
|
||||
} else {
|
||||
return Promise.resolve({ item: result.item, fn: result.fn });
|
||||
}
|
||||
}, function () {
|
||||
return Promise.reject({ error: "unrecognized-command", text: text });
|
||||
});
|
||||
} else {
|
||||
return Promise.reject({ error: "unrecognized-command", text: text });
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
return Promise.reject({ error: "empty" });
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
define([], function () {
|
||||
var currentRecognition = null;
|
||||
define(['events'], function (events) {
|
||||
|
||||
var receiver = {
|
||||
|
||||
};
|
||||
|
||||
var currentRecognition = null;
|
||||
|
||||
/// <summary> Starts listening for voice commands </summary>
|
||||
/// <returns> . </returns>
|
||||
function listenForCommand(lang) {
|
||||
function listen(options) {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
cancelListener();
|
||||
|
||||
|
@ -13,13 +18,28 @@
|
|||
window.mozSpeechRecognition ||
|
||||
window.oSpeechRecognition ||
|
||||
window.msSpeechRecognition)();
|
||||
recognition.lang = lang;
|
||||
|
||||
recognition.lang = options.lang;
|
||||
recognition.continuous = options.continuous || false;
|
||||
|
||||
var resultCount = 0;
|
||||
|
||||
recognition.onresult = function (event) {
|
||||
console.log(event);
|
||||
if (event.results.length > 0) {
|
||||
var resultInput = event.results[0][0].transcript || '';
|
||||
resolve(resultInput);
|
||||
|
||||
var resultInput = event.results[resultCount][0].transcript || '';
|
||||
resultCount++;
|
||||
|
||||
if (options.continuous) {
|
||||
events.trigger(receiver, 'input', [
|
||||
{
|
||||
text: resultInput
|
||||
}
|
||||
]);
|
||||
} else {
|
||||
resolve(resultInput);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -36,7 +56,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Cancel listener. </summary>
|
||||
/// <returns> . </returns>
|
||||
function cancelListener() {
|
||||
|
@ -48,10 +67,9 @@
|
|||
|
||||
}
|
||||
|
||||
/// <summary> An enum constant representing the window. voice input manager option. </summary>
|
||||
return {
|
||||
listenForCommand: listenForCommand,
|
||||
cancel: cancelListener
|
||||
};
|
||||
receiver.listen = listen;
|
||||
receiver.cancel = cancelListener;
|
||||
|
||||
/// <summary> An enum constant representing the window. voice input manager option. </summary>
|
||||
return receiver;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue