OLD | NEW |
---|---|
(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; | |
Satish
2012/03/16 17:00:35
could add a newline below this
Primiano Tucci (use gerrit)
2012/03/20 13:14:50
Done.
| |
42 GoogleSSFERemoteEngineConfig(); | |
43 ~GoogleSSFERemoteEngineConfig(); | |
44 }; | |
45 | |
46 // Implements a SpeechRecognitionEngine by means of remote interaction with | |
47 // Google Speech Server Front End (SSFE) webservice, according to the HTTP-based | |
48 // protocol defined in Google Speech API 1.3.2. | |
49 class GoogleSSFERemoteEngine : public SpeechRecognitionEngine, | |
Satish
2012/03/16 17:00:35
I don't think SSFERemoteEngine is a good name for
| |
50 public content::URLFetcherDelegate { | |
51 public: | |
52 // Duration of each audio packet. | |
53 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.
| |
54 // ID passed to URLFetcher::Create(). Used for testing. | |
55 static int url_fetcher_id_for_tests; | |
56 | |
57 explicit GoogleSSFERemoteEngine(net::URLRequestContextGetter* context); | |
58 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.
| |
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_; | |
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 (
| |
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_ | |
OLD | NEW |