blob: b7bc70c7cae096e17bfe95221400ab738f6b60ec [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;
23
24/**
25 * Interface for TextToSpeech to talk to TextToSpeechService.
26 *
27 * {@hide}
28 */
29interface ITextToSpeechService {
30
31 /**
32 * Tells the engine to synthesize some speech and play it back.
33 *
Narayan Kamath492b7f02011-11-29 17:02:06 +000034 * @param callingInstance a binder representing the identity of the calling
35 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000036 * @param text The text to synthesize.
37 * @param queueMode Determines what to do to requests already in the queue.
38 * @param param Request parameters.
39 */
Narayan Kamath492b7f02011-11-29 17:02:06 +000040 int speak(in IBinder callingInstance, in String text, in int queueMode, in Bundle params);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000041
42 /**
43 * Tells the engine to synthesize some speech and write it to a file.
44 *
Narayan Kamath492b7f02011-11-29 17:02:06 +000045 * @param callingInstance a binder representing the identity of the calling
46 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000047 * @param text The text to synthesize.
Przemyslaw Szczepaniak5acb33a2013-02-08 16:36:25 +000048 * @param fileDescriptor The file descriptor to write the synthesized audio to. Has to be
49 writable.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000050 * @param param Request parameters.
51 */
Przemyslaw Szczepaniak5acb33a2013-02-08 16:36:25 +000052 int synthesizeToFileDescriptor(in IBinder callingInstance, in String text,
53 in ParcelFileDescriptor fileDescriptor, in Bundle params);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000054
55 /**
56 * Plays an existing audio resource.
57 *
Narayan Kamath492b7f02011-11-29 17:02:06 +000058 * @param callingInstance a binder representing the identity of the calling
59 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000060 * @param audioUri URI for the audio resource (a file or android.resource URI)
61 * @param queueMode Determines what to do to requests already in the queue.
62 * @param param Request parameters.
63 */
Narayan Kamath492b7f02011-11-29 17:02:06 +000064 int playAudio(in IBinder callingInstance, in Uri audioUri, in int queueMode, in Bundle params);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000065
66 /**
67 * Plays silence.
68 *
Narayan Kamath492b7f02011-11-29 17:02:06 +000069 * @param callingInstance a binder representing the identity of the calling
70 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000071 * @param duration Number of milliseconds of silence to play.
72 * @param queueMode Determines what to do to requests already in the queue.
73 * @param param Request parameters.
74 */
Narayan Kamath492b7f02011-11-29 17:02:06 +000075 int playSilence(in IBinder callingInstance, in long duration, in int queueMode, in Bundle params);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000076
77 /**
78 * Checks whether the service is currently playing some audio.
79 */
80 boolean isSpeaking();
81
82 /**
83 * Interrupts the current utterance (if from the given app) and removes any utterances
84 * in the queue that are from the given app.
85 *
Narayan Kamath492b7f02011-11-29 17:02:06 +000086 * @param callingInstance a binder representing the identity of the calling
87 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000088 */
Narayan Kamath492b7f02011-11-29 17:02:06 +000089 int stop(in IBinder callingInstance);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000090
91 /**
92 * Returns the language, country and variant currently being used by the TTS engine.
93 *
94 * Can be called from multiple threads.
95 *
96 * @return A 3-element array, containing language (ISO 3-letter code),
97 * country (ISO 3-letter code) and variant used by the engine.
98 * The country and variant may be {@code ""}. If country is empty, then variant must
99 * be empty too.
100 */
101 String[] getLanguage();
Przemyslaw Szczepaniakb4653372012-12-04 14:57:58 +0000102
103 /**
104 * Returns a default TTS language, country and variant as set by the user.
105 *
106 * Can be called from multiple threads.
107 *
108 * @return A 3-element array, containing language (ISO 3-letter code),
109 * country (ISO 3-letter code) and variant used by the engine.
110 * The country and variant may be {@code ""}. If country is empty, then variant must
111 * be empty too.
112 */
113 String[] getClientDefaultLanguage();
114
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000115 /**
116 * Checks whether the engine supports a given language.
117 *
118 * @param lang ISO-3 language code.
119 * @param country ISO-3 country code. May be empty or null.
120 * @param variant Language variant. May be empty or null.
121 * @return Code indicating the support status for the locale.
122 * One of {@link TextToSpeech#LANG_AVAILABLE},
123 * {@link TextToSpeech#LANG_COUNTRY_AVAILABLE},
124 * {@link TextToSpeech#LANG_COUNTRY_VAR_AVAILABLE},
125 * {@link TextToSpeech#LANG_MISSING_DATA}
126 * {@link TextToSpeech#LANG_NOT_SUPPORTED}.
127 */
128 int isLanguageAvailable(in String lang, in String country, in String variant);
129
130 /**
Narayan Kamath748af662011-10-31 14:20:01 +0000131 * Returns a list of features available for a given language. Elements of the returned
132 * string array can be passed in as keys to {@link TextToSpeech#speak} and
133 * {@link TextToSpeech#synthesizeToFile} to select a given feature or features to be
134 * used during synthesis.
135 *
136 * @param lang ISO-3 language code.
137 * @param country ISO-3 country code. May be empty or null.
138 * @param variant Language variant. May be empty or null.
139 * @return An array of strings containing the set of features supported for
140 * the supplied locale. The array of strings must not contain
141 * duplicates.
142 */
143 String[] getFeaturesForLanguage(in String lang, in String country, in String variant);
144
145 /**
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000146 * Notifies the engine that it should load a speech synthesis language.
147 *
Przemyslaw Szczepaniak13896b72012-11-09 15:18:16 +0000148 * @param caller a binder representing the identity of the calling
149 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000150 * @param lang ISO-3 language code.
151 * @param country ISO-3 country code. May be empty or null.
152 * @param variant Language variant. May be empty or null.
153 * @return Code indicating the support status for the locale.
154 * One of {@link TextToSpeech#LANG_AVAILABLE},
155 * {@link TextToSpeech#LANG_COUNTRY_AVAILABLE},
156 * {@link TextToSpeech#LANG_COUNTRY_VAR_AVAILABLE},
157 * {@link TextToSpeech#LANG_MISSING_DATA}
158 * {@link TextToSpeech#LANG_NOT_SUPPORTED}.
159 */
Przemyslaw Szczepaniak13896b72012-11-09 15:18:16 +0000160 int loadLanguage(in IBinder caller, in String lang, in String country, in String variant);
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000161
162 /**
163 * Sets the callback that will be notified when playback of utterance from the
164 * given app are completed.
165 *
Przemyslaw Szczepaniak13896b72012-11-09 15:18:16 +0000166 * @param caller Instance a binder representing the identity of the calling
167 * TextToSpeech object.
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000168 * @param cb The callback.
169 */
Narayan Kamath492b7f02011-11-29 17:02:06 +0000170 void setCallback(in IBinder caller, ITextToSpeechCallback cb);
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000171
172}