| 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_recognition_manager_impl.h" | 5 #include "content/browser/speech/speech_recognition_manager_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 const int session_id = GetNextSessionID(); | 100 const int session_id = GetNextSessionID(); |
| 101 DCHECK(!SessionExists(session_id)); | 101 DCHECK(!SessionExists(session_id)); |
| 102 // Set-up the new session. | 102 // Set-up the new session. |
| 103 Session* session = new Session(); | 103 Session* session = new Session(); |
| 104 sessions_[session_id] = session; | 104 sessions_[session_id] = session; |
| 105 session->id = session_id; | 105 session->id = session_id; |
| 106 session->config = config; | 106 session->config = config; |
| 107 session->context = config.initial_context; | 107 session->context = config.initial_context; |
| 108 | 108 |
| 109 std::string hardware_info; | |
| 110 bool can_report_metrics = false; | |
| 111 if (delegate_) | |
| 112 delegate_->GetDiagnosticInformation(&can_report_metrics, &hardware_info); | |
| 113 | |
| 114 #if !defined(OS_ANDROID) | 109 #if !defined(OS_ANDROID) |
| 115 // A SpeechRecognitionEngine (and corresponding Config) is required only | 110 // A SpeechRecognitionEngine (and corresponding Config) is required only |
| 116 // when using SpeechRecognizerImpl, which performs the audio capture and | 111 // when using SpeechRecognizerImpl, which performs the audio capture and |
| 117 // endpointing in the browser. This is not the case of Android where, not | 112 // endpointing in the browser. This is not the case of Android where, not |
| 118 // only the speech recognition, but also the audio capture and endpointing | 113 // only the speech recognition, but also the audio capture and endpointing |
| 119 // activities performed outside of the browser (delegated via JNI to the | 114 // activities performed outside of the browser (delegated via JNI to the |
| 120 // Android API implementation). | 115 // Android API implementation). |
| 121 | 116 |
| 122 SpeechRecognitionEngine::Config remote_engine_config; | 117 SpeechRecognitionEngine::Config remote_engine_config; |
| 123 remote_engine_config.language = config.language; | 118 remote_engine_config.language = config.language; |
| 124 remote_engine_config.grammars = config.grammars; | 119 remote_engine_config.grammars = config.grammars; |
| 125 remote_engine_config.audio_sample_rate = | 120 remote_engine_config.audio_sample_rate = |
| 126 SpeechRecognizerImpl::kAudioSampleRate; | 121 SpeechRecognizerImpl::kAudioSampleRate; |
| 127 remote_engine_config.audio_num_bits_per_sample = | 122 remote_engine_config.audio_num_bits_per_sample = |
| 128 SpeechRecognizerImpl::kNumBitsPerAudioSample; | 123 SpeechRecognizerImpl::kNumBitsPerAudioSample; |
| 129 remote_engine_config.filter_profanities = config.filter_profanities; | 124 remote_engine_config.filter_profanities = config.filter_profanities; |
| 130 remote_engine_config.continuous = config.continuous; | 125 remote_engine_config.continuous = config.continuous; |
| 131 remote_engine_config.interim_results = config.interim_results; | 126 remote_engine_config.interim_results = config.interim_results; |
| 132 remote_engine_config.max_hypotheses = config.max_hypotheses; | 127 remote_engine_config.max_hypotheses = config.max_hypotheses; |
| 133 remote_engine_config.hardware_info = hardware_info; | |
| 134 remote_engine_config.origin_url = config.origin_url; | 128 remote_engine_config.origin_url = config.origin_url; |
| 135 remote_engine_config.auth_token = config.auth_token; | 129 remote_engine_config.auth_token = config.auth_token; |
| 136 remote_engine_config.auth_scope = config.auth_scope; | 130 remote_engine_config.auth_scope = config.auth_scope; |
| 137 remote_engine_config.preamble = config.preamble; | 131 remote_engine_config.preamble = config.preamble; |
| 138 | 132 |
| 139 SpeechRecognitionEngine* google_remote_engine = | 133 SpeechRecognitionEngine* google_remote_engine = |
| 140 new SpeechRecognitionEngine(config.url_request_context_getter.get()); | 134 new SpeechRecognitionEngine(config.url_request_context_getter.get()); |
| 141 google_remote_engine->SetConfig(remote_engine_config); | 135 google_remote_engine->SetConfig(remote_engine_config); |
| 142 | 136 |
| 143 session->recognizer = new SpeechRecognizerImpl( | 137 session->recognizer = new SpeechRecognizerImpl( |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 SpeechRecognitionManagerImpl::Session::Session() | 666 SpeechRecognitionManagerImpl::Session::Session() |
| 673 : id(kSessionIDInvalid), | 667 : id(kSessionIDInvalid), |
| 674 abort_requested(false), | 668 abort_requested(false), |
| 675 listener_is_active(true) { | 669 listener_is_active(true) { |
| 676 } | 670 } |
| 677 | 671 |
| 678 SpeechRecognitionManagerImpl::Session::~Session() { | 672 SpeechRecognitionManagerImpl::Session::~Session() { |
| 679 } | 673 } |
| 680 | 674 |
| 681 } // namespace content | 675 } // namespace content |
| OLD | NEW |