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; 21 import android.speech.tts.ITextToSpeechCallback; 22 23 /** 24 * Interface for TextToSpeech to talk to TextToSpeechService. 25 * 26 * {@hide} 27 */ 28 interface ITextToSpeechService { 29 30 /** 31 * Tells the engine to synthesize some speech and play it back. 32 * 33 * @param callingInstance a binder representing the identity of the calling 34 * TextToSpeech object. 35 * @param text The text to synthesize. 36 * @param queueMode Determines what to do to requests already in the queue. 37 * @param param Request parameters. 38 */ 39 int speak(in IBinder callingInstance, in String text, in int queueMode, in Bundle params); 40 41 /** 42 * Tells the engine to synthesize some speech and write it to a file. 43 * 44 * @param callingInstance a binder representing the identity of the calling 45 * TextToSpeech object. 46 * @param text The text to synthesize. 47 * @param filename The file to write the synthesized audio to. 48 * @param param Request parameters. 49 */ 50 int synthesizeToFile(in IBinder callingInstance, in String text, 51 in String filename, in Bundle params); 52 53 /** 54 * Plays an existing audio resource. 55 * 56 * @param callingInstance a binder representing the identity of the calling 57 * TextToSpeech object. 58 * @param audioUri URI for the audio resource (a file or android.resource URI) 59 * @param queueMode Determines what to do to requests already in the queue. 60 * @param param Request parameters. 61 */ 62 int playAudio(in IBinder callingInstance, in Uri audioUri, in int queueMode, in Bundle params); 63 64 /** 65 * Plays silence. 66 * 67 * @param callingInstance a binder representing the identity of the calling 68 * TextToSpeech object. 69 * @param duration Number of milliseconds of silence to play. 70 * @param queueMode Determines what to do to requests already in the queue. 71 * @param param Request parameters. 72 */ 73 int playSilence(in IBinder callingInstance, in long duration, in int queueMode, in Bundle params); 74 75 /** 76 * Checks whether the service is currently playing some audio. 77 */ 78 boolean isSpeaking(); 79 80 /** 81 * Interrupts the current utterance (if from the given app) and removes any utterances 82 * in the queue that are from the given app. 83 * 84 * @param callingInstance a binder representing the identity of the calling 85 * TextToSpeech object. 86 */ 87 int stop(in IBinder callingInstance); 88 89 /** 90 * Returns the language, country and variant currently being used by the TTS engine. 91 * 92 * Can be called from multiple threads. 93 * 94 * @return A 3-element array, containing language (ISO 3-letter code), 95 * country (ISO 3-letter code) and variant used by the engine. 96 * The country and variant may be {@code ""}. If country is empty, then variant must 97 * be empty too. 98 */ 99 String[] getLanguage(); 100 101 /** 102 * Checks whether the engine supports a given language. 103 * 104 * @param lang ISO-3 language code. 105 * @param country ISO-3 country code. May be empty or null. 106 * @param variant Language variant. May be empty or null. 107 * @return Code indicating the support status for the locale. 108 * One of {@link TextToSpeech#LANG_AVAILABLE}, 109 * {@link TextToSpeech#LANG_COUNTRY_AVAILABLE}, 110 * {@link TextToSpeech#LANG_COUNTRY_VAR_AVAILABLE}, 111 * {@link TextToSpeech#LANG_MISSING_DATA} 112 * {@link TextToSpeech#LANG_NOT_SUPPORTED}. 113 */ 114 int isLanguageAvailable(in String lang, in String country, in String variant); 115 116 /** 117 * Returns a list of features available for a given language. Elements of the returned 118 * string array can be passed in as keys to {@link TextToSpeech#speak} and 119 * {@link TextToSpeech#synthesizeToFile} to select a given feature or features to be 120 * used during synthesis. 121 * 122 * @param lang ISO-3 language code. 123 * @param country ISO-3 country code. May be empty or null. 124 * @param variant Language variant. May be empty or null. 125 * @return An array of strings containing the set of features supported for 126 * the supplied locale. The array of strings must not contain 127 * duplicates. 128 */ 129 String[] getFeaturesForLanguage(in String lang, in String country, in String variant); 130 131 /** 132 * Notifies the engine that it should load a speech synthesis language. 133 * 134 * @param lang ISO-3 language code. 135 * @param country ISO-3 country code. May be empty or null. 136 * @param variant Language variant. May be empty or null. 137 * @return Code indicating the support status for the locale. 138 * One of {@link TextToSpeech#LANG_AVAILABLE}, 139 * {@link TextToSpeech#LANG_COUNTRY_AVAILABLE}, 140 * {@link TextToSpeech#LANG_COUNTRY_VAR_AVAILABLE}, 141 * {@link TextToSpeech#LANG_MISSING_DATA} 142 * {@link TextToSpeech#LANG_NOT_SUPPORTED}. 143 */ 144 int loadLanguage(in String lang, in String country, in String variant); 145 146 /** 147 * Sets the callback that will be notified when playback of utterance from the 148 * given app are completed. 149 * 150 * @param callingApp Package name for the app whose utterance the callback will handle. 151 * @param cb The callback. 152 */ 153 void setCallback(in IBinder caller, ITextToSpeechCallback cb); 154 155 } 156