diff --git a/api/current.txt b/api/current.txt index aab29be21d0f7..9a4037c6e00e9 100644 --- a/api/current.txt +++ b/api/current.txt @@ -37797,9 +37797,9 @@ package android.speech.tts { method public abstract void onDone(java.lang.String); method public abstract deprecated void onError(java.lang.String); method public void onError(java.lang.String, int); + method public void onRangeStart(java.lang.String, int, int, int); method public abstract void onStart(java.lang.String); method public void onStop(java.lang.String, boolean); - method public void onUtteranceRangeStart(java.lang.String, int, int); } public class Voice implements android.os.Parcelable { diff --git a/api/system-current.txt b/api/system-current.txt index 5e6717cbece43..2e6ca4048d38e 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -40939,9 +40939,9 @@ package android.speech.tts { method public abstract void onDone(java.lang.String); method public abstract deprecated void onError(java.lang.String); method public void onError(java.lang.String, int); + method public void onRangeStart(java.lang.String, int, int, int); method public abstract void onStart(java.lang.String); method public void onStop(java.lang.String, boolean); - method public void onUtteranceRangeStart(java.lang.String, int, int); } public class Voice implements android.os.Parcelable { diff --git a/api/test-current.txt b/api/test-current.txt index f91bbb9a045bf..4db4710dacc37 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -37988,9 +37988,9 @@ package android.speech.tts { method public abstract void onDone(java.lang.String); method public abstract deprecated void onError(java.lang.String); method public void onError(java.lang.String, int); + method public void onRangeStart(java.lang.String, int, int, int); method public abstract void onStart(java.lang.String); method public void onStop(java.lang.String, boolean); - method public void onUtteranceRangeStart(java.lang.String, int, int); } public class Voice implements android.os.Parcelable { diff --git a/core/java/android/speech/tts/FileSynthesisCallback.java b/core/java/android/speech/tts/FileSynthesisCallback.java index ca9931a680112..3bde32b1e5f2b 100644 --- a/core/java/android/speech/tts/FileSynthesisCallback.java +++ b/core/java/android/speech/tts/FileSynthesisCallback.java @@ -309,4 +309,9 @@ class FileSynthesisCallback extends AbstractSynthesisCallback { return header; } + + @Override + public void rangeStart(int markerInFrames, int start, int end) { + mDispatcher.dispatchOnRangeStart(markerInFrames, start, end); + } } diff --git a/core/java/android/speech/tts/ITextToSpeechCallback.aidl b/core/java/android/speech/tts/ITextToSpeechCallback.aidl index edb6e482f3d06..89f2a7f21349c 100644 --- a/core/java/android/speech/tts/ITextToSpeechCallback.aidl +++ b/core/java/android/speech/tts/ITextToSpeechCallback.aidl @@ -96,6 +96,8 @@ oneway interface ITextToSpeechCallback { * @param utteranceId Unique id identifying the synthesis request. * @param start The start character index of the range in the utterance text. * @param end The end character index of the range (exclusive) in the utterance text. + * @param frame The start position in frames in the audio of the request where this range is + * spoken. */ - void onUtteranceRangeStart(String utteranceId, int start, int end); + void onRangeStart(String utteranceId, int start, int end, int frame); } diff --git a/core/java/android/speech/tts/PlaybackSynthesisCallback.java b/core/java/android/speech/tts/PlaybackSynthesisCallback.java index 9e24b09e94ad2..ee69d2cb61da3 100644 --- a/core/java/android/speech/tts/PlaybackSynthesisCallback.java +++ b/core/java/android/speech/tts/PlaybackSynthesisCallback.java @@ -272,6 +272,7 @@ class PlaybackSynthesisCallback extends AbstractSynthesisCallback { } } + @Override public void rangeStart(int markerInFrames, int start, int end) { if (mItem == null) { Log.e(TAG, "mItem is null"); diff --git a/core/java/android/speech/tts/SynthesisCallback.java b/core/java/android/speech/tts/SynthesisCallback.java index 8b74ed763c328..e535cfab3ab61 100644 --- a/core/java/android/speech/tts/SynthesisCallback.java +++ b/core/java/android/speech/tts/SynthesisCallback.java @@ -148,8 +148,8 @@ public interface SynthesisCallback { * *
Calling this method means that at the given audio frame, the given range of the input is * about to be spoken. If this method is called the client will receive a callback on the - * listener ({@link UtteranceProgressListener#onUtteranceRangeStart}) at the moment that frame - * has been reached by the playback head. + * listener ({@link UtteranceProgressListener#onRangeStart}) at the moment that frame has been + * reached by the playback head. * *
The markerInFrames is a frame index into the audio for this synthesis request, i.e. into * the concatenation of the audio bytes sent to audioAvailable for this synthesis request. The diff --git a/core/java/android/speech/tts/SynthesisPlaybackQueueItem.java b/core/java/android/speech/tts/SynthesisPlaybackQueueItem.java index 491eabc910297..f52638b5a3fca 100644 --- a/core/java/android/speech/tts/SynthesisPlaybackQueueItem.java +++ b/core/java/android/speech/tts/SynthesisPlaybackQueueItem.java @@ -224,7 +224,7 @@ final class SynthesisPlaybackQueueItem extends PlaybackQueueItem return; } // Inform the client. - getDispatcher().dispatchOnUtteranceRangeStart(marker.start, marker.end); + getDispatcher().dispatchOnRangeStart(marker.start, marker.end, marker.frames); // Listen for the next marker. // It's ok if this marker is in the past, in that case onMarkerReached will be called again. updateMarker(); diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java index 9a157b7c9b5df..763ea2ca3859e 100644 --- a/core/java/android/speech/tts/TextToSpeech.java +++ b/core/java/android/speech/tts/TextToSpeech.java @@ -2159,10 +2159,10 @@ public class TextToSpeech { } @Override - public void onUtteranceRangeStart(String utteranceId, int start, int end) { + public void onRangeStart(String utteranceId, int start, int end, int frame) { UtteranceProgressListener listener = mUtteranceProgressListener; if (listener != null) { - listener.onUtteranceRangeStart(utteranceId, start, end); + listener.onRangeStart(utteranceId, start, end, frame); } } }; diff --git a/core/java/android/speech/tts/TextToSpeechService.java b/core/java/android/speech/tts/TextToSpeechService.java index 08df64ff3b13d..c645f4057335a 100644 --- a/core/java/android/speech/tts/TextToSpeechService.java +++ b/core/java/android/speech/tts/TextToSpeechService.java @@ -668,7 +668,7 @@ public abstract class TextToSpeechService extends Service { void dispatchOnAudioAvailable(byte[] audio); - public void dispatchOnUtteranceRangeStart(int start, int end); + public void dispatchOnRangeStart(int start, int end, int frame); } /** Set of parameters affecting audio output. */ @@ -889,11 +889,11 @@ public abstract class TextToSpeechService extends Service { } @Override - public void dispatchOnUtteranceRangeStart(int start, int end) { + public void dispatchOnRangeStart(int start, int end, int frame) { final String utteranceId = getUtteranceId(); if (utteranceId != null) { - mCallbacks.dispatchOnUtteranceRangeStart( - getCallerIdentity(), utteranceId, start, end); + mCallbacks.dispatchOnRangeStart( + getCallerIdentity(), utteranceId, start, end, frame); } } @@ -1574,14 +1574,14 @@ public abstract class TextToSpeechService extends Service { } } - public void dispatchOnUtteranceRangeStart( - Object callerIdentity, String utteranceId, int start, int end) { + public void dispatchOnRangeStart( + Object callerIdentity, String utteranceId, int start, int end, int frame) { ITextToSpeechCallback cb = getCallbackFor(callerIdentity); if (cb == null) return; try { - cb.onUtteranceRangeStart(utteranceId, start, end); + cb.onRangeStart(utteranceId, start, end, frame); } catch (RemoteException e) { - Log.e(TAG, "Callback dispatchOnUtteranceRangeStart(String, int, int) failed: " + e); + Log.e(TAG, "Callback dispatchOnRangeStart(String, int, int, int) failed: " + e); } } diff --git a/core/java/android/speech/tts/UtteranceProgressListener.java b/core/java/android/speech/tts/UtteranceProgressListener.java index 0ee3769485388..e59ec080e2c02 100644 --- a/core/java/android/speech/tts/UtteranceProgressListener.java +++ b/core/java/android/speech/tts/UtteranceProgressListener.java @@ -135,8 +135,9 @@ public abstract class UtteranceProgressListener { * @param utteranceId Unique id identifying the synthesis request. * @param start The start index of the range in the utterance text. * @param end The end index of the range (exclusive) in the utterance text. + * @param frame The position in frames in the audio of the request where this range is spoken. */ - public void onUtteranceRangeStart(String utteranceId, int start, int end) {} + public void onRangeStart(String utteranceId, int start, int end, int frame) {} /** * Wraps an old deprecated OnUtteranceCompletedListener with a shiny new progress listener.