| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| 11 #include "content/browser/speech/audio_buffer.h" | 11 #include "content/browser/speech/audio_buffer.h" |
| 12 #include "content/browser/speech/google_one_shot_remote_engine.h" | 12 #include "content/browser/speech/google_one_shot_remote_engine.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/speech_recognition_event_listener.h" | 14 #include "content/public/browser/speech_recognition_event_listener.h" |
| 15 #include "content/public/browser/speech_recognizer.h" | 15 #include "content/public/browser/speech_recognizer.h" |
| 16 #include "content/public/common/speech_recognition_error.h" | 16 #include "content/public/common/speech_recognition_error.h" |
| 17 #include "content/public/common/speech_recognition_grammar.h" |
| 17 #include "content/public/common/speech_recognition_result.h" | 18 #include "content/public/common/speech_recognition_result.h" |
| 18 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
| 19 | 20 |
| 20 using content::BrowserMainLoop; | 21 using content::BrowserMainLoop; |
| 21 using content::BrowserThread; | 22 using content::BrowserThread; |
| 22 using content::SpeechRecognitionError; | 23 using content::SpeechRecognitionError; |
| 23 using content::SpeechRecognitionEventListener; | 24 using content::SpeechRecognitionEventListener; |
| 25 using content::SpeechRecognitionGrammar; |
| 24 using content::SpeechRecognitionResult; | 26 using content::SpeechRecognitionResult; |
| 25 using content::SpeechRecognizer; | 27 using content::SpeechRecognizer; |
| 26 using media::AudioInputController; | 28 using media::AudioInputController; |
| 27 using media::AudioManager; | 29 using media::AudioManager; |
| 28 using media::AudioParameters; | 30 using media::AudioParameters; |
| 29 | 31 |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 // The following constants are related to the volume level indicator shown in | 34 // The following constants are related to the volume level indicator shown in |
| 33 // the UI for recorded audio. | 35 // the UI for recorded audio. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // of instantiating it. | 74 // of instantiating it. |
| 73 SpeechRecognizer* SpeechRecognizer::Create( | 75 SpeechRecognizer* SpeechRecognizer::Create( |
| 74 SpeechRecognitionEventListener* listener, | 76 SpeechRecognitionEventListener* listener, |
| 75 int session_id, | 77 int session_id, |
| 76 const std::string& language, | 78 const std::string& language, |
| 77 const std::string& grammar, | 79 const std::string& grammar, |
| 78 net::URLRequestContextGetter* context_getter, | 80 net::URLRequestContextGetter* context_getter, |
| 79 bool filter_profanities, | 81 bool filter_profanities, |
| 80 const std::string& hardware_info, | 82 const std::string& hardware_info, |
| 81 const std::string& origin_url) { | 83 const std::string& origin_url) { |
| 82 speech::GoogleOneShotRemoteEngineConfig remote_engine_config; | 84 speech::SpeechRecognitionEngineConfig remote_engine_config; |
| 83 remote_engine_config.language = language; | 85 remote_engine_config.language = language; |
| 84 remote_engine_config.grammar = grammar; | 86 if (!grammar.empty()) |
| 87 remote_engine_config.grammars.push_back(SpeechRecognitionGrammar(grammar)); |
| 85 remote_engine_config.audio_sample_rate = | 88 remote_engine_config.audio_sample_rate = |
| 86 speech::SpeechRecognizerImpl::kAudioSampleRate; | 89 speech::SpeechRecognizerImpl::kAudioSampleRate; |
| 87 remote_engine_config.audio_num_bits_per_sample = | 90 remote_engine_config.audio_num_bits_per_sample = |
| 88 speech::SpeechRecognizerImpl::kNumBitsPerAudioSample; | 91 speech::SpeechRecognizerImpl::kNumBitsPerAudioSample; |
| 89 remote_engine_config.filter_profanities = filter_profanities; | 92 remote_engine_config.filter_profanities = filter_profanities; |
| 90 remote_engine_config.hardware_info = hardware_info; | 93 remote_engine_config.hardware_info = hardware_info; |
| 91 remote_engine_config.origin_url = origin_url; | 94 remote_engine_config.origin_url = origin_url; |
| 92 | 95 |
| 93 // SpeechRecognizerImpl takes ownership of google_remote_engine. | 96 // SpeechRecognizerImpl takes ownership of google_remote_engine. |
| 94 speech::GoogleOneShotRemoteEngine* google_remote_engine = | 97 speech::GoogleOneShotRemoteEngine* google_remote_engine = |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 : event(event_value), | 646 : event(event_value), |
| 644 audio_error_code(0), | 647 audio_error_code(0), |
| 645 audio_data(NULL), | 648 audio_data(NULL), |
| 646 engine_error(content::SPEECH_RECOGNITION_ERROR_NONE) { | 649 engine_error(content::SPEECH_RECOGNITION_ERROR_NONE) { |
| 647 } | 650 } |
| 648 | 651 |
| 649 SpeechRecognizerImpl::FSMEventArgs::~FSMEventArgs() { | 652 SpeechRecognizerImpl::FSMEventArgs::~FSMEventArgs() { |
| 650 } | 653 } |
| 651 | 654 |
| 652 } // namespace speech | 655 } // namespace speech |
| OLD | NEW |