Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 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 | |
| 17 | package android.speech.tts; |
| 18 | |
| 19 | import android.net.Uri; |
| 20 | import android.os.Bundle; |
Przemyslaw Szczepaniak | 5acb33a | 2013-02-08 16:36:25 +0000 | [diff] [blame] | 21 | import android.os.ParcelFileDescriptor; |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 22 | import android.speech.tts.ITextToSpeechCallback; |
Przemyslaw Szczepaniak | 90d15d2 | 2013-06-14 12:02:53 +0100 | [diff] [blame] | 23 | import android.speech.tts.VoiceInfo; |
| 24 | import android.speech.tts.SynthesisRequestV2; |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Interface for TextToSpeech to talk to TextToSpeechService. |
| 28 | * |
| 29 | * {@hide} |
| 30 | */ |
| 31 | interface ITextToSpeechService { |
| 32 | |
| 33 | /** |
| 34 | * Tells the engine to synthesize some speech and play it back. |
| 35 | * |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 36 | * @param callingInstance a binder representing the identity of the calling |
| 37 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 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 | */ |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 42 | int speak(in IBinder callingInstance, in String text, in int queueMode, in Bundle params); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Tells the engine to synthesize some speech and write it to a file. |
| 46 | * |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 47 | * @param callingInstance a binder representing the identity of the calling |
| 48 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 49 | * @param text The text to synthesize. |
Przemyslaw Szczepaniak | 5acb33a | 2013-02-08 16:36:25 +0000 | [diff] [blame] | 50 | * @param fileDescriptor The file descriptor to write the synthesized audio to. Has to be |
| 51 | writable. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 52 | * @param param Request parameters. |
| 53 | */ |
Przemyslaw Szczepaniak | 5acb33a | 2013-02-08 16:36:25 +0000 | [diff] [blame] | 54 | int synthesizeToFileDescriptor(in IBinder callingInstance, in String text, |
| 55 | in ParcelFileDescriptor fileDescriptor, in Bundle params); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * Plays an existing audio resource. |
| 59 | * |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 60 | * @param callingInstance a binder representing the identity of the calling |
| 61 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 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 | */ |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 66 | int playAudio(in IBinder callingInstance, in Uri audioUri, in int queueMode, in Bundle params); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * Plays silence. |
| 70 | * |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 71 | * @param callingInstance a binder representing the identity of the calling |
| 72 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 73 | * @param duration Number of milliseconds of silence to play. |
| 74 | * @param queueMode Determines what to do to requests already in the queue. |
Przemyslaw Szczepaniak | 90d15d2 | 2013-06-14 12:02:53 +0100 | [diff] [blame] | 75 | * @param utteranceId Unique id used to identify this request in callbacks. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 76 | */ |
Przemyslaw Szczepaniak | 90d15d2 | 2013-06-14 12:02:53 +0100 | [diff] [blame] | 77 | int playSilence(in IBinder callingInstance, in long duration, in int queueMode, |
| 78 | in String utteranceId); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 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 | * |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 89 | * @param callingInstance a binder representing the identity of the calling |
| 90 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 91 | */ |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 92 | int stop(in IBinder callingInstance); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 93 | |
| 94 | /** |
| 95 | * Returns the language, country and variant currently being used by the TTS engine. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 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(); |
Przemyslaw Szczepaniak | 90d15d2 | 2013-06-14 12:02:53 +0100 | [diff] [blame] | 104 | |
Przemyslaw Szczepaniak | b465337 | 2012-12-04 14:57:58 +0000 | [diff] [blame] | 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(); |
Przemyslaw Szczepaniak | 90d15d2 | 2013-06-14 12:02:53 +0100 | [diff] [blame] | 116 | |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 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 | /** |
Narayan Kamath | 748af66 | 2011-10-31 14:20:01 +0000 | [diff] [blame] | 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 |
Przemyslaw Szczepaniak | 90d15d2 | 2013-06-14 12:02:53 +0100 | [diff] [blame] | 142 | * the supplied locale. The array of strings must not contain |
Narayan Kamath | 748af66 | 2011-10-31 14:20:01 +0000 | [diff] [blame] | 143 | * duplicates. |
| 144 | */ |
| 145 | String[] getFeaturesForLanguage(in String lang, in String country, in String variant); |
| 146 | |
| 147 | /** |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 148 | * Notifies the engine that it should load a speech synthesis language. |
| 149 | * |
Przemyslaw Szczepaniak | 13896b7 | 2012-11-09 15:18:16 +0000 | [diff] [blame] | 150 | * @param caller a binder representing the identity of the calling |
| 151 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 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 | */ |
Przemyslaw Szczepaniak | 13896b7 | 2012-11-09 15:18:16 +0000 | [diff] [blame] | 162 | int loadLanguage(in IBinder caller, in String lang, in String country, in String variant); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 163 | |
| 164 | /** |
| 165 | * Sets the callback that will be notified when playback of utterance from the |
| 166 | * given app are completed. |
| 167 | * |
Przemyslaw Szczepaniak | 13896b7 | 2012-11-09 15:18:16 +0000 | [diff] [blame] | 168 | * @param caller Instance a binder representing the identity of the calling |
| 169 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 170 | * @param cb The callback. |
| 171 | */ |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 172 | void setCallback(in IBinder caller, ITextToSpeechCallback cb); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 173 | |
Przemyslaw Szczepaniak | 90d15d2 | 2013-06-14 12:02:53 +0100 | [diff] [blame] | 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(); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 214 | } |