Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / resources / hotword / constants.js
blob988f9b87d89cf741cf6b68ee75ff285799870c6b
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 * Timeout in seconds, for detecting false positives with a hotword stream.
16 * @const {number}
18 var HOTWORD_STREAM_TIMEOUT_SECONDS = 2;
20 /**
21 * Hotword data shared module extension's ID.
22 * @const {string}
24 var SHARED_MODULE_ID = 'lccekmodgklaepjeofjdjpbminllajkg';
26 /**
27 * Path to shared module data.
28 * @const {string}
30 var SHARED_MODULE_ROOT = '_modules/' + SHARED_MODULE_ID;
32 /**
33 * Name used by the content scripts to create communications Ports.
34 * @const {string}
36 var CLIENT_PORT_NAME = 'chwcpn';
38 /**
39 * The field name to specify the command among pages.
40 * @const {string}
42 var COMMAND_FIELD_NAME = 'cmd';
44 /**
45 * The speaker model file name.
46 * @const {string}
48 var SPEAKER_MODEL_FILE_NAME = 'speaker_model.data';
50 /**
51 * The training utterance file name prefix.
52 * @const {string}
54 var UTTERANCE_FILE_PREFIX = 'utterance-';
56 /**
57 * The training utterance file extension.
58 * @const {string}
60 var UTTERANCE_FILE_EXTENSION = '.raw';
62 /**
63 * The number of training utterances required to train the speaker model.
64 * @const {number}
66 var NUM_TRAINING_UTTERANCES = 3;
68 /**
69 * The size of the file system requested for reading the speaker model and
70 * utterances. This number should always be larger than the combined file size,
71 * currently 576338 bytes as of February 2015.
72 * @const {number}
74 var FILE_SYSTEM_SIZE_BYTES = 1048576;
76 /**
77 * Time to wait for expected messages, in milliseconds.
78 * @enum {number}
80 var TimeoutMs = {
81 SHORT: 200,
82 NORMAL: 500,
83 LONG: 2000
86 /**
87 * The URL of the files used by the plugin.
88 * @enum {string}
90 var File = {
91 RECOGNIZER_CONFIG: 'hotword.data',
94 /**
95 * Errors emitted by the NaClManager.
96 * @enum {string}
98 var Error = {
99 NACL_CRASH: 'nacl_crash',
100 TIMEOUT: 'timeout',
104 * Event types supported by NaClManager.
105 * @enum {string}
107 var Event = {
108 READY: 'ready',
109 TRIGGER: 'trigger',
110 SPEAKER_MODEL_SAVED: 'speaker model saved',
111 ERROR: 'error',
112 TIMEOUT: 'timeout',
116 * Messages for communicating with the NaCl recognizer plugin. These must match
117 * constants in <google3>/hotword_plugin.c
118 * @enum {string}
120 var NaClPlugin = {
121 RESTART: 'r',
122 SAMPLE_RATE_PREFIX: 'h',
123 MODEL_PREFIX: 'm',
124 STOP: 's',
125 LOG: 'l',
126 DSP: 'd',
127 BEGIN_SPEAKER_MODEL: 'b',
128 ADAPT_SPEAKER_MODEL: 'a',
129 FINISH_SPEAKER_MODEL: 'f',
130 SPEAKER_MODEL_SAVED: 'sm_saved',
131 REQUEST_MODEL: 'model',
132 MODEL_LOADED: 'model_loaded',
133 READY_FOR_AUDIO: 'audio',
134 STOPPED: 'stopped',
135 HOTWORD_DETECTED: 'hotword',
136 MS_CONFIGURED: 'ms_configured',
137 TIMEOUT: 'timeout'
141 * Messages sent from the injected scripts to the Google page.
142 * @enum {string}
144 var CommandToPage = {
145 HOTWORD_VOICE_TRIGGER: 'vt',
146 HOTWORD_STARTED: 'hs',
147 HOTWORD_ENDED: 'hd',
148 HOTWORD_TIMEOUT: 'ht',
149 HOTWORD_ERROR: 'he'
153 * Messages sent from the Google page to the extension or to the
154 * injected script and then passed to the extension.
155 * @enum {string}
157 var CommandFromPage = {
158 SPEECH_START: 'ss',
159 SPEECH_END: 'se',
160 SPEECH_RESET: 'sr',
161 SHOWING_HOTWORD_START: 'shs',
162 SHOWING_ERROR_MESSAGE: 'sem',
163 SHOWING_TIMEOUT_MESSAGE: 'stm',
164 CLICKED_RESUME: 'hcc',
165 CLICKED_RESTART: 'hcr',
166 CLICKED_DEBUG: 'hcd',
167 WAKE_UP_HELPER: 'wuh',
168 // Command specifically for the opt-in promo below this line.
169 // User has explicitly clicked 'no'.
170 CLICKED_NO_OPTIN: 'hcno',
171 // User has opted in.
172 CLICKED_OPTIN: 'hco',
173 // User clicked on the microphone.
174 PAGE_WAKEUP: 'wu'
178 * Source of a hotwording session request.
179 * @enum {string}
181 var SessionSource = {
182 LAUNCHER: 'launcher',
183 NTP: 'ntp',
184 ALWAYS: 'always',
185 TRAINING: 'training'
189 * The mode to start the hotword recognizer in.
190 * @enum {string}
192 var RecognizerStartMode = {
193 NORMAL: 'normal',
194 NEW_MODEL: 'new model',
195 ADAPT_MODEL: 'adapt model'
199 * MediaStream open success/errors to be reported via UMA.
200 * DO NOT remove or renumber values in this enum. Only add new ones.
201 * @enum {number}
203 var UmaMediaStreamOpenResult = {
204 SUCCESS: 0,
205 UNKNOWN: 1,
206 NOT_SUPPORTED: 2,
207 PERMISSION_DENIED: 3,
208 CONSTRAINT_NOT_SATISFIED: 4,
209 OVERCONSTRAINED: 5,
210 NOT_FOUND: 6,
211 ABORT: 7,
212 SOURCE_UNAVAILABLE: 8,
213 PERMISSION_DISMISSED: 9,
214 INVALID_STATE: 10,
215 DEVICES_NOT_FOUND: 11,
216 INVALID_SECURITY_ORIGIN: 12,
217 MAX: 12
221 * UMA metrics.
222 * DO NOT change these enum values.
223 * @enum {string}
225 var UmaMetrics = {
226 TRIGGER: 'Hotword.HotwordTrigger',
227 MEDIA_STREAM_RESULT: 'Hotword.HotwordMediaStreamResult',
228 NACL_PLUGIN_LOAD_RESULT: 'Hotword.HotwordNaClPluginLoadResult',
229 NACL_MESSAGE_TIMEOUT: 'Hotword.HotwordNaClMessageTimeout',
230 TRIGGER_SOURCE: 'Hotword.HotwordTriggerSource'
234 * Message waited for by NaCl plugin, to be reported via UMA.
235 * DO NOT remove or renumber values in this enum. Only add new ones.
236 * @enum {number}
238 var UmaNaClMessageTimeout = {
239 REQUEST_MODEL: 0,
240 MODEL_LOADED: 1,
241 READY_FOR_AUDIO: 2,
242 STOPPED: 3,
243 HOTWORD_DETECTED: 4,
244 MS_CONFIGURED: 5,
245 MAX: 5
249 * NaCl plugin load success/errors to be reported via UMA.
250 * DO NOT remove or renumber values in this enum. Only add new ones.
251 * @enum {number}
253 var UmaNaClPluginLoadResult = {
254 SUCCESS: 0,
255 UNKNOWN: 1,
256 CRASH: 2,
257 NO_MODULE_FOUND: 3,
258 MAX: 3
262 * Source of hotword triggering, to be reported via UMA.
263 * DO NOT remove or renumber values in this enum. Only add new ones.
264 * @enum {number}
266 var UmaTriggerSource = {
267 LAUNCHER: 0,
268 NTP_GOOGLE_COM: 1,
269 ALWAYS_ON: 2,
270 TRAINING: 3,
271 MAX: 3
275 * The browser UI language.
276 * @const {string}
278 var UI_LANGUAGE = (chrome.i18n && chrome.i18n.getUILanguage) ?
279 chrome.i18n.getUILanguage() : '';
281 return {
282 AUDIO_LOG_SECONDS: AUDIO_LOG_SECONDS,
283 CLIENT_PORT_NAME: CLIENT_PORT_NAME,
284 COMMAND_FIELD_NAME: COMMAND_FIELD_NAME,
285 FILE_SYSTEM_SIZE_BYTES: FILE_SYSTEM_SIZE_BYTES,
286 HOTWORD_STREAM_TIMEOUT_SECONDS: HOTWORD_STREAM_TIMEOUT_SECONDS,
287 NUM_TRAINING_UTTERANCES: NUM_TRAINING_UTTERANCES,
288 SHARED_MODULE_ID: SHARED_MODULE_ID,
289 SHARED_MODULE_ROOT: SHARED_MODULE_ROOT,
290 SPEAKER_MODEL_FILE_NAME: SPEAKER_MODEL_FILE_NAME,
291 UI_LANGUAGE: UI_LANGUAGE,
292 UTTERANCE_FILE_EXTENSION: UTTERANCE_FILE_EXTENSION,
293 UTTERANCE_FILE_PREFIX: UTTERANCE_FILE_PREFIX,
294 CommandToPage: CommandToPage,
295 CommandFromPage: CommandFromPage,
296 Error: Error,
297 Event: Event,
298 File: File,
299 NaClPlugin: NaClPlugin,
300 RecognizerStartMode: RecognizerStartMode,
301 SessionSource: SessionSource,
302 TimeoutMs: TimeoutMs,
303 UmaMediaStreamOpenResult: UmaMediaStreamOpenResult,
304 UmaMetrics: UmaMetrics,
305 UmaNaClMessageTimeout: UmaNaClMessageTimeout,
306 UmaNaClPluginLoadResult: UmaNaClPluginLoadResult,
307 UmaTriggerSource: UmaTriggerSource