Chromium Code Reviews| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 sessions_[session_id] = session; | 106 sessions_[session_id] = session; |
| 107 session->id = session_id; | 107 session->id = session_id; |
| 108 session->config = config; | 108 session->config = config; |
| 109 session->context = config.initial_context; | 109 session->context = config.initial_context; |
| 110 | 110 |
| 111 std::string hardware_info; | 111 std::string hardware_info; |
| 112 bool can_report_metrics = false; | 112 bool can_report_metrics = false; |
| 113 if (delegate_) | 113 if (delegate_) |
| 114 delegate_->GetDiagnosticInformation(&can_report_metrics, &hardware_info); | 114 delegate_->GetDiagnosticInformation(&can_report_metrics, &hardware_info); |
| 115 | 115 |
| 116 // The legacy api cannot use continuous mode. | |
| 117 DCHECK(!config.is_legacy_api || !config.continuous); | |
| 118 | |
| 119 #if !defined(OS_ANDROID) | 116 #if !defined(OS_ANDROID) |
| 120 // A SpeechRecognitionEngine (and corresponding Config) is required only | 117 // A SpeechRecognitionEngine (and corresponding Config) is required only |
| 121 // when using SpeechRecognizerImpl, which performs the audio capture and | 118 // when using SpeechRecognizerImpl, which performs the audio capture and |
| 122 // endpointing in the browser. This is not the case of Android where, not | 119 // endpointing in the browser. This is not the case of Android where, not |
| 123 // only the speech recognition, but also the audio capture and endpointing | 120 // only the speech recognition, but also the audio capture and endpointing |
| 124 // activities performed outside of the browser (delegated via JNI to the | 121 // activities performed outside of the browser (delegated via JNI to the |
| 125 // Android API implementation). | 122 // Android API implementation). |
| 126 | 123 |
| 127 SpeechRecognitionEngineConfig remote_engine_config; | 124 SpeechRecognitionEngineConfig remote_engine_config; |
| 128 remote_engine_config.language = config.language; | 125 remote_engine_config.language = config.language; |
| 129 remote_engine_config.grammars = config.grammars; | 126 remote_engine_config.grammars = config.grammars; |
| 130 remote_engine_config.audio_sample_rate = | 127 remote_engine_config.audio_sample_rate = |
| 131 SpeechRecognizerImpl::kAudioSampleRate; | 128 SpeechRecognizerImpl::kAudioSampleRate; |
| 132 remote_engine_config.audio_num_bits_per_sample = | 129 remote_engine_config.audio_num_bits_per_sample = |
| 133 SpeechRecognizerImpl::kNumBitsPerAudioSample; | 130 SpeechRecognizerImpl::kNumBitsPerAudioSample; |
| 134 remote_engine_config.filter_profanities = config.filter_profanities; | 131 remote_engine_config.filter_profanities = config.filter_profanities; |
| 135 remote_engine_config.continuous = config.continuous; | 132 remote_engine_config.continuous = config.continuous; |
| 136 remote_engine_config.interim_results = config.interim_results; | 133 remote_engine_config.interim_results = config.interim_results; |
| 137 remote_engine_config.max_hypotheses = config.max_hypotheses; | 134 remote_engine_config.max_hypotheses = config.max_hypotheses; |
| 138 remote_engine_config.hardware_info = hardware_info; | 135 remote_engine_config.hardware_info = hardware_info; |
| 139 remote_engine_config.origin_url = config.origin_url; | 136 remote_engine_config.origin_url = config.origin_url; |
| 140 remote_engine_config.auth_token = config.auth_token; | 137 remote_engine_config.auth_token = config.auth_token; |
| 141 remote_engine_config.auth_scope = config.auth_scope; | 138 remote_engine_config.auth_scope = config.auth_scope; |
| 142 remote_engine_config.preamble = config.preamble; | 139 remote_engine_config.preamble = config.preamble; |
| 143 | 140 |
| 144 SpeechRecognitionEngine* google_remote_engine; | 141 SpeechRecognitionEngine* google_remote_engine = |
| 145 if (config.is_legacy_api) { | 142 new GoogleStreamingRemoteEngine(config.url_request_context_getter.get()); |
| 146 google_remote_engine = | |
| 147 new GoogleOneShotRemoteEngine(config.url_request_context_getter.get()); | |
|
Primiano Tucci (use gerrit)
2016/04/13 17:40:59
At this point in theory we could remove the Google
hans
2016/04/13 17:41:50
I have a CL for that :-) https://codereview.chromi
| |
| 148 } else { | |
| 149 google_remote_engine = new GoogleStreamingRemoteEngine( | |
| 150 config.url_request_context_getter.get()); | |
| 151 } | |
| 152 | |
| 153 google_remote_engine->SetConfig(remote_engine_config); | 143 google_remote_engine->SetConfig(remote_engine_config); |
| 154 | 144 |
| 155 session->recognizer = new SpeechRecognizerImpl( | 145 session->recognizer = new SpeechRecognizerImpl( |
| 156 this, | 146 this, |
| 157 session_id, | 147 session_id, |
| 158 config.continuous, | 148 config.continuous, |
| 159 config.interim_results, | 149 config.interim_results, |
| 160 google_remote_engine); | 150 google_remote_engine); |
| 161 #else | 151 #else |
| 162 session->recognizer = new SpeechRecognizerImplAndroid(this, session_id); | 152 session->recognizer = new SpeechRecognizerImplAndroid(this, session_id); |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 SpeechRecognitionManagerImpl::Session::Session() | 674 SpeechRecognitionManagerImpl::Session::Session() |
| 685 : id(kSessionIDInvalid), | 675 : id(kSessionIDInvalid), |
| 686 abort_requested(false), | 676 abort_requested(false), |
| 687 listener_is_active(true) { | 677 listener_is_active(true) { |
| 688 } | 678 } |
| 689 | 679 |
| 690 SpeechRecognitionManagerImpl::Session::~Session() { | 680 SpeechRecognitionManagerImpl::Session::~Session() { |
| 691 } | 681 } |
| 692 | 682 |
| 693 } // namespace content | 683 } // namespace content |
| OLD | NEW |