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 import android.content.AttributionSource; 21 import android.content.Intent; 22 import android.speech.IRecognitionListener; 23 24 /** 25 * A Service interface to speech recognition. Call startListening when 26 * you want to begin capturing audio; RecognitionService will automatically 27 * determine when the user has finished speaking, stream the audio to the 28 * recognition servers, and notify you when results are ready. In most of the cases, 29 * this class should not be used directly, instead use {@link SpeechRecognizer} for 30 * accessing recognition service. 31 * {@hide} 32 */ 33 oneway interface IRecognitionService { 34 /** 35 * Starts listening for speech. Please note that the recognition service supports 36 * one listener only, therefore, if this function is called from two different threads, 37 * only the latest one will get the notifications 38 * 39 * @param recognizerIntent the intent from which the invocation occurred. Additionally, 40 * this intent can contain extra parameters to manipulate the behavior of the recognition 41 * client. For more information see {@link RecognizerIntent}. 42 * @param listener to receive callbacks, note that this must be non-null 43 * @param attributionSource The attribution source of the caller. 44 */ startListening(in Intent recognizerIntent, in IRecognitionListener listener, in AttributionSource attributionSource)45 void startListening(in Intent recognizerIntent, in IRecognitionListener listener, 46 in AttributionSource attributionSource); 47 48 /** 49 * Stops listening for speech. Speech captured so far will be recognized as 50 * if the user had stopped speaking at this point. The function has no effect unless it 51 * is called during the speech capturing. 52 * 53 * @param listener to receive callbacks, note that this must be non-null 54 */ stopListening(in IRecognitionListener listener)55 void stopListening(in IRecognitionListener listener); 56 57 /** 58 * Cancels the speech recognition. 59 * 60 * @param listener to receive callbacks, note that this must be non-null 61 */ cancel(in IRecognitionListener listener, boolean isShutdown)62 void cancel(in IRecognitionListener listener, boolean isShutdown); 63 } 64