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