Chromium Code Reviews| 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_PUBLIC_BROWSER_SPEECH_RECOGNIZER_DELEGATE_H_ | |
| 6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_DELEGATE_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "content/public/common/speech_input_result.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 // Implemented by the caller to receive recognition events. | |
|
jam
2012/02/13 17:42:12
nit: this comment now needs more context, since |c
tfarina
2012/02/13 18:44:17
Done.
| |
| 14 class SpeechRecognizerDelegate { | |
| 15 public: | |
| 16 virtual void SetRecognitionResult(int caller_id, | |
| 17 const SpeechInputResult& result) = 0; | |
| 18 | |
| 19 // Invoked when the first audio packet was received from the audio capture | |
| 20 // device. | |
| 21 virtual void DidStartReceivingAudio(int caller_id) = 0; | |
| 22 | |
| 23 // Invoked when audio recording stops, either due to the end pointer | |
| 24 // detecting silence in user input or if |StopRecording| was called. The | |
| 25 // delegate has to wait until |DidCompleteRecognition| is invoked before | |
| 26 // destroying the |SpeechRecognizer| object. | |
| 27 virtual void DidCompleteRecording(int caller_id) = 0; | |
| 28 | |
| 29 // This is guaranteed to be the last method invoked in the recognition | |
| 30 // sequence and the |SpeechRecognizer| object can be freed up if necessary. | |
| 31 virtual void DidCompleteRecognition(int caller_id) = 0; | |
| 32 | |
| 33 // Informs that the end pointer has started detecting speech. | |
| 34 virtual void DidStartReceivingSpeech(int caller_id) = 0; | |
| 35 | |
| 36 // Informs that the end pointer has stopped detecting speech. | |
| 37 virtual void DidStopReceivingSpeech(int caller_id) = 0; | |
| 38 | |
| 39 // Invoked if there was an error while recording or recognizing audio. The | |
| 40 // session has already been cancelled when this call is made and the DidXxxx | |
| 41 // callbacks will not be issued. It is safe to destroy/release the | |
| 42 // |SpeechRecognizer| object while processing this call. | |
| 43 virtual void OnRecognizerError(int caller_id, SpeechInputError error) = 0; | |
| 44 | |
| 45 // At the start of recognition, a short amount of audio is recorded to | |
| 46 // estimate the environment/background noise and this callback is issued | |
| 47 // after that is complete. Typically the delegate brings up any speech | |
| 48 // recognition UI once this callback is received. | |
| 49 virtual void DidCompleteEnvironmentEstimation(int caller_id) = 0; | |
| 50 | |
| 51 // Informs of a change in the captured audio level, useful if displaying | |
| 52 // a microphone volume indicator while recording. | |
| 53 // The value of |volume| and |noise_volume| is in the [0.0, 1.0] range. | |
| 54 virtual void SetInputVolume(int caller_id, | |
| 55 float volume, | |
| 56 float noise_volume) = 0; | |
| 57 | |
| 58 protected: | |
| 59 virtual ~SpeechRecognizerDelegate() {} | |
| 60 }; | |
| 61 | |
| 62 } // namespace content | |
| 63 | |
| 64 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_DELEGATE_H_ | |
| OLD | NEW |