• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 callingApp The package name of the calling app. Used to connect requests
34      *         callbacks and to clear requests when the calling app is stopping.
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      */
speak(in String callingApp, in String text, in int queueMode, in Bundle params)39     int speak(in String callingApp, 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 callingApp The package name of the calling app. Used to connect requests
45      *         callbacks and to clear requests when the calling app is stopping.
46      * @param text The text to synthesize.
47      * @param filename The file to write the synthesized audio to.
48      * @param param Request parameters.
49      */
synthesizeToFile(in String callingApp, in String text, in String filename, in Bundle params)50     int synthesizeToFile(in String callingApp, in String text,
51         in String filename, in Bundle params);
52 
53     /**
54      * Plays an existing audio resource.
55      *
56      * @param callingApp The package name of the calling app. Used to connect requests
57      *         callbacks and to clear requests when the calling app is stopping.
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      */
playAudio(in String callingApp, in Uri audioUri, in int queueMode, in Bundle params)62     int playAudio(in String callingApp, in Uri audioUri, in int queueMode, in Bundle params);
63 
64     /**
65      * Plays silence.
66      *
67      * @param callingApp The package name of the calling app. Used to connect requests
68      *         callbacks and to clear requests when the calling app is stopping.
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      */
playSilence(in String callingApp, in long duration, in int queueMode, in Bundle params)73     int playSilence(in String callingApp, in long duration, in int queueMode, in Bundle params);
74 
75     /**
76      * Checks whether the service is currently playing some audio.
77      */
isSpeaking()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 callingApp Package name of the app whose utterances
85      *        should be interrupted and cleared.
86      */
stop(in String callingApp)87     int stop(in String callingApp);
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      */
getLanguage()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      */
isLanguageAvailable(in String lang, in String country, in String variant)114     int isLanguageAvailable(in String lang, in String country, in String variant);
115 
116     /**
117      * Notifies the engine that it should load a speech synthesis language.
118      *
119      * @param lang ISO-3 language code.
120      * @param country ISO-3 country code. May be empty or null.
121      * @param variant Language variant. May be empty or null.
122      * @return Code indicating the support status for the locale.
123      *         One of {@link TextToSpeech#LANG_AVAILABLE},
124      *         {@link TextToSpeech#LANG_COUNTRY_AVAILABLE},
125      *         {@link TextToSpeech#LANG_COUNTRY_VAR_AVAILABLE},
126      *         {@link TextToSpeech#LANG_MISSING_DATA}
127      *         {@link TextToSpeech#LANG_NOT_SUPPORTED}.
128      */
loadLanguage(in String lang, in String country, in String variant)129     int loadLanguage(in String lang, in String country, in String variant);
130 
131     /**
132      * Sets the callback that will be notified when playback of utterance from the
133      * given app are completed.
134      *
135      * @param callingApp Package name for the app whose utterance the callback will handle.
136      * @param cb The callback.
137      */
setCallback(in String callingApp, ITextToSpeechCallback cb)138     void setCallback(in String callingApp, ITextToSpeechCallback cb);
139 
140 }
141