1 // Copyright 2014 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 CHROME_BROWSER_SPEECH_SPEECH_RECOGNIZER_DELEGATE_H_ 6 #define CHROME_BROWSER_SPEECH_SPEECH_RECOGNIZER_DELEGATE_H_ 7 8 #include <stdint.h> 9 #include <string> 10 11 #include "base/strings/string16.h" 12 13 // Requires cleanup. See crbug.com/800374. 14 enum SpeechRecognizerStatus { 15 SPEECH_RECOGNIZER_OFF = 0, 16 SPEECH_RECOGNIZER_READY, 17 SPEECH_RECOGNIZER_RECOGNIZING, 18 SPEECH_RECOGNIZER_IN_SPEECH, 19 SPEECH_RECOGNIZER_STOPPING, 20 SPEECH_RECOGNIZER_NETWORK_ERROR, 21 }; 22 23 // Delegate for speech recognizer. All methods are called from the UI 24 // thread. 25 class SpeechRecognizerDelegate { 26 public: 27 // Receive a speech recognition result. |is_final| indicated whether the 28 // result is an intermediate or final result. If |is_final| is true, then the 29 // recognizer stops and no more results will be returned. 30 virtual void OnSpeechResult(const base::string16& query, bool is_final) = 0; 31 32 // Invoked regularly to indicate the average sound volume. 33 virtual void OnSpeechSoundLevelChanged(int16_t level) = 0; 34 35 // Invoked when the state of speech recognition is changed. 36 virtual void OnSpeechRecognitionStateChanged( 37 SpeechRecognizerStatus new_state) = 0; 38 39 // Get the OAuth2 scope and token to pass to the speech recognizer. Does not 40 // modify the arguments if no auth token is available or allowed. 41 virtual void GetSpeechAuthParameters(std::string* auth_scope, 42 std::string* auth_token) = 0; 43 44 protected: ~SpeechRecognizerDelegate()45 virtual ~SpeechRecognizerDelegate() {} 46 }; 47 48 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNIZER_DELEGATE_H_ 49