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() {
9 * Number of seconds of audio to record when logging is enabled.
12 var AUDIO_LOG_SECONDS
= 2;
15 * Hotword data shared module extension's ID.
18 var SHARED_MODULE_ID
= 'lccekmodgklaepjeofjdjpbminllajkg';
21 * Path to shared module data.
24 var SHARED_MODULE_ROOT
= '_modules/' + SHARED_MODULE_ID
;
27 * Name used by the content scripts to create communications Ports.
30 var CLIENT_PORT_NAME
= 'chwcpn';
33 * The field name to specify the command among pages.
36 var COMMAND_FIELD_NAME
= 'cmd';
39 * The speaker model file name.
42 var SPEAKER_MODEL_FILE_NAME
= 'speaker_model.data';
45 * The training utterance file name prefix.
48 var UTTERANCE_FILE_PREFIX
= 'utterance-';
51 * The training utterance file extension.
54 var UTTERANCE_FILE_EXTENSION
= '.raw';
57 * The number of training utterances required to train the speaker model.
60 var NUM_TRAINING_UTTERANCES
= 3;
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.
68 var FILE_SYSTEM_SIZE_BYTES
= 1048576;
71 * Time to wait for expected messages, in milliseconds.
81 * The URL of the files used by the plugin.
85 RECOGNIZER_CONFIG
: 'hotword.data',
89 * Errors emitted by the NaClManager.
93 NACL_CRASH
: 'nacl_crash',
98 * Event types supported by NaClManager.
104 SPEAKER_MODEL_SAVED
: 'speaker model saved',
109 * Messages for communicating with the NaCl recognizer plugin. These must match
110 * constants in <google3>/hotword_plugin.c
115 SAMPLE_RATE_PREFIX
: 'h',
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',
127 HOTWORD_DETECTED
: 'hotword',
128 MS_CONFIGURED
: 'ms_configured'
132 * Messages sent from the injected scripts to the Google page.
135 var CommandToPage
= {
136 HOTWORD_VOICE_TRIGGER
: 'vt',
137 HOTWORD_STARTED
: 'hs',
139 HOTWORD_TIMEOUT
: 'ht',
144 * Messages sent from the Google page to the injected scripts
145 * and then passed to the extension.
148 var CommandFromPage
= {
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.
165 var SessionSource
= {
166 LAUNCHER
: 'launcher',
173 * The mode to start the hotword recognizer in.
176 var RecognizerStartMode
= {
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.
187 var UmaMediaStreamOpenResult
= {
191 PERMISSION_DENIED
: 3,
192 CONSTRAINT_NOT_SATISFIED
: 4,
196 SOURCE_UNAVAILABLE
: 8,
197 PERMISSION_DISMISSED
: 9,
199 DEVICES_NOT_FOUND
: 11,
200 INVALID_SECURITY_ORIGIN
: 12,
206 * DO NOT change these enum values.
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.
222 var UmaNaClMessageTimeout
= {
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.
237 var UmaNaClPluginLoadResult
= {
246 * Source of hotword triggering, to be reported via UMA.
247 * DO NOT remove or renumber values in this enum. Only add new ones.
250 var UmaTriggerSource
= {
259 * The browser UI language.
262 var UI_LANGUAGE
= (chrome
.i18n
&& chrome
.i18n
.getUILanguage
) ?
263 chrome
.i18n
.getUILanguage() : '';
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
,
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