| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/browser/speech/speech_recognizer_impl.h" | 5 #include "content/browser/speech/speech_recognizer_impl.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "content/browser/browser_main_loop.h" | 10 #include "content/browser/browser_main_loop.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 DVLOG(1) << "SpeechRecognizerImpl starting audio capture."; | 396 DVLOG(1) << "SpeechRecognizerImpl starting audio capture."; |
| 397 num_samples_recorded_ = 0; | 397 num_samples_recorded_ = 0; |
| 398 audio_level_ = 0; | 398 audio_level_ = 0; |
| 399 listener_->OnRecognitionStart(session_id_); | 399 listener_->OnRecognitionStart(session_id_); |
| 400 | 400 |
| 401 if (!audio_manager->HasAudioInputDevices()) { | 401 if (!audio_manager->HasAudioInputDevices()) { |
| 402 return Abort(SpeechRecognitionError(SPEECH_RECOGNITION_ERROR_AUDIO, | 402 return Abort(SpeechRecognitionError(SPEECH_RECOGNITION_ERROR_AUDIO, |
| 403 SPEECH_AUDIO_ERROR_DETAILS_NO_MIC)); | 403 SPEECH_AUDIO_ERROR_DETAILS_NO_MIC)); |
| 404 } | 404 } |
| 405 | 405 |
| 406 if (audio_manager->IsRecordingInProcess()) { | |
| 407 return Abort(SpeechRecognitionError(SPEECH_RECOGNITION_ERROR_AUDIO, | |
| 408 SPEECH_AUDIO_ERROR_DETAILS_IN_USE)); | |
| 409 } | |
| 410 | |
| 411 const int samples_per_packet = (kAudioSampleRate * | 406 const int samples_per_packet = (kAudioSampleRate * |
| 412 recognition_engine_->GetDesiredAudioChunkDurationMs()) / 1000; | 407 recognition_engine_->GetDesiredAudioChunkDurationMs()) / 1000; |
| 413 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, | 408 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, |
| 414 kAudioSampleRate, kNumBitsPerAudioSample, | 409 kAudioSampleRate, kNumBitsPerAudioSample, |
| 415 samples_per_packet); | 410 samples_per_packet); |
| 416 audio_controller_ = AudioInputController::Create(audio_manager, this, params); | 411 audio_controller_ = AudioInputController::Create(audio_manager, this, params); |
| 417 | 412 |
| 418 if (audio_controller_.get() == NULL) { | 413 if (audio_controller_.get() == NULL) { |
| 419 return Abort(SpeechRecognitionError(SPEECH_RECOGNITION_ERROR_AUDIO)); | 414 return Abort(SpeechRecognitionError(SPEECH_RECOGNITION_ERROR_AUDIO)); |
| 420 } | 415 } |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 SpeechRecognizerImpl::FSMEventArgs::FSMEventArgs(FSMEvent event_value) | 654 SpeechRecognizerImpl::FSMEventArgs::FSMEventArgs(FSMEvent event_value) |
| 660 : event(event_value), | 655 : event(event_value), |
| 661 audio_data(NULL), | 656 audio_data(NULL), |
| 662 engine_error(SPEECH_RECOGNITION_ERROR_NONE) { | 657 engine_error(SPEECH_RECOGNITION_ERROR_NONE) { |
| 663 } | 658 } |
| 664 | 659 |
| 665 SpeechRecognizerImpl::FSMEventArgs::~FSMEventArgs() { | 660 SpeechRecognizerImpl::FSMEventArgs::~FSMEventArgs() { |
| 666 } | 661 } |
| 667 | 662 |
| 668 } // namespace content | 663 } // namespace content |
| OLD | NEW |