150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert/* 250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Copyright (C) 2011 The Android Open Source Project 350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); 550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * you may not use this file except in compliance with the License. 650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * You may obtain a copy of the License at 750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 1050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Unless required by applicable law or agreed to in writing, software 1150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS, 1250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * See the License for the specific language governing permissions and 1450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * limitations under the License. 1550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 1650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 1750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringertpackage android.speech.tts; 1850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 1950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringertimport android.net.Uri; 2050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringertimport android.os.Bundle; 2150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringertimport android.speech.tts.ITextToSpeechCallback; 2250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 2350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert/** 2450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Interface for TextToSpeech to talk to TextToSpeechService. 2550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 2650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * {@hide} 2750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 2850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringertinterface ITextToSpeechService { 2950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 3050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 3150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Tells the engine to synthesize some speech and play it back. 3250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 33492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath * @param callingInstance a binder representing the identity of the calling 34492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath * TextToSpeech object. 3550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param text The text to synthesize. 3650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param queueMode Determines what to do to requests already in the queue. 3750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param param Request parameters. 3850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 39492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath int speak(in IBinder callingInstance, in String text, in int queueMode, in Bundle params); 4050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 4150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 4250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Tells the engine to synthesize some speech and write it to a file. 4350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 44492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath * @param callingInstance a binder representing the identity of the calling 45492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath * TextToSpeech object. 4650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param text The text to synthesize. 4750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param filename The file to write the synthesized audio to. 4850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param param Request parameters. 4950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 50492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath int synthesizeToFile(in IBinder callingInstance, in String text, 5150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert in String filename, in Bundle params); 5250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 5350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 5450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Plays an existing audio resource. 5550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 56492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath * @param callingInstance a binder representing the identity of the calling 57492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath * TextToSpeech object. 5850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param audioUri URI for the audio resource (a file or android.resource URI) 5950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param queueMode Determines what to do to requests already in the queue. 6050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param param Request parameters. 6150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 62492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath int playAudio(in IBinder callingInstance, in Uri audioUri, in int queueMode, in Bundle params); 6350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 6450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 6550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Plays silence. 6650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 67492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath * @param callingInstance a binder representing the identity of the calling 68492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath * TextToSpeech object. 6950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param duration Number of milliseconds of silence to play. 7050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param queueMode Determines what to do to requests already in the queue. 7150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param param Request parameters. 7250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 73492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath int playSilence(in IBinder callingInstance, in long duration, in int queueMode, in Bundle params); 7450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 7550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 7650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Checks whether the service is currently playing some audio. 7750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 7850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert boolean isSpeaking(); 7950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 8050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 8150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Interrupts the current utterance (if from the given app) and removes any utterances 8250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * in the queue that are from the given app. 8350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 84492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath * @param callingInstance a binder representing the identity of the calling 85492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath * TextToSpeech object. 8650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 87492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath int stop(in IBinder callingInstance); 8850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 8950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 9050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Returns the language, country and variant currently being used by the TTS engine. 9150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 9250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Can be called from multiple threads. 9350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 9450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @return A 3-element array, containing language (ISO 3-letter code), 9550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * country (ISO 3-letter code) and variant used by the engine. 9650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * The country and variant may be {@code ""}. If country is empty, then variant must 9750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * be empty too. 9850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 9950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert String[] getLanguage(); 10050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 10150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 10250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Checks whether the engine supports a given language. 10350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 10450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param lang ISO-3 language code. 10550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param country ISO-3 country code. May be empty or null. 10650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param variant Language variant. May be empty or null. 10750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @return Code indicating the support status for the locale. 10850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * One of {@link TextToSpeech#LANG_AVAILABLE}, 10950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * {@link TextToSpeech#LANG_COUNTRY_AVAILABLE}, 11050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * {@link TextToSpeech#LANG_COUNTRY_VAR_AVAILABLE}, 11150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * {@link TextToSpeech#LANG_MISSING_DATA} 11250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * {@link TextToSpeech#LANG_NOT_SUPPORTED}. 11350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 11450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert int isLanguageAvailable(in String lang, in String country, in String variant); 11550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 11650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 117748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * Returns a list of features available for a given language. Elements of the returned 118748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * string array can be passed in as keys to {@link TextToSpeech#speak} and 119748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * {@link TextToSpeech#synthesizeToFile} to select a given feature or features to be 120748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * used during synthesis. 121748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * 122748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * @param lang ISO-3 language code. 123748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * @param country ISO-3 country code. May be empty or null. 124748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * @param variant Language variant. May be empty or null. 125748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * @return An array of strings containing the set of features supported for 126748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * the supplied locale. The array of strings must not contain 127748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath * duplicates. 128748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath */ 129748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath String[] getFeaturesForLanguage(in String lang, in String country, in String variant); 130748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath 131748af66ca27d3afe2e16ccc80b147d447635292aNarayan Kamath /** 13250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Notifies the engine that it should load a speech synthesis language. 13350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 13450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param lang ISO-3 language code. 13550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param country ISO-3 country code. May be empty or null. 13650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param variant Language variant. May be empty or null. 13750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @return Code indicating the support status for the locale. 13850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * One of {@link TextToSpeech#LANG_AVAILABLE}, 13950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * {@link TextToSpeech#LANG_COUNTRY_AVAILABLE}, 14050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * {@link TextToSpeech#LANG_COUNTRY_VAR_AVAILABLE}, 14150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * {@link TextToSpeech#LANG_MISSING_DATA} 14250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * {@link TextToSpeech#LANG_NOT_SUPPORTED}. 14350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 14450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert int loadLanguage(in String lang, in String country, in String variant); 14550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 14650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 14750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Sets the callback that will be notified when playback of utterance from the 14850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * given app are completed. 14950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 15050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param callingApp Package name for the app whose utterance the callback will handle. 15150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * @param cb The callback. 15250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 153492b7f0d51f53164aa6eb974cd7ab6a7889af677Narayan Kamath void setCallback(in IBinder caller, ITextToSpeechCallback cb); 15450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 15550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert} 156