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

Side by Side 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: Rebased from master. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_SPEECH_GOOGLE_SSFE_REMOTE_ENGINE_H_
6 #define CONTENT_BROWSER_SPEECH_GOOGLE_SSFE_REMOTE_ENGINE_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "content/browser/speech/audio_encoder.h"
15 #include "content/browser/speech/speech_recognition_engine.h"
16 #include "content/common/content_export.h"
17 #include "content/public/common/url_fetcher_delegate.h"
18 #include "googleurl/src/gurl.h"
19
20 class URLFetcher;
21
22 namespace content {
23 struct SpeechRecognitionResult;
24 }
25
26 namespace net {
27 class URLRequestContextGetter;
28 }
29
30 namespace speech {
31
32 class AudioChunk;
33
34 struct GoogleSSFERemoteEngineConfig {
35 std::string language;
36 std::string grammar;
37 bool filter_profanities;
38 std::string hardware_info;
39 std::string origin_url;
40 int audio_sample_rate;
41 int audio_num_bits_per_sample;
42 GoogleSSFERemoteEngineConfig();
43 ~GoogleSSFERemoteEngineConfig();
44 };
45
46 // Implements a SpeechRecognitionEngine by means of remote interaction with
47 // Google speech webservice, according to the HTTP-based protocol defined in
48 // 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.
49 class GoogleSSFERemoteEngine : public SpeechRecognitionEngine,
50 public content::URLFetcherDelegate {
51 public:
52 // Duration of each audio packet.
53 static const int kAudioPacketIntervalMs;
54 // ID passed to URLFetcher::Create(). Used for testing.
55 static int url_fetcher_id_for_tests;
56
57 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.
58 void SetConfiguration(const GoogleSSFERemoteEngineConfig& config);
59 virtual ~GoogleSSFERemoteEngine();
60
61 // SpeechRecognitionEngine methods.
62 virtual void SpeechRecognitionBegins() OVERRIDE;
63 virtual void SpeechRecognitionEnds() OVERRIDE;
64 virtual void PushSpeechAudio(const AudioChunk& data) OVERRIDE;
65 virtual void SpeechAudioStreamComplete() OVERRIDE;
66 virtual bool IsRecognitionPending() const OVERRIDE;
67 virtual int DesiredAudioChunkDurationMs() const OVERRIDE;
68
69 // content::URLFetcherDelegate methods.
70 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE;
71
72 private:
73 GoogleSSFERemoteEngineConfig config_;
74 scoped_ptr<content::URLFetcher> url_fetcher_;
75 scoped_refptr<net::URLRequestContextGetter> url_context_;
76 AudioEncoder::Codec codec_;
77 scoped_ptr<AudioEncoder> encoder_;
78
79 DISALLOW_COPY_AND_ASSIGN(GoogleSSFERemoteEngine);
80 };
81
82 } // namespace speech
83
84 #endif // CONTENT_BROWSER_SPEECH_GOOGLE_SSFE_REMOTE_ENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698