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