blob: 9cf49ffdd45638ee465837a2bf26ca18d4d418fb [file] [log] [blame]
Bjorn Bringert50e657b2011-03-08 16:00:40 +00001/*
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;
Przemyslaw Szczepaniak5acb33a2013-02-08 16:36:25 +000021import android.os.ParcelFileDescriptor;
Bjorn Bringert50e657b2011-03-08 16:00:40 +000022import android.speech.tts.ITextToSpeechCallback;
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +010023import android.speech.tts.VoiceInfo;
24import android.speech.tts.SynthesisRequestV2;
Bjorn Bringert50e657b2011-03-08 16:00:40 +000025
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 *
Narayan Kamath492b7f02011-11-29 17:02:06 +000036 * @param callingInstance a binder representing the identity of the calling
37 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000038 * @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 */
Narayan Kamath492b7f02011-11-29 17:02:06 +000042 int speak(in IBinder callingInstance, in String text, in int queueMode, in Bundle params);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000043
44 /**
45 * Tells the engine to synthesize some speech and write it to a file.
46 *
Narayan Kamath492b7f02011-11-29 17:02:06 +000047 * @param callingInstance a binder representing the identity of the calling
48 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000049 * @param text The text to synthesize.
Przemyslaw Szczepaniak5acb33a2013-02-08 16:36:25 +000050 * @param fileDescriptor The file descriptor to write the synthesized audio to. Has to be
51 writable.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000052 * @param param Request parameters.
53 */
Przemyslaw Szczepaniak5acb33a2013-02-08 16:36:25 +000054 int synthesizeToFileDescriptor(in IBinder callingInstance, in String text,
55 in ParcelFileDescriptor fileDescriptor, in Bundle params);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000056
57 /**
58 * Plays an existing audio resource.
59 *
Narayan Kamath492b7f02011-11-29 17:02:06 +000060 * @param callingInstance a binder representing the identity of the calling
61 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000062 * @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 */
Narayan Kamath492b7f02011-11-29 17:02:06 +000066 int playAudio(in IBinder callingInstance, in Uri audioUri, in int queueMode, in Bundle params);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000067
68 /**
69 * Plays silence.
70 *
Narayan Kamath492b7f02011-11-29 17:02:06 +000071 * @param callingInstance a binder representing the identity of the calling
72 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000073 * @param duration Number of milliseconds of silence to play.
74 * @param queueMode Determines what to do to requests already in the queue.
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +010075 * @param utteranceId Unique id used to identify this request in callbacks.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000076 */
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +010077 int playSilence(in IBinder callingInstance, in long duration, in int queueMode,
78 in String utteranceId);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000079
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 *
Narayan Kamath492b7f02011-11-29 17:02:06 +000089 * @param callingInstance a binder representing the identity of the calling
90 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000091 */
Narayan Kamath492b7f02011-11-29 17:02:06 +000092 int stop(in IBinder callingInstance);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000093
94 /**
95 * Returns the language, country and variant currently being used by the TTS engine.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000096 * 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();
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +0100104
Przemyslaw Szczepaniakb4653372012-12-04 14:57:58 +0000105 /**
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();
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +0100116
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000117 /**
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 /**
Narayan Kamath748af662011-10-31 14:20:01 +0000133 * 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
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +0100142 * the supplied locale. The array of strings must not contain
Narayan Kamath748af662011-10-31 14:20:01 +0000143 * duplicates.
144 */
145 String[] getFeaturesForLanguage(in String lang, in String country, in String variant);
146
147 /**
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000148 * Notifies the engine that it should load a speech synthesis language.
149 *
Przemyslaw Szczepaniak13896b72012-11-09 15:18:16 +0000150 * @param caller a binder representing the identity of the calling
151 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000152 * @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 */
Przemyslaw Szczepaniak13896b72012-11-09 15:18:16 +0000162 int loadLanguage(in IBinder caller, in String lang, in String country, in String variant);
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000163
164 /**
165 * Sets the callback that will be notified when playback of utterance from the
166 * given app are completed.
167 *
Przemyslaw Szczepaniak13896b72012-11-09 15:18:16 +0000168 * @param caller Instance a binder representing the identity of the calling
169 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000170 * @param cb The callback.
171 */
Narayan Kamath492b7f02011-11-29 17:02:06 +0000172 void setCallback(in IBinder caller, ITextToSpeechCallback cb);
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000173
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +0100174 /**
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();
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000214}