1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.speech;
18 
19 import android.os.Bundle;
20 
21 /**
22  *  Listener for speech recognition events, used with RecognitionService.
23  *  This gives you both the final recognition results, as well as various
24  *  intermediate events that can be used to show visual feedback to the user.
25  *  {@hide}
26  */
27 oneway interface IRecognitionListener {
28     /**
29      * Called when the endpointer is ready for the user to start speaking.
30      *
31      * @param params parameters set by the recognition service. Reserved for future use.
32      */
onReadyForSpeech(in Bundle params)33     void onReadyForSpeech(in Bundle params);
34 
35     /**
36      * The user has started to speak.
37      */
onBeginningOfSpeech()38     void onBeginningOfSpeech();
39 
40     /**
41      * The sound level in the audio stream has changed.
42      *
43      * @param rmsdB the new RMS dB value
44      */
onRmsChanged(in float rmsdB)45     void onRmsChanged(in float rmsdB);
46 
47     /**
48      * More sound has been received.
49      *
50      * @param buffer the byte buffer containing a sequence of 16-bit shorts.
51      */
onBufferReceived(in byte[] buffer)52     void onBufferReceived(in byte[] buffer);
53 
54     /**
55      * Called after the user stops speaking.
56      */
onEndOfSpeech()57     void onEndOfSpeech();
58 
59     /**
60      * A network or recognition error occurred.
61      *
62      * @param error code is defined in {@link SpeechRecognizer}
63      */
onError(in int error)64     void onError(in int error);
65 
66     /**
67      * Called when recognition results are ready.
68      *
69      * @param results a Bundle containing the most likely results (N-best list).
70      */
onResults(in Bundle results)71     void onResults(in Bundle results);
72 
73      /**
74      * Called when recognition partial results are ready.
75      *
76      * @param results a Bundle containing the current most likely result.
77      */
onPartialResults(in Bundle results)78     void onPartialResults(in Bundle results);
79 
80     /**
81      * Reserved for adding future events.
82      *
83      * @param eventType the type of the occurred event
84      * @param params a Bundle containing the passed parameters
85      */
86     @UnsupportedAppUsage
onEvent(in int eventType, in Bundle params)87     void onEvent(in int eventType, in Bundle params);
88 }
89