Merge "Hide new TTS API for the lmp-preview. DO NOT MERGE" into lmp-preview-dev

This commit is contained in:
Przemyslaw Szczepaniak
2014-06-12 10:36:03 +00:00
committed by Android (Google) Code Review
9 changed files with 21 additions and 199 deletions

View File

@@ -26094,52 +26094,11 @@ package android.speech {
package android.speech.tts {
public final class RequestConfig {
method public android.os.Bundle getAudioParams();
method public android.speech.tts.VoiceInfo getVoice();
method public android.os.Bundle getVoiceParams();
}
public static final class RequestConfig.Builder {
method public android.speech.tts.RequestConfig build();
method public static android.speech.tts.RequestConfig.Builder newBuilder();
method public static android.speech.tts.RequestConfig.Builder newBuilder(android.speech.tts.RequestConfig);
method public android.speech.tts.RequestConfig.Builder setAudioParam(java.lang.String, java.lang.Object);
method public void setAudioParamPan(float);
method public void setAudioParamStream(int);
method public void setAudioParamVolume(float);
method public android.speech.tts.RequestConfig.Builder setVoice(android.speech.tts.VoiceInfo);
method public android.speech.tts.RequestConfig.Builder setVoiceParam(java.lang.String, java.lang.Object);
}
public final class RequestConfigHelper {
method public static android.speech.tts.RequestConfig highestQuality(android.speech.tts.TextToSpeechClient.EngineStatus, boolean, android.speech.tts.RequestConfigHelper.VoiceScorer);
method public static android.speech.tts.RequestConfig highestQuality(android.speech.tts.TextToSpeechClient.EngineStatus, boolean);
}
public static final class RequestConfigHelper.ExactLocaleMatcher implements android.speech.tts.RequestConfigHelper.VoiceScorer {
ctor public RequestConfigHelper.ExactLocaleMatcher(java.util.Locale);
method public int scoreVoice(android.speech.tts.VoiceInfo);
}
public static final class RequestConfigHelper.LanguageMatcher implements android.speech.tts.RequestConfigHelper.VoiceScorer {
ctor public RequestConfigHelper.LanguageMatcher(java.util.Locale);
method public int scoreVoice(android.speech.tts.VoiceInfo);
}
public static abstract interface RequestConfigHelper.VoiceScorer {
method public abstract int scoreVoice(android.speech.tts.VoiceInfo);
}
public abstract interface SynthesisCallback {
method public abstract int audioAvailable(byte[], int, int);
method public abstract int done();
method public abstract void error();
method public abstract void error(int);
method public abstract int fallback();
method public abstract int getMaxBufferSize();
method public abstract boolean hasFinished();
method public abstract boolean hasStarted();
method public abstract int start(int, int, int);
}
@@ -26155,18 +26114,7 @@ package android.speech.tts {
method public java.lang.String getVariant();
}
public final class SynthesisRequestV2 implements android.os.Parcelable {
ctor public SynthesisRequestV2(java.lang.String, java.lang.String, java.lang.String, android.os.Bundle, android.os.Bundle);
method public int describeContents();
method public android.os.Bundle getAudioParams();
method public java.lang.String getText();
method public java.lang.String getUtteranceId();
method public java.lang.String getVoiceName();
method public android.os.Bundle getVoiceParams();
method public void writeToParcel(android.os.Parcel, int);
}
public deprecated class TextToSpeech {
public class TextToSpeech {
ctor public TextToSpeech(android.content.Context, android.speech.tts.TextToSpeech.OnInitListener);
ctor public TextToSpeech(android.content.Context, android.speech.tts.TextToSpeech.OnInitListener, java.lang.String);
method public int addEarcon(java.lang.String, java.lang.String, int);
@@ -26251,79 +26199,8 @@ package android.speech.tts {
method public abstract void onUtteranceCompleted(java.lang.String);
}
public class TextToSpeechClient {
ctor public TextToSpeechClient(android.content.Context, java.lang.String, boolean, android.speech.tts.TextToSpeechClient.RequestCallbacks, android.speech.tts.TextToSpeechClient.ConnectionCallbacks);
ctor public TextToSpeechClient(android.content.Context, android.speech.tts.TextToSpeechClient.RequestCallbacks, android.speech.tts.TextToSpeechClient.ConnectionCallbacks);
method public void connect();
method public void disconnect();
method public android.speech.tts.TextToSpeechClient.EngineStatus getEngineStatus();
method public boolean isConnected();
method public void queueAudio(android.net.Uri, android.speech.tts.TextToSpeechClient.UtteranceId, android.speech.tts.RequestConfig, android.speech.tts.TextToSpeechClient.RequestCallbacks);
method public void queueSilence(long, android.speech.tts.TextToSpeechClient.UtteranceId, android.speech.tts.TextToSpeechClient.RequestCallbacks);
method public void queueSpeak(java.lang.String, android.speech.tts.TextToSpeechClient.UtteranceId, android.speech.tts.RequestConfig, android.speech.tts.TextToSpeechClient.RequestCallbacks);
method public void queueSynthesizeToFile(java.lang.String, android.speech.tts.TextToSpeechClient.UtteranceId, java.io.File, android.speech.tts.RequestConfig, android.speech.tts.TextToSpeechClient.RequestCallbacks);
method public void stop();
}
public static abstract interface TextToSpeechClient.ConnectionCallbacks {
method public abstract void onConnectionFailure();
method public abstract void onConnectionSuccess();
method public abstract void onEngineStatusChange(android.speech.tts.TextToSpeechClient.EngineStatus);
method public abstract void onServiceDisconnected();
}
public static final class TextToSpeechClient.EngineStatus {
method public java.lang.String getEnginePackage();
method public java.util.List<android.speech.tts.VoiceInfo> getVoices();
}
public static final class TextToSpeechClient.Params {
field public static final java.lang.String AUDIO_PARAM_PAN = "pan";
field public static final java.lang.String AUDIO_PARAM_STREAM = "streamType";
field public static final java.lang.String AUDIO_PARAM_VOLUME = "volume";
field public static final java.lang.String FALLBACK_VOICE_NAME = "fallbackVoiceName";
field public static final java.lang.String NETWORK_RETRIES_COUNT = "networkRetriesCount";
field public static final java.lang.String NETWORK_TIMEOUT_MS = "networkTimeoutMs";
field public static final java.lang.String SPEECH_PITCH = "speechPitch";
field public static final java.lang.String SPEECH_SPEED = "speechSpeed";
field public static final java.lang.String TRACK_SUBUTTERANCE_PROGRESS = "trackSubutteranceProgress";
}
public static abstract class TextToSpeechClient.RequestCallbacks {
ctor public TextToSpeechClient.RequestCallbacks();
method public void onSynthesisFailure(android.speech.tts.TextToSpeechClient.UtteranceId, int);
method public void onSynthesisFallback(android.speech.tts.TextToSpeechClient.UtteranceId);
method public void onSynthesisProgress(android.speech.tts.TextToSpeechClient.UtteranceId, int, int);
method public void onSynthesisStart(android.speech.tts.TextToSpeechClient.UtteranceId);
method public void onSynthesisStop(android.speech.tts.TextToSpeechClient.UtteranceId);
method public void onSynthesisSuccess(android.speech.tts.TextToSpeechClient.UtteranceId);
}
public static final class TextToSpeechClient.Status {
field public static final int ERROR_DOWNLOADING_ADDITIONAL_DATA = 17; // 0x11
field public static final int ERROR_INVALID_REQUEST = 15; // 0xf
field public static final int ERROR_NETWORK = 13; // 0xd
field public static final int ERROR_NETWORK_TIMEOUT = 14; // 0xe
field public static final int ERROR_NON_UNIQUE_UTTERANCE_ID = 16; // 0x10
field public static final int ERROR_OUTPUT = 12; // 0xc
field public static final int ERROR_SERVICE = 11; // 0xb
field public static final int ERROR_SYNTHESIS = 10; // 0xa
field public static final int ERROR_UNKNOWN = -1; // 0xffffffff
field public static final int STOPPED = 100; // 0x64
field public static final int SUCCESS = 0; // 0x0
}
public static class TextToSpeechClient.UtteranceId {
ctor public TextToSpeechClient.UtteranceId();
method public final java.lang.String toUniqueString();
}
public abstract class TextToSpeechService extends android.app.Service {
ctor public TextToSpeechService();
method protected java.util.List<android.speech.tts.VoiceInfo> checkVoicesInfo();
method public void forceVoicesInfoCheck();
method public android.speech.tts.VoiceInfo getVoicesInfoWithName(java.lang.String);
method protected boolean implementsV2API();
method public android.os.IBinder onBind(android.content.Intent);
method protected java.util.Set<java.lang.String> onGetFeaturesForLanguage(java.lang.String, java.lang.String, java.lang.String);
method protected abstract java.lang.String[] onGetLanguage();
@@ -26331,8 +26208,6 @@ package android.speech.tts {
method protected abstract int onLoadLanguage(java.lang.String, java.lang.String, java.lang.String);
method protected abstract void onStop();
method protected abstract void onSynthesizeText(android.speech.tts.SynthesisRequest, android.speech.tts.SynthesisCallback);
method protected void onSynthesizeTextV2(android.speech.tts.SynthesisRequestV2, android.speech.tts.VoiceInfo, android.speech.tts.SynthesisCallback);
method protected void onVoicesInfoChange();
}
public abstract class UtteranceProgressListener {
@@ -26342,44 +26217,6 @@ package android.speech.tts {
method public abstract void onStart(java.lang.String);
}
public final class VoiceInfo implements android.os.Parcelable {
method public int describeContents();
method public android.os.Bundle getAdditionalFeatures();
method public int getLatency();
method public java.util.Locale getLocale();
method public java.lang.String getName();
method public android.os.Bundle getParamsWithDefaults();
method public int getQuality();
method public boolean getRequiresNetworkConnection();
method public void writeToParcel(android.os.Parcel, int);
field public static final java.lang.String FEATURE_MAY_AUTOINSTALL = "mayAutoInstall";
field public static final java.lang.String FEATURE_SPEAKER_GENDER = "speakerGender";
field public static final java.lang.String FEATURE_WORDS_PER_MINUTE = "wordsPerMinute";
field public static final int LATENCY_HIGH = 400; // 0x190
field public static final int LATENCY_LOW = 200; // 0xc8
field public static final int LATENCY_NORMAL = 300; // 0x12c
field public static final int LATENCY_VERY_HIGH = 500; // 0x1f4
field public static final int LATENCY_VERY_LOW = 100; // 0x64
field public static final int QUALITY_HIGH = 400; // 0x190
field public static final int QUALITY_LOW = 200; // 0xc8
field public static final int QUALITY_NORMAL = 300; // 0x12c
field public static final int QUALITY_VERY_HIGH = 500; // 0x1f4
field public static final int QUALITY_VERY_LOW = 100; // 0x64
}
public static final class VoiceInfo.Builder {
ctor public VoiceInfo.Builder();
ctor public VoiceInfo.Builder(android.speech.tts.VoiceInfo);
method public android.speech.tts.VoiceInfo build();
method public android.speech.tts.VoiceInfo.Builder setAdditionalFeatures(android.os.Bundle);
method public android.speech.tts.VoiceInfo.Builder setLatency(int);
method public android.speech.tts.VoiceInfo.Builder setLocale(java.util.Locale);
method public android.speech.tts.VoiceInfo.Builder setName(java.lang.String);
method public android.speech.tts.VoiceInfo.Builder setParamsWithDefaults(android.os.Bundle);
method public android.speech.tts.VoiceInfo.Builder setQuality(int);
method public android.speech.tts.VoiceInfo.Builder setRequiresNetworkConnection(boolean);
}
}
package android.system {

View File

@@ -8,6 +8,7 @@ import android.os.Bundle;
*
* This class is immutable, and can only be constructed using
* {@link RequestConfig.Builder}.
* @hide
*/
public final class RequestConfig {

View File

@@ -7,6 +7,7 @@ import java.util.Locale;
/**
* Set of common heuristics for selecting {@link VoiceInfo} from
* {@link TextToSpeechClient#getEngineStatus()} output.
* @hide
*/
public final class RequestConfigHelper {
private RequestConfigHelper() {}

View File

@@ -43,16 +43,13 @@ public interface SynthesisCallback {
* request.
*
* This method should only be called on the synthesis thread,
* while in {@link TextToSpeechService#onSynthesizeText} or
* {@link TextToSpeechService#onSynthesizeTextV2}.
* while in {@link TextToSpeechService#onSynthesizeText}.
*
* @param sampleRateInHz Sample rate in HZ of the generated audio.
* @param audioFormat Audio format of the generated audio. Must be one of
* the ENCODING_ constants defined in {@link android.media.AudioFormat}.
* @param channelCount The number of channels. Must be {@code 1} or {@code 2}.
* @return {@link TextToSpeech#SUCCESS}, {@link TextToSpeech#ERROR}.
* {@link TextToSpeechClient.Status#STOPPED} is also possible if called in context of
* {@link TextToSpeechService#onSynthesizeTextV2}.
*/
public int start(int sampleRateInHz, int audioFormat, int channelCount);
@@ -60,8 +57,7 @@ public interface SynthesisCallback {
* The service should call this method when synthesized audio is ready for consumption.
*
* This method should only be called on the synthesis thread,
* while in {@link TextToSpeechService#onSynthesizeText} or
* {@link TextToSpeechService#onSynthesizeTextV2}.
* while in {@link TextToSpeechService#onSynthesizeText}.
*
* @param buffer The generated audio data. This method will not hold on to {@code buffer},
* so the caller is free to modify it after this method returns.
@@ -69,8 +65,6 @@ public interface SynthesisCallback {
* @param length The number of bytes of audio data in {@code buffer}. This must be
* less than or equal to the return value of {@link #getMaxBufferSize}.
* @return {@link TextToSpeech#SUCCESS} or {@link TextToSpeech#ERROR}.
* {@link TextToSpeechClient.Status#STOPPED} is also possible if called in context of
* {@link TextToSpeechService#onSynthesizeTextV2}.
*/
public int audioAvailable(byte[] buffer, int offset, int length);
@@ -79,14 +73,11 @@ public interface SynthesisCallback {
* been passed to {@link #audioAvailable}.
*
* This method should only be called on the synthesis thread,
* while in {@link TextToSpeechService#onSynthesizeText} or
* {@link TextToSpeechService#onSynthesizeTextV2}.
* while in {@link TextToSpeechService#onSynthesizeText}.
*
* This method has to be called if {@link #start} and/or {@link #error} was called.
*
* @return {@link TextToSpeech#SUCCESS} or {@link TextToSpeech#ERROR}.
* {@link TextToSpeechClient.Status#STOPPED} is also possible if called in context of
* {@link TextToSpeechService#onSynthesizeTextV2}.
*/
public int done();
@@ -108,6 +99,7 @@ public interface SynthesisCallback {
*
* @param errorCode Error code to pass to the client. One of the ERROR_ values from
* {@link TextToSpeechClient.Status}
* @hide
*/
public void error(int errorCode);
@@ -128,6 +120,7 @@ public interface SynthesisCallback {
* @return {@link TextToSpeech#SUCCESS}, {@link TextToSpeech#ERROR} if client already
* called {@link #start(int, int, int)}, {@link TextToSpeechClient.Status#STOPPED}
* if stop was requested.
* @hide
*/
public int fallback();
@@ -139,6 +132,7 @@ public interface SynthesisCallback {
* {@link TextToSpeechService#onSynthesizeTextV2}.
*
* Useful for checking if a fallback from network request is possible.
* @hide
*/
public boolean hasStarted();
@@ -150,6 +144,7 @@ public interface SynthesisCallback {
* {@link TextToSpeechService#onSynthesizeTextV2}.
*
* Useful for checking if a fallback from network request is possible.
* @hide
*/
public boolean hasFinished();
}

View File

@@ -14,6 +14,7 @@ import android.speech.tts.TextToSpeechClient.UtteranceId;
* <li>Voice parameters (Bundle of parameters)</li>
* <li>Audio parameters (Bundle of parameters)</li>
* </ul>
* @hide
*/
public final class SynthesisRequestV2 implements Parcelable {
/** Synthesis utterance. */

View File

@@ -53,10 +53,7 @@ import java.util.Set;
* notified of the completion of the initialization.<br>
* When you are done using the TextToSpeech instance, call the {@link #shutdown()} method
* to release the native resources used by the TextToSpeech engine.
*
* @deprecated Use {@link TextToSpeechClient} instead
*/
@Deprecated
public class TextToSpeech {
private static final String TAG = "TextToSpeech";

View File

@@ -71,6 +71,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* In the rare case of a change to the set of available voices, the service will call to the
* {@link ConnectionCallbacks#onEngineStatusChange} with new set of available voices as argument.
* In response, the client HAVE to recreate all {@link RequestConfig} instances in use.
* @hide
*/
public class TextToSpeechClient {
private static final String TAG = TextToSpeechClient.class.getSimpleName();

View File

@@ -74,26 +74,6 @@ import java.util.Set;
*
* {@link #onGetLanguage} is not required as of JELLYBEAN_MR2 (API 18) and later, it is only
* called on earlier versions of Android.
* <p>
* In order to fully support the V2 API ({@link TextToSpeechClient}),
* these methods must be implemented:
* <ul>
* <li>{@link #onSynthesizeTextV2}</li>
* <li>{@link #checkVoicesInfo}</li>
* <li>{@link #onVoicesInfoChange}</li>
* <li>{@link #implementsV2API}</li>
* </ul>
* In addition {@link #implementsV2API} has to return true.
* <p>
* If the service does not implement these methods and {@link #implementsV2API} returns false,
* then the V2 API will be provided by converting V2 requests ({@link #onSynthesizeTextV2})
* to V1 requests ({@link #onSynthesizeText}). On service setup, all of the available device
* locales will be fed to {@link #onIsLanguageAvailable} to check if they are supported.
* If they are, embedded and/or network voices will be created depending on the result of
* {@link #onGetFeaturesForLanguage}.
* <p>
* Note that a V2 service will still receive requests from V1 clients and has to implement all
* of the V1 API methods.
*/
public abstract class TextToSpeechService extends Service {
@@ -245,6 +225,7 @@ public abstract class TextToSpeechService extends Service {
* The result of this method will be saved and served to all TTS clients. If a TTS service wants
* to update the set of available voices, it should call the {@link #forceVoicesInfoCheck()}
* method.
* @hide
*/
protected List<VoiceInfo> checkVoicesInfo() {
if (implementsV2API()) {
@@ -312,6 +293,7 @@ public abstract class TextToSpeechService extends Service {
* Tells the synthesis thread that it should reload voice data.
* There's a high probability that the underlying set of available voice data has changed.
* Called only on the synthesis thread.
* @hide
*/
protected void onVoicesInfoChange() {
@@ -326,6 +308,7 @@ public abstract class TextToSpeechService extends Service {
* @param request The synthesis request.
* @param callback The callback the the engine must use to make data
* available for playback or for writing to a file.
* @hide
*/
protected void onSynthesizeTextV2(SynthesisRequestV2 request,
VoiceInfo selectedVoice,
@@ -367,6 +350,7 @@ public abstract class TextToSpeechService extends Service {
/**
* If true, this service implements proper V2 TTS API service. If it's false,
* V2 API will be provided through adapter.
* @hide
*/
protected boolean implementsV2API() {
return false;
@@ -405,6 +389,9 @@ public abstract class TextToSpeechService extends Service {
}
}
/**
* @hide
*/
public VoiceInfo getVoicesInfoWithName(String name) {
synchronized (mVoicesInfoLock) {
if (mVoicesInfoLookup != null) {
@@ -424,6 +411,7 @@ public abstract class TextToSpeechService extends Service {
* Use this method only if you know that set of available languages changed.
*
* Can be called on multiple threads.
* @hide
*/
public void forceVoicesInfoCheck() {
synchronized (mVoicesInfoLock) {

View File

@@ -16,6 +16,7 @@ import java.util.Locale;
* callback. The name can be used to reference a VoiceInfo in an instance of {@link RequestConfig};
* the {@link TextToSpeechClient.Params#FALLBACK_VOICE_NAME} voice parameter is an example of this.
* It is recommended that the voice name never change during the TTS service lifetime.
* @hide
*/
public final class VoiceInfo implements Parcelable {
/** Very low, but still intelligible quality of speech synthesis */