| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/speech/speech_recognizer.h" | 5 #include "chrome/browser/speech/speech_recognizer.h" |
| 6 | 6 |
| 7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 delegate_->SetInputVolume(caller_id_, audio_level_); | 307 delegate_->SetInputVolume(caller_id_, audio_level_); |
| 308 | 308 |
| 309 if (endpointer_.speech_input_complete()) { | 309 if (endpointer_.speech_input_complete()) { |
| 310 StopRecording(); | 310 StopRecording(); |
| 311 } | 311 } |
| 312 | 312 |
| 313 // TODO(satish): Once we have streaming POST, start sending the data received | 313 // TODO(satish): Once we have streaming POST, start sending the data received |
| 314 // here as POST chunks. | 314 // here as POST chunks. |
| 315 } | 315 } |
| 316 | 316 |
| 317 void SpeechRecognizer::SetRecognitionResult(bool error, const string16& value) { | 317 void SpeechRecognizer::SetRecognitionResult( |
| 318 if (value.empty()) { | 318 bool error, const SpeechInputResultArray& result) { |
| 319 if (result.empty()) { |
| 319 InformErrorAndCancelRecognition(RECOGNIZER_ERROR_NO_RESULTS); | 320 InformErrorAndCancelRecognition(RECOGNIZER_ERROR_NO_RESULTS); |
| 320 return; | 321 return; |
| 321 } | 322 } |
| 322 | 323 |
| 323 delegate_->SetRecognitionResult(caller_id_, error, value); | 324 delegate_->SetRecognitionResult(caller_id_, error, result); |
| 324 | 325 |
| 325 // Guard against the delegate freeing us until we finish our job. | 326 // Guard against the delegate freeing us until we finish our job. |
| 326 scoped_refptr<SpeechRecognizer> me(this); | 327 scoped_refptr<SpeechRecognizer> me(this); |
| 327 delegate_->DidCompleteRecognition(caller_id_); | 328 delegate_->DidCompleteRecognition(caller_id_); |
| 328 } | 329 } |
| 329 | 330 |
| 330 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) { | 331 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) { |
| 331 CancelRecognition(); | 332 CancelRecognition(); |
| 332 | 333 |
| 333 // Guard against the delegate freeing us until we finish our job. | 334 // Guard against the delegate freeing us until we finish our job. |
| 334 scoped_refptr<SpeechRecognizer> me(this); | 335 scoped_refptr<SpeechRecognizer> me(this); |
| 335 delegate_->OnRecognizerError(caller_id_, error); | 336 delegate_->OnRecognizerError(caller_id_, error); |
| 336 } | 337 } |
| 337 | 338 |
| 338 } // namespace speech_input | 339 } // namespace speech_input |
| OLD | NEW |