Index: content/browser/speech/google_one_shot_remote_engine.h |
diff --git a/content/browser/speech/google_one_shot_remote_engine.h b/content/browser/speech/google_one_shot_remote_engine.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5c2ab0e6647a2914e7b0e9247f6bb0b05e30558c |
--- /dev/null |
+++ b/content/browser/speech/google_one_shot_remote_engine.h |
@@ -0,0 +1,84 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_SPEECH_GOOGLE_ONE_SHOT_REMOTE_ENGINE_H_ |
+#define CONTENT_BROWSER_SPEECH_GOOGLE_ONE_SHOT_REMOTE_ENGINE_H_ |
+#pragma once |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "content/browser/speech/audio_encoder.h" |
+#include "content/browser/speech/speech_recognition_engine.h" |
+#include "content/common/content_export.h" |
+#include "content/public/common/url_fetcher_delegate.h" |
+#include "googleurl/src/gurl.h" |
+ |
+class URLFetcher; |
+ |
+namespace content { |
+struct SpeechRecognitionResult; |
+} |
+ |
+namespace net { |
+class URLRequestContextGetter; |
+} |
+ |
+namespace speech { |
+ |
+class AudioChunk; |
+ |
+struct GoogleOneShotRemoteEngineConfig { |
+ std::string language; |
+ std::string grammar; |
+ bool filter_profanities; |
+ std::string hardware_info; |
+ std::string origin_url; |
+ int audio_sample_rate; |
+ int audio_num_bits_per_sample; |
+ |
+ GoogleOneShotRemoteEngineConfig(); |
+ ~GoogleOneShotRemoteEngineConfig(); |
+}; |
+ |
+// Implements a SpeechRecognitionEngine by means of remote interaction with |
+// Google Speech Server Front End (SSFE) webservice, according to the HTTP-based |
Satish
2012/03/21 13:29:48
not sure if these two lines help. may be switch th
Primiano Tucci (use gerrit)
2012/03/22 11:20:41
Done.
|
+// protocol defined in Google Speech API 1.3.2. |
+class GoogleOneShotRemoteEngine : public SpeechRecognitionEngine, |
Satish
2012/03/21 13:29:48
I think if these don't fit in a single line the ':
Primiano Tucci (use gerrit)
2012/03/22 11:20:41
Done.
|
+ public content::URLFetcherDelegate { |
+ public: |
+ // Duration of each audio packet. |
+ static const int kAudioPacketIntervalMs; |
+ // ID passed to URLFetcher::Create(). Used for testing. |
+ static int url_fetcher_id_for_tests; |
+ |
+ explicit GoogleOneShotRemoteEngine(net::URLRequestContextGetter* context); |
+ virtual ~GoogleOneShotRemoteEngine(); |
+ void SetConfiguration(const GoogleOneShotRemoteEngineConfig& config); |
+ |
+ // SpeechRecognitionEngine methods. |
+ virtual void Initialize() OVERRIDE; |
+ virtual void Cleanup() OVERRIDE; |
+ virtual void TakeAudioChunk(const AudioChunk& data) OVERRIDE; |
+ virtual void AudioChunksEnded() OVERRIDE; |
+ virtual bool IsRecognitionPending() const OVERRIDE; |
+ virtual int GetDesiredAudioChunkDurationMs() const OVERRIDE; |
+ |
+ // content::URLFetcherDelegate methods. |
+ virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; |
+ |
+ private: |
+ GoogleOneShotRemoteEngineConfig config_; |
+ scoped_ptr<content::URLFetcher> url_fetcher_; |
+ scoped_refptr<net::URLRequestContextGetter> url_context_; |
+ scoped_ptr<AudioEncoder> encoder_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(GoogleOneShotRemoteEngine); |
+}; |
+ |
+} // namespace speech |
+ |
+#endif // CONTENT_BROWSER_SPEECH_GOOGLE_ONE_SHOT_REMOTE_ENGINE_H_ |