Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: content/browser/speech/speech_recognizer_impl.cc

Issue 10233010: Introducing new data types and IPC messages for scripted JS speech recognition APIs (Speech CL2.0) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added also SpeechRecognitionSessionContext Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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;
23 using content::SpeechRecognitionGrammar;
hans 2012/04/26 16:23:25 nit: sort order
Primiano Tucci (use gerrit) 2012/04/27 09:27:13 Done.
22 using content::SpeechRecognitionError; 24 using content::SpeechRecognitionError;
23 using content::SpeechRecognitionEventListener; 25 using content::SpeechRecognitionEventListener;
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
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // of instantiating it. 71 // of instantiating it.
70 SpeechRecognizer* SpeechRecognizer::Create( 72 SpeechRecognizer* SpeechRecognizer::Create(
71 SpeechRecognitionEventListener* listener, 73 SpeechRecognitionEventListener* listener,
72 int session_id, 74 int session_id,
73 const std::string& language, 75 const std::string& language,
74 const std::string& grammar, 76 const std::string& grammar,
75 net::URLRequestContextGetter* context_getter, 77 net::URLRequestContextGetter* context_getter,
76 bool filter_profanities, 78 bool filter_profanities,
77 const std::string& hardware_info, 79 const std::string& hardware_info,
78 const std::string& origin_url) { 80 const std::string& origin_url) {
79 speech::GoogleOneShotRemoteEngineConfig remote_engine_config; 81 speech::SpeechRecognitionEngineConfig remote_engine_config;
80 remote_engine_config.language = language; 82 remote_engine_config.language = language;
81 remote_engine_config.grammar = grammar; 83 if (!grammar.empty())
84 remote_engine_config.grammars.push_back(SpeechRecognitionGrammar(grammar));
82 remote_engine_config.audio_sample_rate = 85 remote_engine_config.audio_sample_rate =
83 speech::SpeechRecognizerImpl::kAudioSampleRate; 86 speech::SpeechRecognizerImpl::kAudioSampleRate;
84 remote_engine_config.audio_num_bits_per_sample = 87 remote_engine_config.audio_num_bits_per_sample =
85 speech::SpeechRecognizerImpl::kNumBitsPerAudioSample; 88 speech::SpeechRecognizerImpl::kNumBitsPerAudioSample;
86 remote_engine_config.filter_profanities = filter_profanities; 89 remote_engine_config.filter_profanities = filter_profanities;
87 remote_engine_config.hardware_info = hardware_info; 90 remote_engine_config.hardware_info = hardware_info;
88 remote_engine_config.origin_url = origin_url; 91 remote_engine_config.origin_url = origin_url;
89 92
90 // SpeechRecognizerImpl takes ownership of google_remote_engine. 93 // SpeechRecognizerImpl takes ownership of google_remote_engine.
91 speech::GoogleOneShotRemoteEngine* google_remote_engine = 94 speech::GoogleOneShotRemoteEngine* google_remote_engine =
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 : event(event_value), 639 : event(event_value),
637 audio_error_code(0), 640 audio_error_code(0),
638 audio_data(NULL), 641 audio_data(NULL),
639 engine_error(content::SPEECH_RECOGNITION_ERROR_NONE) { 642 engine_error(content::SPEECH_RECOGNITION_ERROR_NONE) {
640 } 643 }
641 644
642 SpeechRecognizerImpl::FSMEventArgs::~FSMEventArgs() { 645 SpeechRecognizerImpl::FSMEventArgs::~FSMEventArgs() {
643 } 646 }
644 647
645 } // namespace speech 648 } // namespace speech
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698