Index: content/browser/speech/google_ssfe_remote_engine.h |
diff --git a/content/browser/speech/google_ssfe_remote_engine.h b/content/browser/speech/google_ssfe_remote_engine.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1cafa80eaf3d1735f1c19878db7740c027603c47 |
--- /dev/null |
+++ b/content/browser/speech/google_ssfe_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_SSFE_REMOTE_ENGINE_H_ |
+#define CONTENT_BROWSER_SPEECH_GOOGLE_SSFE_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 GoogleSSFERemoteEngineConfig { |
+ 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; |
+ GoogleSSFERemoteEngineConfig(); |
+ ~GoogleSSFERemoteEngineConfig(); |
+}; |
+ |
+// Implements a SpeechRecognitionEngine by means of remote interaction with |
+// Google speech webservice, according to the HTTP-based protocol defined in |
+// Google Speech API 1.3.2. |
hans
2012/03/16 11:12:56
it's not immediately obvious what the SSFE part of
Primiano Tucci (use gerrit)
2012/03/16 15:03:42
Absolutely right.
|
+class GoogleSSFERemoteEngine : public SpeechRecognitionEngine, |
+ 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; |
+ |
+ GoogleSSFERemoteEngine(net::URLRequestContextGetter* context); |
hans
2012/03/16 11:12:56
one-parameter constructors should be explicit
Primiano Tucci (use gerrit)
2012/03/16 15:03:42
Done.
|
+ void SetConfiguration(const GoogleSSFERemoteEngineConfig& config); |
+ virtual ~GoogleSSFERemoteEngine(); |
+ |
+ // SpeechRecognitionEngine methods. |
+ virtual void SpeechRecognitionBegins() OVERRIDE; |
+ virtual void SpeechRecognitionEnds() OVERRIDE; |
+ virtual void PushSpeechAudio(const AudioChunk& data) OVERRIDE; |
+ virtual void SpeechAudioStreamComplete() OVERRIDE; |
+ virtual bool IsRecognitionPending() const OVERRIDE; |
+ virtual int DesiredAudioChunkDurationMs() const OVERRIDE; |
+ |
+ // content::URLFetcherDelegate methods. |
+ virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; |
+ |
+ private: |
+ GoogleSSFERemoteEngineConfig config_; |
+ scoped_ptr<content::URLFetcher> url_fetcher_; |
+ scoped_refptr<net::URLRequestContextGetter> url_context_; |
+ AudioEncoder::Codec codec_; |
+ scoped_ptr<AudioEncoder> encoder_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(GoogleSSFERemoteEngine); |
+}; |
+ |
+} // namespace speech |
+ |
+#endif // CONTENT_BROWSER_SPEECH_GOOGLE_SSFE_REMOTE_ENGINE_H_ |