Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/resources/app_list/speech_manager.js

Issue 217423002: Removes Experimental hotword-always-on feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/resources/app_list/start_page.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 /** 5 /**
6 * @fileoverview The class to Manage both offline / online speech recognition. 6 * @fileoverview The class to Manage both offline / online speech recognition.
7 */ 7 */
8 8
9 <include src="plugin_manager.js"/> 9 <include src="plugin_manager.js"/>
10 <include src="audio_manager.js"/> 10 <include src="audio_manager.js"/>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 this.audioManager_.addEventListener( 78 this.audioManager_.addEventListener(
79 'audio', pluginManager.sendAudioData.bind(pluginManager)); 79 'audio', pluginManager.sendAudioData.bind(pluginManager));
80 if (this.shown_) { 80 if (this.shown_) {
81 this.pluginManager_.startRecognizer(); 81 this.pluginManager_.startRecognizer();
82 this.audioManager_.start(); 82 this.audioManager_.start();
83 this.setState_(SpeechState.HOTWORD_RECOGNIZING); 83 this.setState_(SpeechState.HOTWORD_RECOGNIZING);
84 } else { 84 } else {
85 this.pluginManager_.stopRecognizer(); 85 this.pluginManager_.stopRecognizer();
86 this.setState_(SpeechState.READY); 86 this.setState_(SpeechState.READY);
87 } 87 }
88 chrome.send('setHotwordRecognizerState', [true]);
89 }; 88 };
90 89
91 /** 90 /**
92 * Called when the hotword is recognized. 91 * Called when the hotword is recognized.
93 * 92 *
94 * @private 93 * @private
95 */ 94 */
96 SpeechManager.prototype.onHotwordRecognized_ = function() { 95 SpeechManager.prototype.onHotwordRecognized_ = function() {
97 if (this.state != SpeechState.HOTWORD_RECOGNIZING) 96 if (this.state != SpeechState.HOTWORD_RECOGNIZING)
98 return; 97 return;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 var pluginManager = new speech.PluginManager( 173 var pluginManager = new speech.PluginManager(
175 this.onHotwordRecognizerReady_.bind(this), 174 this.onHotwordRecognizerReady_.bind(this),
176 this.onHotwordRecognized_.bind(this)); 175 this.onHotwordRecognized_.bind(this));
177 pluginManager.scheduleInitialize( 176 pluginManager.scheduleInitialize(
178 this.audioManager_.sampleRate, 'chrome://app-list/hotword.data'); 177 this.audioManager_.sampleRate, 'chrome://app-list/hotword.data');
179 } else { 178 } else {
180 if (!recognizer) 179 if (!recognizer)
181 return; 180 return;
182 document.body.removeChild(recognizer); 181 document.body.removeChild(recognizer);
183 this.pluginManager_ = null; 182 this.pluginManager_ = null;
184 chrome.send('setHotwordRecognizerState', [false]);
185 if (this.state == SpeechState.HOTWORD_RECOGNIZING) 183 if (this.state == SpeechState.HOTWORD_RECOGNIZING)
186 this.setState(SpeechState.READY); 184 this.setState(SpeechState.READY);
187 } 185 }
188 }; 186 };
189 187
190 /** 188 /**
191 * Starts the hotword recognizer. 189 * Called when the app-list bubble is shown.
192 */ 190 */
193 SpeechManager.prototype.startHotwordRecognition = function() { 191 SpeechManager.prototype.onShown = function() {
192 this.shown_ = true;
194 if (!this.pluginManager_) 193 if (!this.pluginManager_)
195 return; 194 return;
196 195
197 if (this.state == SpeechState.HOTWORD_RECOGNIZING) 196 if (this.state == SpeechState.HOTWORD_RECOGNIZING) {
197 console.warn('Already in recognition state...');
198 return; 198 return;
199 }
199 200
200 this.pluginManager_.startRecognizer(); 201 this.pluginManager_.startRecognizer();
201 this.audioManager_.start(); 202 this.audioManager_.start();
202 this.setState_(SpeechState.HOTWORD_RECOGNIZING); 203 this.setState_(SpeechState.HOTWORD_RECOGNIZING);
203 }; 204 };
204 205
205 /** 206 /**
206 * Stops the hotword recognizer.
207 */
208 SpeechManager.prototype.stopHotwordRecognition = function() {
209 if (!this.pluginManager_)
210 return;
211
212 if (this.state != SpeechState.HOTWORD_RECOGNIZING)
213 return;
214
215 this.pluginManager_.stopRecognizer();
216 this.audioManager_.stop();
217 this.setState_(SpeechState.READY);
218 };
219
220 /**
221 * Called when the app-list bubble is shown.
222 */
223 SpeechManager.prototype.onShown = function() {
224 this.shown_ = true;
225 if (this.state == SpeechState.READY)
226 this.startHotwordRecognition();
227 };
228
229 /**
230 * Called when the app-list bubble is hidden. 207 * Called when the app-list bubble is hidden.
231 */ 208 */
232 SpeechManager.prototype.onHidden = function() { 209 SpeechManager.prototype.onHidden = function() {
233 this.shown_ = false; 210 this.shown_ = false;
234 if (this.pluginManager_) 211 if (this.pluginManager_)
235 this.pluginManager_.stopRecognizer(); 212 this.pluginManager_.stopRecognizer();
236 213
237 // SpeechRecognition is asynchronous. 214 // SpeechRecognition is asynchronous.
238 this.audioManager_.stop(); 215 this.audioManager_.stop();
239 if (this.state == SpeechState.RECOGNIZING || 216 if (this.state == SpeechState.RECOGNIZING ||
(...skipping 19 matching lines...) Expand all
259 if (this.audioManager_.state == speech.AudioState.STOPPED) 236 if (this.audioManager_.state == speech.AudioState.STOPPED)
260 this.audioManager_.start(); 237 this.audioManager_.start();
261 this.speechRecognitionManager_.start(); 238 this.speechRecognitionManager_.start();
262 } 239 }
263 }; 240 };
264 241
265 return { 242 return {
266 SpeechManager: SpeechManager 243 SpeechManager: SpeechManager
267 }; 244 };
268 }); 245 });
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/resources/app_list/start_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698