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

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 compilation issues on windows. 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..236ac9451b33b55eb0e6e4d76d336b258f584255
--- /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 recognition webservice.
+class CONTENT_EXPORT GoogleOneShotRemoteEngine
+ : public NON_EXPORTED_BASE(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;
+
+ explicit GoogleOneShotRemoteEngine(net::URLRequestContextGetter* context);
+ virtual ~GoogleOneShotRemoteEngine();
+ void SetConfig(const GoogleOneShotRemoteEngineConfig& config);
+
+ // SpeechRecognitionEngine methods.
+ virtual void StartRecognition() OVERRIDE;
+ virtual void EndRecognition() 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_
« no previous file with comments | « chrome/browser/speech/speech_input_extension_manager.cc ('k') | content/browser/speech/google_one_shot_remote_engine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698