Debian Codegraph @

core/java/android/speech/tts/ITextToSpeechCallback.aidl

raw
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 package android.speech.tts;
17
18 /**
19 * Interface for callbacks from TextToSpeechService
20 *
21 * {@hide}
22 */
23 oneway interface ITextToSpeechCallback {
24 /**
25 * Tells the client that the synthesis has started playing.
26 *
27 * @param utteranceId Unique id identifying the synthesis request.
28 */
29 void onStart(String utteranceId);
30
31 /**
32 * Tells the client that the synthesis has finished playing.
33 *
34 * @param utteranceId Unique id identifying the synthesis request.
35 */
36 void onSuccess(String utteranceId);
37
38 /**
39 * Tells the client that the synthesis was stopped.
40 *
41 * @param utteranceId Unique id identifying the synthesis request.
42 */
43 void onStop(String utteranceId, boolean isStarted);
44
45 /**
46 * Tells the client that the synthesis has failed.
47 *
48 * @param utteranceId Unique id identifying the synthesis request.
49 * @param errorCode One of the values from
50 * {@link android.speech.tts.v2.TextToSpeech}.
51 */
52 void onError(String utteranceId, int errorCode);
53
54 /**
55 * Tells the client that the TTS engine has started synthesizing the audio for a request.
56 *
57 * <p>
58 * This doesn't mean the synthesis request has already started playing (for example when there
59 * are synthesis requests ahead of it in the queue), but after receiving this callback you can
60 * expect onAudioAvailable to be called.
61 * </p>
62 *
63 * @param utteranceId Unique id identifying the synthesis request.
64 * @param sampleRateInHz Sample rate in HZ of the generated audio.
65 * @param audioFormat The audio format of the generated audio in the {@link #onAudioAvailable}
66 * call. Should be one of {@link android.media.AudioFormat.ENCODING_PCM_8BIT},
67 * {@link android.media.AudioFormat.ENCODING_PCM_16BIT} or
68 * {@link android.media.AudioFormat.ENCODING_PCM_FLOAT}.
69 * @param channelCount The number of channels.
70 */
71 void onBeginSynthesis(String utteranceId, int sampleRateInHz, int audioFormat, int channelCount);
72
73 /**
74 * Tells the client about a chunk of the synthesized audio.
75 *
76 * <p>
77 * Called when a chunk of the synthesized audio is ready. This may be called more than once for
78 * every synthesis request, thereby streaming the audio to the client.
79 * </p>
80 *
81 * @param utteranceId Unique id identifying the synthesis request.
82 * @param audio The raw audio bytes. Its format is specified by the {@link #onStartAudio}
83 * callback.
84 */
85 void onAudioAvailable(String utteranceId, in byte[] audio);
86
87 /**
88 * Tells the client that the engine is about to speak the specified range of the utterance.
89 *
90 * <p>
91 * Only called if the engine supplies timing information by calling
92 * {@link SynthesisCallback#rangeStart(int, int, int)} and only when the request is played back
93 * by the service, not when using {@link android.speech.tts.TextToSpeech#synthesizeToFile}.
94 * </p>
95 *
96 * @param utteranceId Unique id identifying the synthesis request.
97 * @param start The start character index of the range in the utterance text.
98 * @param end The end character index of the range (exclusive) in the utterance text.
99 * @param frame The start position in frames in the audio of the request where this range is
100 * spoken.
101 */
102 void onRangeStart(String utteranceId, int start, int end, int frame);
103 }