ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / resources / hotword / constants.js
blob55a3d30dc7881976c9c33796433e77a468d6c3a4
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 cr.define('hotword.constants', function() {
6 'use strict';
8 /**
9 * Number of seconds of audio to record when logging is enabled.
10 * @const {number}
12 var AUDIO_LOG_SECONDS = 2;
14 /**
15 * Hotword data shared module extension's ID.
16 * @const {string}
18 var SHARED_MODULE_ID = 'lccekmodgklaepjeofjdjpbminllajkg';
20 /**
21 * Path to shared module data.
22 * @const {string}
24 var SHARED_MODULE_ROOT = '_modules/' + SHARED_MODULE_ID;
26 /**
27 * Name used by the content scripts to create communications Ports.
28 * @const {string}
30 var CLIENT_PORT_NAME = 'chwcpn';
32 /**
33 * The field name to specify the command among pages.
34 * @const {string}
36 var COMMAND_FIELD_NAME = 'cmd';
38 /**
39 * The speaker model file name.
40 * @const {string}
42 var SPEAKER_MODEL_FILE_NAME = 'speaker_model.data';
44 /**
45 * The training utterance file name prefix.
46 * @const {string}
48 var UTTERANCE_FILE_PREFIX = 'utterance-';
50 /**
51 * The training utterance file extension.
52 * @const {string}
54 var UTTERANCE_FILE_EXTENSION = '.raw';
56 /**
57 * The number of training utterances required to train the speaker model.
58 * @const {number}
60 var NUM_TRAINING_UTTERANCES = 3;
62 /**
63 * The size of the file system requested for reading the speaker model and
64 * utterances. This number should always be larger than the combined file size,
65 * currently 576338 bytes as of February 2015.
66 * @const {number}
68 var FILE_SYSTEM_SIZE_BYTES = 1048576;
70 /**
71 * Time to wait for expected messages, in milliseconds.
72 * @enum {number}
74 var TimeoutMs = {
75 SHORT: 200,
76 NORMAL: 500,
77 LONG: 2000
80 /**
81 * The URL of the files used by the plugin.
82 * @enum {string}
84 var File = {
85 RECOGNIZER_CONFIG: 'hotword.data',
88 /**
89 * Errors emitted by the NaClManager.
90 * @enum {string}
92 var Error = {
93 NACL_CRASH: 'nacl_crash',
94 TIMEOUT: 'timeout',
97 /**
98 * Event types supported by NaClManager.
99 * @enum {string}
101 var Event = {
102 READY: 'ready',
103 TRIGGER: 'trigger',
104 SPEAKER_MODEL_SAVED: 'speaker model saved',
105 ERROR: 'error',
109 * Messages for communicating with the NaCl recognizer plugin. These must match
110 * constants in <google3>/hotword_plugin.c
111 * @enum {string}
113 var NaClPlugin = {
114 RESTART: 'r',
115 SAMPLE_RATE_PREFIX: 'h',
116 MODEL_PREFIX: 'm',
117 STOP: 's',
118 LOG: 'l',
119 BEGIN_SPEAKER_MODEL: 'b',
120 ADAPT_SPEAKER_MODEL: 'a',
121 FINISH_SPEAKER_MODEL: 'f',
122 SPEAKER_MODEL_SAVED: 'sm_saved',
123 REQUEST_MODEL: 'model',
124 MODEL_LOADED: 'model_loaded',
125 READY_FOR_AUDIO: 'audio',
126 STOPPED: 'stopped',
127 HOTWORD_DETECTED: 'hotword',
128 MS_CONFIGURED: 'ms_configured'
132 * Messages sent from the injected scripts to the Google page.
133 * @enum {string}
135 var CommandToPage = {
136 HOTWORD_VOICE_TRIGGER: 'vt',
137 HOTWORD_STARTED: 'hs',
138 HOTWORD_ENDED: 'hd',
139 HOTWORD_TIMEOUT: 'ht',
140 HOTWORD_ERROR: 'he'
144 * Messages sent from the Google page to the injected scripts
145 * and then passed to the extension.
146 * @enum {string}
148 var CommandFromPage = {
149 SPEECH_START: 'ss',
150 SPEECH_END: 'se',
151 SPEECH_RESET: 'sr',
152 SHOWING_HOTWORD_START: 'shs',
153 SHOWING_ERROR_MESSAGE: 'sem',
154 SHOWING_TIMEOUT_MESSAGE: 'stm',
155 CLICKED_RESUME: 'hcc',
156 CLICKED_RESTART: 'hcr',
157 CLICKED_DEBUG: 'hcd',
158 WAKE_UP_HELPER: 'wuh'
162 * Source of a hotwording session request.
163 * @enum {string}
165 var SessionSource = {
166 LAUNCHER: 'launcher',
167 NTP: 'ntp',
168 ALWAYS: 'always',
169 TRAINING: 'training'
173 * The mode to start the hotword recognizer in.
174 * @enum {string}
176 var RecognizerStartMode = {
177 NORMAL: 'normal',
178 NEW_MODEL: 'new model',
179 ADAPT_MODEL: 'adapt model'
183 * MediaStream open success/errors to be reported via UMA.
184 * DO NOT remove or renumber values in this enum. Only add new ones.
185 * @enum {number}
187 var UmaMediaStreamOpenResult = {
188 SUCCESS: 0,
189 UNKNOWN: 1,
190 NOT_SUPPORTED: 2,
191 PERMISSION_DENIED: 3,
192 CONSTRAINT_NOT_SATISFIED: 4,
193 OVERCONSTRAINED: 5,
194 NOT_FOUND: 6,
195 ABORT: 7,
196 SOURCE_UNAVAILABLE: 8,
197 PERMISSION_DISMISSED: 9,
198 INVALID_STATE: 10,
199 DEVICES_NOT_FOUND: 11,
200 INVALID_SECURITY_ORIGIN: 12,
201 MAX: 12
205 * UMA metrics.
206 * DO NOT change these enum values.
207 * @enum {string}
209 var UmaMetrics = {
210 TRIGGER: 'Hotword.HotwordTrigger',
211 MEDIA_STREAM_RESULT: 'Hotword.HotwordMediaStreamResult',
212 NACL_PLUGIN_LOAD_RESULT: 'Hotword.HotwordNaClPluginLoadResult',
213 NACL_MESSAGE_TIMEOUT: 'Hotword.HotwordNaClMessageTimeout',
214 TRIGGER_SOURCE: 'Hotword.HotwordTriggerSource'
218 * Message waited for by NaCl plugin, to be reported via UMA.
219 * DO NOT remove or renumber values in this enum. Only add new ones.
220 * @enum {number}
222 var UmaNaClMessageTimeout = {
223 REQUEST_MODEL: 0,
224 MODEL_LOADED: 1,
225 READY_FOR_AUDIO: 2,
226 STOPPED: 3,
227 HOTWORD_DETECTED: 4,
228 MS_CONFIGURED: 5,
229 MAX: 5
233 * NaCl plugin load success/errors to be reported via UMA.
234 * DO NOT remove or renumber values in this enum. Only add new ones.
235 * @enum {number}
237 var UmaNaClPluginLoadResult = {
238 SUCCESS: 0,
239 UNKNOWN: 1,
240 CRASH: 2,
241 NO_MODULE_FOUND: 3,
242 MAX: 3
246 * Source of hotword triggering, to be reported via UMA.
247 * DO NOT remove or renumber values in this enum. Only add new ones.
248 * @enum {number}
250 var UmaTriggerSource = {
251 LAUNCHER: 0,
252 NTP_GOOGLE_COM: 1,
253 ALWAYS_ON: 2,
254 TRAINING: 3,
255 MAX: 3
259 * The browser UI language.
260 * @const {string}
262 var UI_LANGUAGE = (chrome.i18n && chrome.i18n.getUILanguage) ?
263 chrome.i18n.getUILanguage() : '';
265 return {
266 AUDIO_LOG_SECONDS: AUDIO_LOG_SECONDS,
267 CLIENT_PORT_NAME: CLIENT_PORT_NAME,
268 COMMAND_FIELD_NAME: COMMAND_FIELD_NAME,
269 FILE_SYSTEM_SIZE_BYTES: FILE_SYSTEM_SIZE_BYTES,
270 NUM_TRAINING_UTTERANCES: NUM_TRAINING_UTTERANCES,
271 SHARED_MODULE_ID: SHARED_MODULE_ID,
272 SHARED_MODULE_ROOT: SHARED_MODULE_ROOT,
273 SPEAKER_MODEL_FILE_NAME: SPEAKER_MODEL_FILE_NAME,
274 UI_LANGUAGE: UI_LANGUAGE,
275 UTTERANCE_FILE_EXTENSION: UTTERANCE_FILE_EXTENSION,
276 UTTERANCE_FILE_PREFIX: UTTERANCE_FILE_PREFIX,
277 CommandToPage: CommandToPage,
278 CommandFromPage: CommandFromPage,
279 Error: Error,
280 Event: Event,
281 File: File,
282 NaClPlugin: NaClPlugin,
283 RecognizerStartMode: RecognizerStartMode,
284 SessionSource: SessionSource,
285 TimeoutMs: TimeoutMs,
286 UmaMediaStreamOpenResult: UmaMediaStreamOpenResult,
287 UmaMetrics: UmaMetrics,
288 UmaNaClMessageTimeout: UmaNaClMessageTimeout,
289 UmaNaClPluginLoadResult: UmaNaClPluginLoadResult,
290 UmaTriggerSource: UmaTriggerSource