ITextToSpeechService.aidl revision b46533732c40c6aa4d0d7357176835a33d863234
1/*
2 * Copyright (C) 2011 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
17package android.speech.tts;
18
19import android.net.Uri;
20import android.os.Bundle;
21import android.speech.tts.ITextToSpeechCallback;
22
23/**
24 * Interface for TextToSpeech to talk to TextToSpeechService.
25 *
26 * {@hide}
27 */
28interface ITextToSpeechService {
29
30    /**
31     * Tells the engine to synthesize some speech and play it back.
32     *
33     * @param callingInstance a binder representing the identity of the calling
34     *        TextToSpeech object.
35     * @param text The text to synthesize.
36     * @param queueMode Determines what to do to requests already in the queue.
37     * @param param Request parameters.
38     */
39    int speak(in IBinder callingInstance, in String text, in int queueMode, in Bundle params);
40
41    /**
42     * Tells the engine to synthesize some speech and write it to a file.
43     *
44     * @param callingInstance a binder representing the identity of the calling
45     *        TextToSpeech object.
46     * @param text The text to synthesize.
47     * @param filename The file to write the synthesized audio to.
48     * @param param Request parameters.
49     */
50    int synthesizeToFile(in IBinder callingInstance, in String text,
51        in String filename, in Bundle params);
52
53    /**
54     * Plays an existing audio resource.
55     *
56     * @param callingInstance a binder representing the identity of the calling
57     *        TextToSpeech object.
58     * @param audioUri URI for the audio resource (a file or android.resource URI)
59     * @param queueMode Determines what to do to requests already in the queue.
60     * @param param Request parameters.
61     */
62    int playAudio(in IBinder callingInstance, in Uri audioUri, in int queueMode, in Bundle params);
63
64    /**
65     * Plays silence.
66     *
67     * @param callingInstance a binder representing the identity of the calling
68     *        TextToSpeech object.
69     * @param duration Number of milliseconds of silence to play.
70     * @param queueMode Determines what to do to requests already in the queue.
71     * @param param Request parameters.
72     */
73    int playSilence(in IBinder callingInstance, in long duration, in int queueMode, in Bundle params);
74
75    /**
76     * Checks whether the service is currently playing some audio.
77     */
78    boolean isSpeaking();
79
80    /**
81     * Interrupts the current utterance (if from the given app) and removes any utterances
82     * in the queue that are from the given app.
83     *
84     * @param callingInstance a binder representing the identity of the calling
85     *        TextToSpeech object.
86     */
87    int stop(in IBinder callingInstance);
88
89    /**
90     * Returns the language, country and variant currently being used by the TTS engine.
91     *
92     * Can be called from multiple threads.
93     *
94     * @return A 3-element array, containing language (ISO 3-letter code),
95     *         country (ISO 3-letter code) and variant used by the engine.
96     *         The country and variant may be {@code ""}. If country is empty, then variant must
97     *         be empty too.
98     */
99    String[] getLanguage();
100
101    /**
102     * Returns a default TTS language, country and variant as set by the user.
103     *
104     * Can be called from multiple threads.
105     *
106     * @return A 3-element array, containing language (ISO 3-letter code),
107     *         country (ISO 3-letter code) and variant used by the engine.
108     *         The country and variant may be {@code ""}. If country is empty, then variant must
109     *         be empty too.
110     */
111    String[] getClientDefaultLanguage();
112
113    /**
114     * Checks whether the engine supports a given language.
115     *
116     * @param lang ISO-3 language code.
117     * @param country ISO-3 country code. May be empty or null.
118     * @param variant Language variant. May be empty or null.
119     * @return Code indicating the support status for the locale.
120     *         One of {@link TextToSpeech#LANG_AVAILABLE},
121     *         {@link TextToSpeech#LANG_COUNTRY_AVAILABLE},
122     *         {@link TextToSpeech#LANG_COUNTRY_VAR_AVAILABLE},
123     *         {@link TextToSpeech#LANG_MISSING_DATA}
124     *         {@link TextToSpeech#LANG_NOT_SUPPORTED}.
125     */
126    int isLanguageAvailable(in String lang, in String country, in String variant);
127
128    /**
129     * Returns a list of features available for a given language. Elements of the returned
130     * string array can be passed in as keys to {@link TextToSpeech#speak} and
131     * {@link TextToSpeech#synthesizeToFile} to select a given feature or features to be
132     * used during synthesis.
133     *
134     * @param lang ISO-3 language code.
135     * @param country ISO-3 country code. May be empty or null.
136     * @param variant Language variant. May be empty or null.
137     * @return An array of strings containing the set of features supported for
138     *         the supplied locale. The array of strings must not contain
139     *         duplicates.
140     */
141    String[] getFeaturesForLanguage(in String lang, in String country, in String variant);
142
143    /**
144     * Notifies the engine that it should load a speech synthesis language.
145     *
146     * @param caller a binder representing the identity of the calling
147     *        TextToSpeech object.
148     * @param lang ISO-3 language code.
149     * @param country ISO-3 country code. May be empty or null.
150     * @param variant Language variant. May be empty or null.
151     * @return Code indicating the support status for the locale.
152     *         One of {@link TextToSpeech#LANG_AVAILABLE},
153     *         {@link TextToSpeech#LANG_COUNTRY_AVAILABLE},
154     *         {@link TextToSpeech#LANG_COUNTRY_VAR_AVAILABLE},
155     *         {@link TextToSpeech#LANG_MISSING_DATA}
156     *         {@link TextToSpeech#LANG_NOT_SUPPORTED}.
157     */
158    int loadLanguage(in IBinder caller, in String lang, in String country, in String variant);
159
160    /**
161     * Sets the callback that will be notified when playback of utterance from the
162     * given app are completed.
163     *
164     * @param caller Instance a binder representing the identity of the calling
165     *        TextToSpeech object.
166     * @param cb The callback.
167     */
168    void setCallback(in IBinder caller, ITextToSpeechCallback cb);
169
170}
171