OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('hotword.constants', function() { | 5 cr.define('hotword.constants', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 | |
9 /** | 8 /** |
10 * Hotword data shared module extension's ID. | 9 * Hotword data shared module extension's ID. |
11 * @const {string} | 10 * @const {string} |
12 * TODO(amistry): Replace with real shared module ID. | 11 * TODO(amistry): Replace with real shared module ID. |
13 */ | 12 */ |
14 var SHARED_MODULE_ID = 'bepbmhgboaologfdajaanbcjmnhjmhfn'; | 13 var SHARED_MODULE_ID = 'bepbmhgboaologfdajaanbcjmnhjmhfn'; |
15 | 14 |
16 | |
17 /** | 15 /** |
18 * Path to shared module data. | 16 * Path to shared module data. |
19 * @const {string} | 17 * @const {string} |
20 */ | 18 */ |
21 var SHARED_MODULE_ROOT = '_modules/' + SHARED_MODULE_ID; | 19 var SHARED_MODULE_ROOT = '_modules/' + SHARED_MODULE_ID; |
22 | 20 |
23 | |
24 /** | 21 /** |
25 * Time to wait for expected messages, in milliseconds. | 22 * Time to wait for expected messages, in milliseconds. |
26 * @enum {number} | 23 * @enum {number} |
27 */ | 24 */ |
28 var TimeoutMs = { | 25 var TimeoutMs = { |
29 SHORT: 200, | 26 SHORT: 200, |
30 NORMAL: 500, | 27 NORMAL: 500, |
31 LONG: 2000 | 28 LONG: 2000 |
32 }; | 29 }; |
33 | 30 |
34 | |
35 /** | 31 /** |
36 * The URL of the files used by the plugin. | 32 * The URL of the files used by the plugin. |
37 * @enum {string} | 33 * @enum {string} |
38 */ | 34 */ |
39 var File = { | 35 var File = { |
40 RECOGNIZER_CONFIG: 'hotword.data', | 36 RECOGNIZER_CONFIG: 'hotword.data', |
41 }; | 37 }; |
42 | 38 |
43 | |
44 /** | 39 /** |
45 * Errors emitted by the NaClManager. | 40 * Errors emitted by the NaClManager. |
46 * @enum {string} | 41 * @enum {string} |
47 */ | 42 */ |
48 var Error = { | 43 var Error = { |
49 NACL_CRASH: 'nacl_crash', | 44 NACL_CRASH: 'nacl_crash', |
50 TIMEOUT: 'timeout', | 45 TIMEOUT: 'timeout', |
51 }; | 46 }; |
52 | 47 |
53 | |
54 /** | 48 /** |
55 * Event types supported by NaClManager. | 49 * Event types supported by NaClManager. |
56 * @enum {string} | 50 * @enum {string} |
57 */ | 51 */ |
58 var Event = { | 52 var Event = { |
59 READY: 'ready', | 53 READY: 'ready', |
60 TRIGGER: 'trigger', | 54 TRIGGER: 'trigger', |
61 ERROR: 'error', | 55 ERROR: 'error', |
62 }; | 56 }; |
63 | 57 |
64 | |
65 /** | 58 /** |
66 * Messages for communicating with the NaCl recognizer plugin. These must match | 59 * Messages for communicating with the NaCl recognizer plugin. These must match |
67 * constants in <google3>/hotword_plugin.c | 60 * constants in <google3>/hotword_plugin.c |
68 * @enum {string} | 61 * @enum {string} |
69 */ | 62 */ |
70 var NaClPlugin = { | 63 var NaClPlugin = { |
71 RESTART: 'r', | 64 RESTART: 'r', |
72 SAMPLE_RATE_PREFIX: 'h', | 65 SAMPLE_RATE_PREFIX: 'h', |
73 MODEL_PREFIX: 'm', | 66 MODEL_PREFIX: 'm', |
74 STOP: 's', | 67 STOP: 's', |
75 REQUEST_MODEL: 'model', | 68 REQUEST_MODEL: 'model', |
76 MODEL_LOADED: 'model_loaded', | 69 MODEL_LOADED: 'model_loaded', |
77 READY_FOR_AUDIO: 'audio', | 70 READY_FOR_AUDIO: 'audio', |
78 STOPPED: 'stopped', | 71 STOPPED: 'stopped', |
79 HOTWORD_DETECTED: 'hotword', | 72 HOTWORD_DETECTED: 'hotword', |
80 MS_CONFIGURED: 'ms_configured' | 73 MS_CONFIGURED: 'ms_configured' |
81 }; | 74 }; |
82 | 75 |
| 76 /** |
| 77 * Source of a hotwording session request. |
| 78 * @enum {string} |
| 79 */ |
| 80 var SessionSource = { |
| 81 LAUNCHER: 'launcher' |
| 82 }; |
83 | 83 |
84 /** | 84 /** |
85 * The browser UI language. | 85 * The browser UI language. |
86 * @const {string} | 86 * @const {string} |
87 */ | 87 */ |
88 var UI_LANGUAGE = (chrome.i18n && chrome.i18n.getUILanguage) ? | 88 var UI_LANGUAGE = (chrome.i18n && chrome.i18n.getUILanguage) ? |
89 chrome.i18n.getUILanguage() : ''; | 89 chrome.i18n.getUILanguage() : ''; |
90 | 90 |
91 return { | 91 return { |
92 SHARED_MODULE_ID: SHARED_MODULE_ID, | 92 SHARED_MODULE_ID: SHARED_MODULE_ID, |
93 SHARED_MODULE_ROOT: SHARED_MODULE_ROOT, | 93 SHARED_MODULE_ROOT: SHARED_MODULE_ROOT, |
94 TimeoutMs: TimeoutMs, | 94 TimeoutMs: TimeoutMs, |
95 File: File, | 95 File: File, |
96 Error: Error, | 96 Error: Error, |
97 Event: Event, | 97 Event: Event, |
98 NaClPlugin: NaClPlugin, | 98 NaClPlugin: NaClPlugin, |
| 99 SessionSource: SessionSource, |
99 UI_LANGUAGE: UI_LANGUAGE | 100 UI_LANGUAGE: UI_LANGUAGE |
100 }; | 101 }; |
101 | 102 |
102 }); | 103 }); |
OLD | NEW |