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

Unified Diff: content/browser/speech/google_ssfe_remote_engine.h

Issue 9663066: Refactoring of chrome speech recognition architecture (CL1.3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed according to Hans review. Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
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..de58b6c79d576b1e013130f539ae55a99e93daaa
--- /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;
Satish 2012/03/16 17:00:35 could add a newline below this
Primiano Tucci (use gerrit) 2012/03/20 13:14:50 Done.
+ GoogleSSFERemoteEngineConfig();
+ ~GoogleSSFERemoteEngineConfig();
+};
+
+// Implements a SpeechRecognitionEngine by means of remote interaction with
+// Google Speech Server Front End (SSFE) webservice, according to the HTTP-based
+// protocol defined in Google Speech API 1.3.2.
+class GoogleSSFERemoteEngine : public SpeechRecognitionEngine,
Satish 2012/03/16 17:00:35 I don't think SSFERemoteEngine is a good name for
+ public content::URLFetcherDelegate {
+ public:
+ // Duration of each audio packet.
+ static const int kAudioPacketIntervalMs;
Satish 2012/03/16 17:00:35 are these statics used outside this class? If not,
Primiano Tucci (use gerrit) 2012/03/20 13:14:50 Yes, they are needed by the recognizer unittest.
+ // ID passed to URLFetcher::Create(). Used for testing.
+ static int url_fetcher_id_for_tests;
+
+ explicit GoogleSSFERemoteEngine(net::URLRequestContextGetter* context);
+ void SetConfiguration(const GoogleSSFERemoteEngineConfig& config);
Satish 2012/03/16 17:00:35 suggest moving this below the constructor/destruct
Primiano Tucci (use gerrit) 2012/03/20 13:14:50 Done.
+ 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_;
Satish 2012/03/16 17:00:35 is this member required since it is hardcodec to F
Primiano Tucci (use gerrit) 2012/03/20 13:14:50 Moved to a constant into the anonymous namespace (
+ scoped_ptr<AudioEncoder> encoder_;
+
+ DISALLOW_COPY_AND_ASSIGN(GoogleSSFERemoteEngine);
+};
+
+} // namespace speech
+
+#endif // CONTENT_BROWSER_SPEECH_GOOGLE_SSFE_REMOTE_ENGINE_H_

Powered by Google App Engine
This is Rietveld 408576698