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