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