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_ONE_SHOT_REMOTE_ENGINE_H_ | |
6 #define CONTENT_BROWSER_SPEECH_GOOGLE_ONE_SHOT_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 GoogleOneShotRemoteEngineConfig { | |
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 | |
43 GoogleOneShotRemoteEngineConfig(); | |
44 ~GoogleOneShotRemoteEngineConfig(); | |
45 }; | |
46 | |
47 // Implements a SpeechRecognitionEngine by means of remote interaction with | |
48 // 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.
| |
49 // protocol defined in Google Speech API 1.3.2. | |
50 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.
| |
51 public content::URLFetcherDelegate { | |
52 public: | |
53 // Duration of each audio packet. | |
54 static const int kAudioPacketIntervalMs; | |
55 // ID passed to URLFetcher::Create(). Used for testing. | |
56 static int url_fetcher_id_for_tests; | |
57 | |
58 explicit GoogleOneShotRemoteEngine(net::URLRequestContextGetter* context); | |
59 virtual ~GoogleOneShotRemoteEngine(); | |
60 void SetConfiguration(const GoogleOneShotRemoteEngineConfig& config); | |
61 | |
62 // SpeechRecognitionEngine methods. | |
63 virtual void Initialize() OVERRIDE; | |
64 virtual void Cleanup() OVERRIDE; | |
65 virtual void TakeAudioChunk(const AudioChunk& data) OVERRIDE; | |
66 virtual void AudioChunksEnded() OVERRIDE; | |
67 virtual bool IsRecognitionPending() const OVERRIDE; | |
68 virtual int GetDesiredAudioChunkDurationMs() const OVERRIDE; | |
69 | |
70 // content::URLFetcherDelegate methods. | |
71 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | |
72 | |
73 private: | |
74 GoogleOneShotRemoteEngineConfig config_; | |
75 scoped_ptr<content::URLFetcher> url_fetcher_; | |
76 scoped_refptr<net::URLRequestContextGetter> url_context_; | |
77 scoped_ptr<AudioEncoder> encoder_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(GoogleOneShotRemoteEngine); | |
80 }; | |
81 | |
82 } // namespace speech | |
83 | |
84 #endif // CONTENT_BROWSER_SPEECH_GOOGLE_ONE_SHOT_REMOTE_ENGINE_H_ | |
OLD | NEW |