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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "content/browser/browser_main_loop.h" | 9 #include "content/browser/browser_main_loop.h" |
10 #include "content/public/browser/speech_recognizer_delegate.h" | 10 #include "content/public/browser/speech_recognizer_delegate.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/common/speech_input_result.h" | 12 #include "content/public/common/speech_recognition_traits.h" |
13 #include "net/url_request/url_request_context_getter.h" | 13 #include "net/url_request/url_request_context_getter.h" |
14 | 14 |
15 using content::BrowserMainLoop; | 15 using content::BrowserMainLoop; |
16 using content::BrowserThread; | 16 using content::BrowserThread; |
17 using content::SpeechRecognizer; | 17 using content::SpeechRecognizer; |
18 using content::SpeechRecognizerDelegate; | 18 using content::SpeechRecognizerDelegate; |
19 using media::AudioInputController; | 19 using media::AudioInputController; |
20 using std::string; | 20 using std::string; |
21 | 21 |
22 namespace { | 22 namespace { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 SpeechRecognizer* SpeechRecognizer::Create( | 55 SpeechRecognizer* SpeechRecognizer::Create( |
56 SpeechRecognizerDelegate* delegate, | 56 SpeechRecognizerDelegate* delegate, |
57 int caller_id, | 57 int caller_id, |
58 const std::string& language, | 58 const std::string& language, |
59 const std::string& grammar, | 59 const std::string& grammar, |
60 net::URLRequestContextGetter* context_getter, | 60 net::URLRequestContextGetter* context_getter, |
61 bool filter_profanities, | 61 bool filter_profanities, |
62 const std::string& hardware_info, | 62 const std::string& hardware_info, |
63 const std::string& origin_url) { | 63 const std::string& origin_url) { |
64 return new speech_input::SpeechRecognizerImpl( | 64 return new speech::SpeechRecognizerImpl( |
65 delegate, caller_id, language, grammar, context_getter, | 65 delegate, caller_id, language, grammar, context_getter, |
66 filter_profanities, hardware_info, origin_url); | 66 filter_profanities, hardware_info, origin_url); |
67 } | 67 } |
68 | 68 |
69 namespace speech_input { | 69 namespace speech { |
70 | 70 |
71 const int SpeechRecognizerImpl::kAudioSampleRate = 16000; | 71 const int SpeechRecognizerImpl::kAudioSampleRate = 16000; |
72 const int SpeechRecognizerImpl::kAudioPacketIntervalMs = 100; | 72 const int SpeechRecognizerImpl::kAudioPacketIntervalMs = 100; |
73 const ChannelLayout SpeechRecognizerImpl::kChannelLayout = CHANNEL_LAYOUT_MONO; | 73 const ChannelLayout SpeechRecognizerImpl::kChannelLayout = CHANNEL_LAYOUT_MONO; |
74 const int SpeechRecognizerImpl::kNumBitsPerAudioSample = 16; | 74 const int SpeechRecognizerImpl::kNumBitsPerAudioSample = 16; |
75 const int SpeechRecognizerImpl::kNoSpeechTimeoutSec = 8; | 75 const int SpeechRecognizerImpl::kNoSpeechTimeoutSec = 8; |
76 const int SpeechRecognizerImpl::kEndpointerEstimationTimeMs = 300; | 76 const int SpeechRecognizerImpl::kEndpointerEstimationTimeMs = 300; |
77 | 77 |
78 SpeechRecognizerImpl::SpeechRecognizerImpl( | 78 SpeechRecognizerImpl::SpeechRecognizerImpl( |
79 SpeechRecognizerDelegate* delegate, | 79 SpeechRecognizerDelegate* delegate, |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 base::Unretained(&closed_event))); | 336 base::Unretained(&closed_event))); |
337 closed_event.Wait(); | 337 closed_event.Wait(); |
338 audio_controller_ = NULL; // Releases the ref ptr. | 338 audio_controller_ = NULL; // Releases the ref ptr. |
339 } | 339 } |
340 | 340 |
341 void SpeechRecognizerImpl::SetAudioManagerForTesting( | 341 void SpeechRecognizerImpl::SetAudioManagerForTesting( |
342 AudioManager* audio_manager) { | 342 AudioManager* audio_manager) { |
343 audio_manager_ = audio_manager; | 343 audio_manager_ = audio_manager; |
344 } | 344 } |
345 | 345 |
346 } // namespace speech_input | 346 } // namespace speech |
OLD | NEW |