| 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_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ |
| 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ | 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/public/common/speech_recognition_grammar.h" | 12 #include "content/public/common/speech_recognition_grammar.h" |
| 13 #include "content/public/common/speech_recognition_result.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 class AudioChunk; | 17 class AudioChunk; |
| 17 struct SpeechRecognitionResult; | |
| 18 struct SpeechRecognitionError; | 18 struct SpeechRecognitionError; |
| 19 | 19 |
| 20 // This interface models the basic contract that a speech recognition engine, | 20 // This interface models the basic contract that a speech recognition engine, |
| 21 // either working locally or relying on a remote web-service, must obey. | 21 // either working locally or relying on a remote web-service, must obey. |
| 22 // The expected call sequence for exported methods is: | 22 // The expected call sequence for exported methods is: |
| 23 // StartRecognition Mandatory at beginning of SR. | 23 // StartRecognition Mandatory at beginning of SR. |
| 24 // TakeAudioChunk For every audio chunk pushed. | 24 // TakeAudioChunk For every audio chunk pushed. |
| 25 // AudioChunksEnded Finalize the audio stream (omitted in case of errors). | 25 // AudioChunksEnded Finalize the audio stream (omitted in case of errors). |
| 26 // EndRecognition Mandatory at end of SR (even on errors). | 26 // EndRecognition Mandatory at end of SR (even on errors). |
| 27 // No delegate callbacks are allowed before StartRecognition or after | 27 // No delegate callbacks are allowed before StartRecognition or after |
| 28 // EndRecognition. If a recognition was started, the caller can free the | 28 // EndRecognition. If a recognition was started, the caller can free the |
| 29 // SpeechRecognitionEngine only after calling EndRecognition. | 29 // SpeechRecognitionEngine only after calling EndRecognition. |
| 30 class SpeechRecognitionEngine { | 30 class SpeechRecognitionEngine { |
| 31 public: | 31 public: |
| 32 // Interface for receiving callbacks from this object. | 32 // Interface for receiving callbacks from this object. |
| 33 class Delegate { | 33 class Delegate { |
| 34 public: | 34 public: |
| 35 // Called whenever a result is retrieved. It might be issued several times, | 35 // Called whenever a result is retrieved. It might be issued several times, |
| 36 // (e.g., in the case of continuous speech recognition engine | 36 // (e.g., in the case of continuous speech recognition engine |
| 37 // implementations). | 37 // implementations). |
| 38 virtual void OnSpeechRecognitionEngineResult( | 38 virtual void OnSpeechRecognitionEngineResults( |
| 39 const SpeechRecognitionResult& result) = 0; | 39 const SpeechRecognitionResults& results) = 0; |
| 40 virtual void OnSpeechRecognitionEngineError( | 40 virtual void OnSpeechRecognitionEngineError( |
| 41 const SpeechRecognitionError& error) = 0; | 41 const SpeechRecognitionError& error) = 0; |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 virtual ~Delegate() {} | 44 virtual ~Delegate() {} |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // Remote engine configuration. | 47 // Remote engine configuration. |
| 48 struct CONTENT_EXPORT Config { | 48 struct CONTENT_EXPORT Config { |
| 49 Config(); | 49 Config(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 // These typedefs are to workaround the issue with certain versions of | 104 // These typedefs are to workaround the issue with certain versions of |
| 105 // Visual Studio where it gets confused between multiple Delegate | 105 // Visual Studio where it gets confused between multiple Delegate |
| 106 // classes and gives a C2500 error. | 106 // classes and gives a C2500 error. |
| 107 typedef SpeechRecognitionEngine::Delegate SpeechRecognitionEngineDelegate; | 107 typedef SpeechRecognitionEngine::Delegate SpeechRecognitionEngineDelegate; |
| 108 typedef SpeechRecognitionEngine::Config SpeechRecognitionEngineConfig; | 108 typedef SpeechRecognitionEngine::Config SpeechRecognitionEngineConfig; |
| 109 | 109 |
| 110 } // namespace content | 110 } // namespace content |
| 111 | 111 |
| 112 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ | 112 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ |
| OLD | NEW |