OLD | NEW |
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_RECOGNITION_EVENT_LISTENER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_EVENT_LISTENER_H_ |
6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_EVENT_LISTENER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_EVENT_LISTENER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
10 #include "content/public/common/speech_recognition_result.h" | |
11 | 10 |
12 namespace content { | 11 namespace content { |
13 | 12 |
| 13 struct SpeechRecognitionError; |
| 14 struct SpeechRecognitionResult; |
| 15 |
14 // The interface to be implemented by consumers interested in receiving | 16 // The interface to be implemented by consumers interested in receiving |
15 // speech recognition events. | 17 // speech recognition events. |
16 class CONTENT_EXPORT SpeechRecognitionEventListener { | 18 class CONTENT_EXPORT SpeechRecognitionEventListener { |
17 public: | 19 public: |
18 // Invoked when the StartRequest is received and the recognition process is | 20 // Invoked when the StartRequest is received and the recognition process is |
19 // started. | 21 // started. |
20 virtual void OnRecognitionStart(int caller_id_id) = 0; | 22 virtual void OnRecognitionStart(int caller_id_id) = 0; |
21 | 23 |
22 // Invoked when the first audio capture is initiated. | 24 // Invoked when the first audio capture is initiated. |
23 virtual void OnAudioStart(int caller_id) = 0; | 25 virtual void OnAudioStart(int caller_id) = 0; |
(...skipping 15 matching lines...) Expand all Loading... |
39 virtual void OnAudioEnd(int caller_id) = 0; | 41 virtual void OnAudioEnd(int caller_id) = 0; |
40 | 42 |
41 // Invoked when a result is retrieved. | 43 // Invoked when a result is retrieved. |
42 virtual void OnRecognitionResult(int caller_id, | 44 virtual void OnRecognitionResult(int caller_id, |
43 const SpeechRecognitionResult& result) = 0; | 45 const SpeechRecognitionResult& result) = 0; |
44 | 46 |
45 // Invoked if there was an error while capturing or recognizing audio. | 47 // Invoked if there was an error while capturing or recognizing audio. |
46 // The recognition has already been cancelled when this call is made and | 48 // The recognition has already been cancelled when this call is made and |
47 // no more events will be raised. | 49 // no more events will be raised. |
48 virtual void OnRecognitionError(int caller_id, | 50 virtual void OnRecognitionError(int caller_id, |
49 const SpeechRecognitionErrorCode& error) = 0; | 51 const SpeechRecognitionError& error) = 0; |
50 | 52 |
51 // Informs of a change in the captured audio level, useful if displaying | 53 // Informs of a change in the captured audio level, useful if displaying |
52 // a microphone volume indicator while recording. | 54 // a microphone volume indicator while recording. |
53 // The value of |volume| and |noise_volume| is in the [0.0, 1.0] range. | 55 // The value of |volume| and |noise_volume| is in the [0.0, 1.0] range. |
54 virtual void OnAudioLevelsChange(int caller_id, float volume, | 56 virtual void OnAudioLevelsChange(int caller_id, float volume, |
55 float noise_volume) = 0; | 57 float noise_volume) = 0; |
56 | 58 |
57 // This is guaranteed to be the last event raised in the recognition | 59 // This is guaranteed to be the last event raised in the recognition |
58 // process and the |SpeechRecognizer| object can be freed if necessary. | 60 // process and the |SpeechRecognizer| object can be freed if necessary. |
59 virtual void OnRecognitionEnd(int caller_id) = 0; | 61 virtual void OnRecognitionEnd(int caller_id) = 0; |
60 | 62 |
61 protected: | 63 protected: |
62 virtual ~SpeechRecognitionEventListener() { } | 64 virtual ~SpeechRecognitionEventListener() { } |
63 }; | 65 }; |
64 | 66 |
65 } // namespace content | 67 } // namespace content |
66 | 68 |
67 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_EVENT_LISTENER_H_ | 69 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_EVENT_LISTENER_H_ |
OLD | NEW |