1181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger/*
2181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger * Copyright (C) 2009 The Android Open Source Project
3181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger *
4181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger * Licensed under the Apache License, Version 2.0 (the "License");
5181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger * you may not use this file except in compliance with the License.
6181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger * You may obtain a copy of the License at
7181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger *
8181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger *      http://www.apache.org/licenses/LICENSE-2.0
9181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger *
10181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger * Unless required by applicable law or agreed to in writing, software
11181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger * distributed under the License is distributed on an "AS IS" BASIS,
12181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger * See the License for the specific language governing permissions and
14181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger * limitations under the License.
15181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger */
16181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger
17181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballingerpackage android.speech;
18181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger
1979896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsovimport android.os.Bundle;
20cdd0ac6d85f5530dc88e73b0b51f44708c804b55Brandon Ballingerimport android.content.Intent;
21181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballingerimport android.speech.IRecognitionListener;
22181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger
2379896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov/**
2479896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov* A Service interface to speech recognition. Call startListening when
2579896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov* you want to begin capturing audio; RecognitionService will automatically
2679896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov* determine when the user has finished speaking, stream the audio to the
2779896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov* recognition servers, and notify you when results are ready. In most of the cases,
282a5d9f9b577376768372837723f0f42098aba13bJean-Michel Trivi* this class should not be used directly, instead use {@link SpeechRecognizer} for
2979896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov* accessing recognition service.
3079896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov* {@hide}
3179896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov*/
323da3cad97269d694a6153771fb4a0c3775ca6ab5Valentin Kravtsovoneway interface IRecognitionService {
3379896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov    /**
3479896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     * Starts listening for speech. Please note that the recognition service supports
3579896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     * one listener only, therefore, if this function is called from two different threads,
3679896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     * only the latest one will get the notifications
3779896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     *
3879896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     * @param recognizerIntent the intent from which the invocation occurred. Additionally,
3979896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     *        this intent can contain extra parameters to manipulate the behavior of the recognition
4079896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     *        client. For more information see {@link RecognizerIntent}.
413da3cad97269d694a6153771fb4a0c3775ca6ab5Valentin Kravtsov     * @param listener to receive callbacks, note that this must be non-null
4279896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     */
4379896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov    void startListening(in Intent recognizerIntent, in IRecognitionListener listener);
44181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger
4579896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov    /**
4679896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     * Stops listening for speech. Speech captured so far will be recognized as
4779896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     * if the user had stopped speaking at this point. The function has no effect unless it
4879896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     * is called during the speech capturing.
493da3cad97269d694a6153771fb4a0c3775ca6ab5Valentin Kravtsov     *
503da3cad97269d694a6153771fb4a0c3775ca6ab5Valentin Kravtsov     * @param listener to receive callbacks, note that this must be non-null
5179896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     */
523da3cad97269d694a6153771fb4a0c3775ca6ab5Valentin Kravtsov    void stopListening(in IRecognitionListener listener);
5379896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov
5479896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov    /**
5579896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     * Cancels the speech recognition.
563da3cad97269d694a6153771fb4a0c3775ca6ab5Valentin Kravtsov     *
573da3cad97269d694a6153771fb4a0c3775ca6ab5Valentin Kravtsov     * @param listener to receive callbacks, note that this must be non-null
5879896bd123aa3bc69c6455d4e2ddf2b2b555e6e5Valentin Kravtsov     */
593da3cad97269d694a6153771fb4a0c3775ca6ab5Valentin Kravtsov    void cancel(in IRecognitionListener listener);
60181a44dd81eed5587252ef740663a42fe4d2a9a9Brandon Ballinger}
61