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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/task_scheduler/post_task.h" | |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "content/browser/browser_main_loop.h" | 16 #include "content/browser/browser_main_loop.h" |
16 #include "content/browser/media/media_internals.h" | 17 #include "content/browser/media/media_internals.h" |
17 #include "content/browser/speech/audio_buffer.h" | 18 #include "content/browser/speech/audio_buffer.h" |
18 #include "content/public/browser/speech_recognition_event_listener.h" | 19 #include "content/public/browser/speech_recognition_event_listener.h" |
19 #include "media/audio/audio_manager.h" | 20 #include "media/audio/audio_manager.h" |
20 #include "media/audio/audio_system.h" | 21 #include "media/audio/audio_system.h" |
21 #include "media/base/audio_converter.h" | 22 #include "media/base/audio_converter.h" |
22 | 23 |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 input_parameters.set_frames_per_buffer(frames_per_buffer); | 629 input_parameters.set_frames_per_buffer(frames_per_buffer); |
629 DVLOG(1) << "SRI::input_parameters: " | 630 DVLOG(1) << "SRI::input_parameters: " |
630 << input_parameters.AsHumanReadableString(); | 631 << input_parameters.AsHumanReadableString(); |
631 } | 632 } |
632 | 633 |
633 // Create an audio converter which converts data between native input format | 634 // Create an audio converter which converts data between native input format |
634 // and WebSpeech specific output format. | 635 // and WebSpeech specific output format. |
635 audio_converter_.reset( | 636 audio_converter_.reset( |
636 new OnDataConverter(input_parameters, output_parameters)); | 637 new OnDataConverter(input_parameters, output_parameters)); |
637 | 638 |
638 audio_controller_ = AudioInputController::Create( | 639 audio_controller_ = AudioInputController::Create( |
fdoray
2017/05/17 14:58:52
The TaskRunner ends up being used here: https://cs
| |
639 GetAudioManager(), this, this, nullptr, input_parameters, device_id_, | 640 GetAudioManager(), this, this, nullptr, input_parameters, device_id_, |
640 /*agc_is_enabled*/ false, | 641 /*agc_is_enabled*/ false, |
641 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); | 642 base::CreateSingleThreadTaskRunnerWithTraits( |
643 {base::MayBlock(), base::TaskPriority::BACKGROUND})); | |
642 | 644 |
643 if (!audio_controller_.get()) { | 645 if (!audio_controller_.get()) { |
644 return Abort( | 646 return Abort( |
645 SpeechRecognitionError(SPEECH_RECOGNITION_ERROR_AUDIO_CAPTURE)); | 647 SpeechRecognitionError(SPEECH_RECOGNITION_ERROR_AUDIO_CAPTURE)); |
646 } | 648 } |
647 | 649 |
648 audio_log_->OnCreated(0, input_parameters, device_id_); | 650 audio_log_->OnCreated(0, input_parameters, device_id_); |
649 | 651 |
650 // The endpointer needs to estimate the environment/background noise before | 652 // The endpointer needs to estimate the environment/background noise before |
651 // starting to treat the audio as user input. We wait in the state | 653 // starting to treat the audio as user input. We wait in the state |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
906 engine_error(SPEECH_RECOGNITION_ERROR_NONE) { | 908 engine_error(SPEECH_RECOGNITION_ERROR_NONE) { |
907 } | 909 } |
908 | 910 |
909 SpeechRecognizerImpl::FSMEventArgs::FSMEventArgs(const FSMEventArgs& other) = | 911 SpeechRecognizerImpl::FSMEventArgs::FSMEventArgs(const FSMEventArgs& other) = |
910 default; | 912 default; |
911 | 913 |
912 SpeechRecognizerImpl::FSMEventArgs::~FSMEventArgs() { | 914 SpeechRecognizerImpl::FSMEventArgs::~FSMEventArgs() { |
913 } | 915 } |
914 | 916 |
915 } // namespace content | 917 } // namespace content |
OLD | NEW |