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

Side by Side Diff: content/public/browser/speech_recognizer.h

Issue 9688012: Refactoring of chrome speech recognition architecture (CL1.2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor fix in recognizer unit test due to "others" CL in the middle (9692038) 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_H_
6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_H_ 6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 12
13 namespace net { 13 namespace net {
14 class URLRequestContextGetter; 14 class URLRequestContextGetter;
15 } 15 }
16 16
17 namespace content { 17 namespace content {
18 18
19 class SpeechRecognizerDelegate; 19 class SpeechRecognitionEventListener;
20 20
21 // Records audio, sends recorded audio to server and translates server response 21 // Records audio, sends recorded audio to server and translates server response
22 // to recognition result. 22 // to recognition result.
23 // TODO(primiano) remove this public interface as soon as we fix speech input
24 // extensions.
23 class SpeechRecognizer : public base::RefCountedThreadSafe<SpeechRecognizer> { 25 class SpeechRecognizer : public base::RefCountedThreadSafe<SpeechRecognizer> {
24 public: 26 public:
27
28 // TODO(primiano) Create(...) is transitional (until we fix speech input
29 // extensions) and should be removed soon. The manager should be the only one
30 // knowing the existence of SpeechRecognizer, thus the only one in charge of
31 // instantiating it.
25 CONTENT_EXPORT static SpeechRecognizer* Create( 32 CONTENT_EXPORT static SpeechRecognizer* Create(
26 SpeechRecognizerDelegate* delegate, 33 SpeechRecognitionEventListener* event_listener,
27 int caller_id, 34 int caller_id,
28 const std::string& language, 35 const std::string& language,
29 const std::string& grammar, 36 const std::string& grammar,
30 net::URLRequestContextGetter* context_getter, 37 net::URLRequestContextGetter* context_getter,
31 bool filter_profanities, 38 bool filter_profanities,
32 const std::string& hardware_info, 39 const std::string& hardware_info,
33 const std::string& origin_url); 40 const std::string& origin_url);
34 41
35 virtual ~SpeechRecognizer() {} 42 virtual ~SpeechRecognizer() {}
36 43
37 // Starts audio recording and does recognition after recording ends. The same 44 // Starts audio recording and the recognition process. The same
38 // SpeechRecognizer instance can be used multiple times for speech recognition 45 // SpeechRecognizer instance can be used multiple times for speech recognition
39 // though each recognition request can be made only after the previous one 46 // though each recognition request can be made only after the previous one
40 // completes (i.e. after receiving 47 // completes (i.e. after receiving
41 // SpeechRecognizerDelegate::DidCompleteRecognition). 48 // SpeechRecognitionEventListener::OnRecognitionEnd).
42 virtual bool StartRecording() = 0; 49 virtual bool StartRecognition() = 0;
43 50
44 // Stops recording audio and cancels recognition. Any audio recorded so far 51 // Stops recording audio and cancels recognition. Any audio recorded so far
45 // gets discarded. 52 // gets discarded.
46 virtual void CancelRecognition() = 0; 53 virtual void AbortRecognition() = 0;
54
55 // Stops recording audio and finalizes recognition, possibly getting results.
56 virtual void StopAudioCapture() = 0;
57
58 // Checks wether the recognizer is active, that is, either capturing audio
59 // or waiting for a result.
60 virtual bool IsActive() const = 0;
61
62 // Checks wether the recognizer is capturing audio.
63 virtual bool IsCapturingAudio() const = 0;
47 }; 64 };
48 65
49 } // namespace speech 66 } // namespace content
50 67
51 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_H_ 68 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_H_
OLDNEW
« no previous file with comments | « content/public/browser/speech_recognition_event_listener.h ('k') | content/public/browser/speech_recognizer_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698