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; |
| 23 | |
| 24 | /** |
| 25 | * Interface for TextToSpeech to talk to TextToSpeechService. |
| 26 | * |
| 27 | * {@hide} |
| 28 | */ |
| 29 | interface ITextToSpeechService { |
| 30 | |
| 31 | /** |
| 32 | * Tells the engine to synthesize some speech and play it back. |
| 33 | * |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 34 | * @param callingInstance a binder representing the identity of the calling |
| 35 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 36 | * @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 Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 40 | 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] | 41 | |
| 42 | /** |
| 43 | * Tells the engine to synthesize some speech and write it to a file. |
| 44 | * |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 45 | * @param callingInstance a binder representing the identity of the calling |
| 46 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 47 | * @param text The text to synthesize. |
Przemyslaw Szczepaniak | 5acb33a | 2013-02-08 16:36:25 +0000 | [diff] [blame] | 48 | * @param fileDescriptor The file descriptor to write the synthesized audio to. Has to be |
| 49 | writable. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 50 | * @param param Request parameters. |
| 51 | */ |
Przemyslaw Szczepaniak | 5acb33a | 2013-02-08 16:36:25 +0000 | [diff] [blame] | 52 | int synthesizeToFileDescriptor(in IBinder callingInstance, in String text, |
| 53 | in ParcelFileDescriptor fileDescriptor, in Bundle params); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 54 | |
| 55 | /** |
| 56 | * Plays an existing audio resource. |
| 57 | * |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 58 | * @param callingInstance a binder representing the identity of the calling |
| 59 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 60 | * @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 Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 64 | 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] | 65 | |
| 66 | /** |
| 67 | * Plays silence. |
| 68 | * |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 69 | * @param callingInstance a binder representing the identity of the calling |
| 70 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 71 | * @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 Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 75 | int playSilence(in IBinder callingInstance, in long duration, in int queueMode, in Bundle params); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 76 | |
| 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 Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 86 | * @param callingInstance a binder representing the identity of the calling |
| 87 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 88 | */ |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 89 | int stop(in IBinder callingInstance); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 90 | |
| 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 Szczepaniak | b465337 | 2012-12-04 14:57:58 +0000 | [diff] [blame] | 102 | |
| 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 Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 115 | /** |
| 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 Kamath | 748af66 | 2011-10-31 14:20:01 +0000 | [diff] [blame] | 131 | * 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 Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 146 | * Notifies the engine that it should load a speech synthesis language. |
| 147 | * |
Przemyslaw Szczepaniak | 13896b7 | 2012-11-09 15:18:16 +0000 | [diff] [blame] | 148 | * @param caller a binder representing the identity of the calling |
| 149 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 150 | * @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 Szczepaniak | 13896b7 | 2012-11-09 15:18:16 +0000 | [diff] [blame] | 160 | 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] | 161 | |
| 162 | /** |
| 163 | * Sets the callback that will be notified when playback of utterance from the |
| 164 | * given app are completed. |
| 165 | * |
Przemyslaw Szczepaniak | 13896b7 | 2012-11-09 15:18:16 +0000 | [diff] [blame] | 166 | * @param caller Instance a binder representing the identity of the calling |
| 167 | * TextToSpeech object. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 168 | * @param cb The callback. |
| 169 | */ |
Narayan Kamath | 492b7f0 | 2011-11-29 17:02:06 +0000 | [diff] [blame] | 170 | void setCallback(in IBinder caller, ITextToSpeechCallback cb); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 171 | |
| 172 | } |