| OLD | NEW |
| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 this.setState_(SpeechState.HOTWORD_RECOGNIZING); | 80 this.setState_(SpeechState.HOTWORD_RECOGNIZING); |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * Called when the speech recognition has happened. | 84 * Called when the speech recognition has happened. |
| 85 * | 85 * |
| 86 * @param {string} result The speech recognition result. | 86 * @param {string} result The speech recognition result. |
| 87 * @param {boolean} isFinal Whether the result is final or not. | 87 * @param {boolean} isFinal Whether the result is final or not. |
| 88 */ | 88 */ |
| 89 SpeechManager.prototype.onSpeechRecognized = function(result, isFinal) { | 89 SpeechManager.prototype.onSpeechRecognized = function(result, isFinal) { |
| 90 // TODO(mukai): updates the UI, make requests, and/or sends the result | |
| 91 // to the web_ui handler. | |
| 92 console.log('speech result: ' + result + ' ' + | 90 console.log('speech result: ' + result + ' ' + |
| 93 (isFinal ? 'final' : 'interim')); | 91 (isFinal ? 'final' : 'interim')); |
| 92 if (isFinal) { |
| 93 chrome.send('search', [result]); |
| 94 this.speechRecognitionManager_.stop(); |
| 95 } |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 /** | 98 /** |
| 97 * Called when the speech recognition has started. | 99 * Called when the speech recognition has started. |
| 98 */ | 100 */ |
| 99 SpeechManager.prototype.onSpeechRecognitionStarted = function() { | 101 SpeechManager.prototype.onSpeechRecognitionStarted = function() { |
| 100 this.setState_(SpeechState.RECOGNIZING); | 102 this.setState_(SpeechState.RECOGNIZING); |
| 101 }; | 103 }; |
| 102 | 104 |
| 103 /** | 105 /** |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 145 |
| 144 this.audioManager_.stop(); | 146 this.audioManager_.stop(); |
| 145 this.speechRecognitionManager_.stop(); | 147 this.speechRecognitionManager_.stop(); |
| 146 this.setState_(SpeechState.READY); | 148 this.setState_(SpeechState.READY); |
| 147 }; | 149 }; |
| 148 | 150 |
| 149 return { | 151 return { |
| 150 SpeechManager: SpeechManager | 152 SpeechManager: SpeechManager |
| 151 }; | 153 }; |
| 152 }); | 154 }); |
| OLD | NEW |