mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update voice
This commit is contained in:
parent
b13e561c6c
commit
c6ba4e2a10
3 changed files with 59 additions and 50 deletions
|
@ -29,7 +29,7 @@
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
html += '<paper-icon-button icon="mic" class="headerButton headerButtonRight headerVoiceButton hide" onclick="VoiceInputManager.startListening();"></paper-icon-button>';
|
html += '<paper-icon-button icon="mic" class="headerButton headerButtonRight headerVoiceButton hide"></paper-icon-button>';
|
||||||
|
|
||||||
html += '<paper-button class="headerButton headerButtonRight btnNotifications subdued" type="button" title="Notifications"><div class="btnNotificationsInner">0</div></paper-button>';
|
html += '<paper-button class="headerButton headerButtonRight btnNotifications subdued" type="button" title="Notifications"><div class="btnNotificationsInner">0</div></paper-button>';
|
||||||
|
|
||||||
|
@ -136,9 +136,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
requirejs(['voice/voice'], function () {
|
require(['voice/voice'], function (voice) {
|
||||||
|
|
||||||
if (VoiceInputManager.isSupported()) {
|
if (voice.isSupported()) {
|
||||||
header.querySelector('.headerVoiceButton').classList.remove('hide');
|
header.querySelector('.headerVoiceButton').classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
header.querySelector('.headerVoiceButton').classList.add('hide');
|
header.querySelector('.headerVoiceButton').classList.add('hide');
|
||||||
|
@ -159,6 +159,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showVoice() {
|
||||||
|
require(['voice/voice'], function (voice) {
|
||||||
|
voice.startListening();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function bindMenuEvents() {
|
function bindMenuEvents() {
|
||||||
|
|
||||||
var mainDrawerButton = document.querySelector('.mainDrawerButton');
|
var mainDrawerButton = document.querySelector('.mainDrawerButton');
|
||||||
|
@ -172,6 +178,11 @@
|
||||||
headerBackButton.addEventListener('click', onBackClick);
|
headerBackButton.addEventListener('click', onBackClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var headerVoiceButton = document.querySelector('.headerVoiceButton');
|
||||||
|
if (headerVoiceButton) {
|
||||||
|
headerVoiceButton.addEventListener('click', showVoice);
|
||||||
|
}
|
||||||
|
|
||||||
var viewMenuBar = document.querySelector(".viewMenuBar");
|
var viewMenuBar = document.querySelector(".viewMenuBar");
|
||||||
initHeadRoom(viewMenuBar);
|
initHeadRoom(viewMenuBar);
|
||||||
|
|
||||||
|
@ -904,7 +915,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
requirejs(["headroom"], function () {
|
require(["headroom"], function () {
|
||||||
|
|
||||||
// construct an instance of Headroom, passing the element
|
// construct an instance of Headroom, passing the element
|
||||||
var headroom = new Headroom(elem, {
|
var headroom = new Headroom(elem, {
|
||||||
|
|
|
@ -8,56 +8,56 @@
|
||||||
"sourceid": "group",
|
"sourceid": "group",
|
||||||
"groupid": "movie",
|
"groupid": "movie",
|
||||||
"command": "(?<action>show|display|view)\\s?(?<source>Movie)?\\s?(?<text>based commands)",
|
"command": "(?<action>show|display|view)\\s?(?<source>Movie)?\\s?(?<text>based commands)",
|
||||||
"commandtemplates": [ "Show Movie based commands" ]
|
"commandtemplates": [ "Show movie commands" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"actionid": "show",
|
"actionid": "show",
|
||||||
"sourceid": "group",
|
"sourceid": "group",
|
||||||
"groupid": "music",
|
"groupid": "music",
|
||||||
"command": "(?<action>show|display|view)\\s?(?<source>Music)?\\s?(?<text>based commands)",
|
"command": "(?<action>show|display|view)\\s?(?<source>Music)?\\s?(?<text>based commands)",
|
||||||
"commandtemplates": [ "Show Music based commands" ]
|
"commandtemplates": [ "Show music commands" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"actionid": "show",
|
"actionid": "show",
|
||||||
"sourceid": "group",
|
"sourceid": "group",
|
||||||
"groupid": "picture",
|
"groupid": "picture",
|
||||||
"command": "(?<action>show|display|view)\\s?(?<source>Picture)?\\s?(?<text>based commands)",
|
"command": "(?<action>show|display|view)\\s?(?<source>Picture)?\\s?(?<text>based commands)",
|
||||||
"commandtemplates": [ "Show Picture based commands" ]
|
"commandtemplates": [ "Show photo commands" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"actionid": "show",
|
"actionid": "show",
|
||||||
"sourceid": "group",
|
"sourceid": "group",
|
||||||
"groupid": "tvseries",
|
"groupid": "tvseries",
|
||||||
"command": "(?<action>show|display|view)\\s?(?<source>TV series)?\\s?(?<text>based commands)",
|
"command": "(?<action>show|display|view)\\s?(?<source>TV series)?\\s?(?<text>based commands)",
|
||||||
"commandtemplates": [ "Show TV series based commands" ]
|
"commandtemplates": [ "Show tv library commands" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"actionid": "show",
|
"actionid": "show",
|
||||||
"sourceid": "group",
|
"sourceid": "group",
|
||||||
"groupid": "home",
|
"groupid": "home",
|
||||||
"command": "(?<action>show|display|view)\\s?(?<source>home page)?\\s?(?<text>based commands)",
|
"command": "(?<action>show|display|view)\\s?(?<source>home page)?\\s?(?<text>based commands)",
|
||||||
"commandtemplates": [ "Show home page based commands" ]
|
"commandtemplates": [ "Show home screen commands" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"actionid": "show",
|
"actionid": "show",
|
||||||
"sourceid": "group",
|
"sourceid": "group",
|
||||||
"groupid": "general",
|
"groupid": "general",
|
||||||
"command": "(?<action>show|display|view)\\s?(?<source>general)?\\s?(?<text>group commands)",
|
"command": "(?<action>show|display|view)\\s?(?<source>general)?\\s?(?<text>group commands)",
|
||||||
"commandtemplates": [ "Show general group commands" ]
|
"commandtemplates": [ "Show general commands" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"actionid": "show",
|
"actionid": "show",
|
||||||
"sourceid": "group",
|
"sourceid": "group",
|
||||||
"groupid": "devices",
|
"groupid": "devices",
|
||||||
"command": "(?<action>show|display|view)\\s?(?<source>devices)?\\s?(?<text>based commands)",
|
"command": "(?<action>show|display|view)\\s?(?<source>devices)?\\s?(?<text>based commands)",
|
||||||
"commandtemplates": [ "Show devices based commands" ]
|
"commandtemplates": [ "Show device commands" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"actionid": "show",
|
"actionid": "show",
|
||||||
"sourceid": "group",
|
"sourceid": "group",
|
||||||
"groupid": "livetv",
|
"groupid": "livetv",
|
||||||
"command": "(?<action>show|display|view)\\s?(?<source>live tv)?\\s?(?<text>based commands)",
|
"command": "(?<action>show|display|view)\\s?(?<source>live tv)?\\s?(?<text>based commands)",
|
||||||
"commandtemplates": [ "Show Live TV based commands" ]
|
"commandtemplates": [ "Show live tv commands" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,10 +1,36 @@
|
||||||
define(['paperdialoghelper'], function (paperDialogHelper) {
|
define(['paperdialoghelper'], function (paperDialogHelper) {
|
||||||
|
|
||||||
var currentRecognition;
|
var currentRecognition;
|
||||||
var lang = 'grammar';
|
var lang = 'en-US';
|
||||||
//var lang = 'en-US';
|
|
||||||
|
|
||||||
var commandgroups = getGrammarCommands(lang);
|
var commandgroups;
|
||||||
|
|
||||||
|
function getCommandGroups() {
|
||||||
|
|
||||||
|
if (commandgroups) {
|
||||||
|
return Promise.resolve(commandgroups);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
|
var file = "grammar";
|
||||||
|
//if (language && language.length > 0)
|
||||||
|
// file = language;
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', "voice/grammar/" + file + ".json", true);
|
||||||
|
|
||||||
|
xhr.onload = function (e) {
|
||||||
|
|
||||||
|
commandgroups = JSON.parse(this.response);
|
||||||
|
resolve(commandgroups);
|
||||||
|
}
|
||||||
|
|
||||||
|
xhr.onerror = reject;
|
||||||
|
|
||||||
|
xhr.send();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary> Shuffle array. </summary>
|
/// <summary> Shuffle array. </summary>
|
||||||
/// <param name="array"> The array. </param>
|
/// <param name="array"> The array. </param>
|
||||||
|
@ -32,12 +58,11 @@ define(['paperdialoghelper'], function (paperDialogHelper) {
|
||||||
/// <returns> The sample commands. </returns>
|
/// <returns> The sample commands. </returns>
|
||||||
function getSampleCommands(groupid) {
|
function getSampleCommands(groupid) {
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return getCommandGroups().then(function (commandGroups) {
|
||||||
|
|
||||||
groupid = typeof (groupid) !== 'undefined' ? groupid : '';
|
groupid = typeof (groupid) !== 'undefined' ? groupid : '';
|
||||||
|
|
||||||
var commands = [];
|
var commands = [];
|
||||||
commandgroups.map(function (group) {
|
commandGroups.map(function (group) {
|
||||||
if ((group.items && group.items.length > 0) && (groupid == group.groupid || groupid == '')) {
|
if ((group.items && group.items.length > 0) && (groupid == group.groupid || groupid == '')) {
|
||||||
|
|
||||||
group.items.map(function (item) {
|
group.items.map(function (item) {
|
||||||
|
@ -53,10 +78,8 @@ define(['paperdialoghelper'], function (paperDialogHelper) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
resolve(shuffleArray(commands));
|
return shuffleArray(commands);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Gets command group. </summary>
|
/// <summary> Gets command group. </summary>
|
||||||
|
@ -82,7 +105,7 @@ define(['paperdialoghelper'], function (paperDialogHelper) {
|
||||||
/// <returns> . </returns>
|
/// <returns> . </returns>
|
||||||
function renderSampleCommands(elem, commands) {
|
function renderSampleCommands(elem, commands) {
|
||||||
|
|
||||||
commands.length = Math.min(commands.length, 6);
|
commands.length = Math.min(commands.length, 4);
|
||||||
|
|
||||||
commands = commands.map(function (c) {
|
commands = commands.map(function (c) {
|
||||||
|
|
||||||
|
@ -124,7 +147,7 @@ define(['paperdialoghelper'], function (paperDialogHelper) {
|
||||||
|
|
||||||
html += '<div class="defaultVoiceHelp">';
|
html += '<div class="defaultVoiceHelp">';
|
||||||
|
|
||||||
html += '<h1>' + Globalize.translate('HeaderSaySomethingLike') + '</h1>';
|
html += '<h1 style="margin-bottom:1.25em;">' + Globalize.translate('HeaderSaySomethingLike') + '</h1>';
|
||||||
|
|
||||||
html += '<div class="exampleCommands">';
|
html += '<div class="exampleCommands">';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
@ -301,31 +324,6 @@ define(['paperdialoghelper'], function (paperDialogHelper) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Getgrammars the given language. </summary>
|
|
||||||
/// <param name="language"> The language. </param>
|
|
||||||
/// <returns> . </returns>
|
|
||||||
function getGrammarCommands(language) {
|
|
||||||
|
|
||||||
var file = "grammar";
|
|
||||||
if (language && language.length > 0)
|
|
||||||
file = language;
|
|
||||||
|
|
||||||
var grammar = (function () {
|
|
||||||
var grm = null;
|
|
||||||
$.ajax({
|
|
||||||
async: false,
|
|
||||||
global: false,
|
|
||||||
url: "voice/grammar/" + file + ".json",
|
|
||||||
dataType: "json",
|
|
||||||
success: function (data) {
|
|
||||||
grm = data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return grm;
|
|
||||||
})();
|
|
||||||
return grammar;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Speaks the given text. </summary>
|
/// <summary> Speaks the given text. </summary>
|
||||||
/// <param name="text"> The text. </param>
|
/// <param name="text"> The text. </param>
|
||||||
/// <returns> . </returns>
|
/// <returns> . </returns>
|
||||||
|
@ -353,7 +351,7 @@ define(['paperdialoghelper'], function (paperDialogHelper) {
|
||||||
|
|
||||||
|
|
||||||
/// <summary> An enum constant representing the window. voice input manager option. </summary>
|
/// <summary> An enum constant representing the window. voice input manager option. </summary>
|
||||||
window.VoiceInputManager = {
|
return {
|
||||||
|
|
||||||
isSupported: function () {
|
isSupported: function () {
|
||||||
|
|
||||||
|
@ -371,7 +369,7 @@ define(['paperdialoghelper'], function (paperDialogHelper) {
|
||||||
window.msSpeechRecognition;
|
window.msSpeechRecognition;
|
||||||
},
|
},
|
||||||
|
|
||||||
startListening: startListening,
|
startListening: startListening
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue