OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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', function() { | 5 cr.define('hotword', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Trivial container class for session information. | 9 * Trivial container class for session information. |
10 * @param {!hotword.constants.SessionSource} source Source of the hotword | 10 * @param {!hotword.constants.SessionSource} source Source of the hotword |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // possible for both to be set. In that case, always-on takes precedence. | 209 // possible for both to be set. In that case, always-on takes precedence. |
210 return this.hotwordStatus_.enabled && | 210 return this.hotwordStatus_.enabled && |
211 !this.hotwordStatus_.alwaysOnEnabled; | 211 !this.hotwordStatus_.alwaysOnEnabled; |
212 }, | 212 }, |
213 | 213 |
214 /** | 214 /** |
215 * @return {boolean} True if always-on hotwording is enabled. | 215 * @return {boolean} True if always-on hotwording is enabled. |
216 */ | 216 */ |
217 isAlwaysOnEnabled: function() { | 217 isAlwaysOnEnabled: function() { |
218 assert(this.hotwordStatus_, 'No hotword status (isAlwaysOnEnabled)'); | 218 assert(this.hotwordStatus_, 'No hotword status (isAlwaysOnEnabled)'); |
219 return this.hotwordStatus_.alwaysOnEnabled; | 219 return this.hotwordStatus_.alwaysOnEnabled && |
| 220 !this.hotwordStatus_.trainingEnabled; |
220 }, | 221 }, |
221 | 222 |
222 /** | 223 /** |
223 * @return {boolean} True if training is enabled. | 224 * @return {boolean} True if training is enabled. |
224 */ | 225 */ |
225 isTrainingEnabled: function() { | 226 isTrainingEnabled: function() { |
226 assert(this.hotwordStatus_, 'No hotword status (isTrainingEnabled)'); | 227 assert(this.hotwordStatus_, 'No hotword status (isTrainingEnabled)'); |
227 return this.hotwordStatus_.trainingEnabled; | 228 return this.hotwordStatus_.trainingEnabled; |
228 }, | 229 }, |
229 | 230 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 // order to restart the detector. | 479 // order to restart the detector. |
479 if (this.sessions_.length) { | 480 if (this.sessions_.length) { |
480 var session = this.sessions_.pop(); | 481 var session = this.sessions_.pop(); |
481 session.triggerCb_(event.log); | 482 session.triggerCb_(event.log); |
482 | 483 |
483 hotword.metrics.recordEnum( | 484 hotword.metrics.recordEnum( |
484 hotword.constants.UmaMetrics.TRIGGER_SOURCE, | 485 hotword.constants.UmaMetrics.TRIGGER_SOURCE, |
485 UmaTriggerSources_[session.source_], | 486 UmaTriggerSources_[session.source_], |
486 hotword.constants.UmaTriggerSource.MAX); | 487 hotword.constants.UmaTriggerSource.MAX); |
487 } | 488 } |
| 489 |
| 490 // If we're in always-on mode, shut down the hotword detector. The hotword |
| 491 // stream requires that we close and re-open it after a trigger, and the |
| 492 // only way to accomplish this is to shut everything down. |
| 493 if (this.isAlwaysOnEnabled()) |
| 494 this.shutdownDetector_(); |
488 }, | 495 }, |
489 | 496 |
490 /** | 497 /** |
491 * Handle speaker model saved. | 498 * Handle speaker model saved. |
492 * @private | 499 * @private |
493 */ | 500 */ |
494 onSpeakerModelSaved_: function() { | 501 onSpeakerModelSaved_: function() { |
495 hotword.debug('Speaker model saved!'); | 502 hotword.debug('Speaker model saved!'); |
496 | 503 |
497 if (this.sessions_.length) { | 504 if (this.sessions_.length) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 580 |
574 if (oldLocked != this.isLocked_) | 581 if (oldLocked != this.isLocked_) |
575 this.updateStateFromStatus_(); | 582 this.updateStateFromStatus_(); |
576 } | 583 } |
577 }; | 584 }; |
578 | 585 |
579 return { | 586 return { |
580 StateManager: StateManager | 587 StateManager: StateManager |
581 }; | 588 }; |
582 }); | 589 }); |
OLD | NEW |