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

Unified Diff: content/browser/speech/google_one_shot_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 (partial) Satish 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_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_

Powered by Google App Engine
This is Rietveld 408576698