Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97cd647f authored by Przemyslaw Szczepaniak's avatar Przemyslaw Szczepaniak
Browse files

TTS API: Replace "voice id" with "voice name"

"Voice id" and "voice name" are both used to reference a voice in a
speech synthesis request. Voice id was a random integer, where
voice name is human readable string, that provides more debug
information and readability. Also, it's expected that voice name
will stay consistent, and won't change during the life of the speech
connection. Though, it may disappear.

Change-Id: I180296d413a18301cead1c8e3212de2bd0c7e32d
parent f6db763b
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -23475,7 +23475,7 @@ package android.speech.tts {
    method public android.os.Bundle getAudioParams();
    method public java.lang.String getText();
    method public java.lang.String getUtteranceId();
    method public int getVoiceId();
    method public java.lang.String getVoiceName();
    method public android.os.Bundle getVoiceParams();
    method public void writeToParcel(android.os.Parcel, int);
  }
@@ -23595,7 +23595,7 @@ package android.speech.tts {
    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_ID = "fallbackVoiceId";
    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";
@@ -23637,7 +23637,7 @@ package android.speech.tts {
    ctor public TextToSpeechService();
    method protected java.util.List<android.speech.tts.VoiceInfo> checkVoicesInfo();
    method public void forceVoicesInfoCheck();
    method public android.speech.tts.VoiceInfo getVoicesInfoWithId(int);
    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);
@@ -23660,9 +23660,9 @@ package android.speech.tts {
  public final class VoiceInfo implements android.os.Parcelable {
    method public int describeContents();
    method public android.os.Bundle getAdditionalFeatures();
    method public int getId();
    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();
@@ -23687,9 +23687,9 @@ package android.speech.tts {
    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 setId(int);
    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);
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ class EventLoggerV2 extends AbstractEventLogger {
        mRequest.getVoiceParams().size();
        mRequest.getAudioParams().size();

        return new StringBuilder(64).append("VoiceId: ").append(mRequest.getVoiceId())
        return new StringBuilder(64).append("VoiceName: ").append(mRequest.getVoiceName())
            .append(" ,VoiceParams: ").append(mRequest.getVoiceParams())
            .append(" ,SystemParams: ").append(mRequest.getAudioParams())
            .append("]").toString();
+6 −6
Original line number Diff line number Diff line
@@ -57,8 +57,8 @@ public final class RequestConfig {
         *            from {@link VoiceInfo#getParamsWithDefaults()}
         * @param value
         *            Value of the parameter. Its type can be one of: Integer, Float,
         *            Boolean, String, VoiceInfo (will be set as an Integer, result of a call to
         *            the {@link VoiceInfo#getId()}) or byte[]. It has to be of the same type
         *            Boolean, String, VoiceInfo (will be set as a String, result of a call to
         *            the {@link VoiceInfo#getName()}) or byte[]. It has to be of the same type
         *            as the default value from {@link VoiceInfo#getParamsWithDefaults()}
         *            for that parameter.
         * @throws IllegalArgumentException
@@ -75,13 +75,13 @@ public final class RequestConfig {
            Object defaultValue = mCurrentVoiceInfo.getParamsWithDefaults().get(paramName);
            if (defaultValue == null) {
                throw new IllegalArgumentException(
                        "Parameter \"" + paramName + "\" is not available in set voice with id: " +
                                mCurrentVoiceInfo.getId());
                        "Parameter \"" + paramName + "\" is not available in set voice with " +
                                "name: " + mCurrentVoiceInfo.getName());
            }

            // If it's VoiceInfo, get its id
            // If it's VoiceInfo, get its name
            if (value instanceof VoiceInfo) {
                value = ((VoiceInfo)value).getId();
                value = ((VoiceInfo)value).getName();
            }

            // Check type information
+9 −9
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ import android.speech.tts.TextToSpeechClient.UtteranceId;
 * <ul>
 *   <li>The utterance to synthesize</li>
 *   <li>The id of the utterance (String, result of {@link UtteranceId#toUniqueString()}</li>
 *   <li>The synthesis voice ID (Integer, result of {@link VoiceInfo#getId()})</li>
 *   <li>The synthesis voice name (String, result of {@link VoiceInfo#getName()})</li>
 *   <li>Voice parameters (Bundle of parameters)</li>
 *   <li>Audio parameters (Bundle of parameters)</li>
 * </ul>
@@ -23,7 +23,7 @@ public final class SynthesisRequestV2 implements Parcelable {
    private final String mUtteranceId;

    /** Voice ID. */
    private final int mVoiceId;
    private final String mVoiceName;

    /** Voice Parameters. */
    private final Bundle mVoiceParams;
@@ -39,7 +39,7 @@ public final class SynthesisRequestV2 implements Parcelable {
    public SynthesisRequestV2(Parcel in) {
        this.mText = in.readString();
        this.mUtteranceId = in.readString();
        this.mVoiceId = in.readInt();
        this.mVoiceName = in.readString();
        this.mVoiceParams = in.readBundle();
        this.mAudioParams = in.readBundle();
    }
@@ -47,7 +47,7 @@ public final class SynthesisRequestV2 implements Parcelable {
    SynthesisRequestV2(String text, String utteranceId, RequestConfig rconfig) {
        this.mText = text;
        this.mUtteranceId = utteranceId;
        this.mVoiceId = rconfig.getVoice().getId();
        this.mVoiceName = rconfig.getVoice().getName();
        this.mVoiceParams = rconfig.getVoiceParams();
        this.mAudioParams = rconfig.getAudioParams();
    }
@@ -61,7 +61,7 @@ public final class SynthesisRequestV2 implements Parcelable {
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mText);
        dest.writeString(mUtteranceId);
        dest.writeInt(mVoiceId);
        dest.writeString(mVoiceName);
        dest.writeBundle(mVoiceParams);
        dest.writeBundle(mAudioParams);
    }
@@ -83,11 +83,11 @@ public final class SynthesisRequestV2 implements Parcelable {
    }

    /**
     * @return the id of the voice to use for this synthesis request. Result of a call to
     * the {@link VoiceInfo#getId()} method.
     * @return the name of the voice to use for this synthesis request. Result of a call to
     * the {@link VoiceInfo#getName()} method.
     */
    public int getVoiceId() {
        return mVoiceId;
    public String getVoiceName() {
        return mVoiceName;
    }

    /**
+5 −5
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public final class TextToSpeechClient {
        /**
         * Maximum allowed time for a single request attempt, in milliseconds, before synthesis
         * fails (or fallback request starts, if requested using
         * {@link #FALLBACK_VOICE_ID}).
         * {@link #FALLBACK_VOICE_NAME}).
         */
        public static final String NETWORK_TIMEOUT_MS = "networkTimeoutMs";

@@ -111,13 +111,13 @@ public final class TextToSpeechClient {
        /**
         * If a voice exposes this parameter then it supports the fallback request feature.
         *
         * If it is set to a valid id of some other voice ({@link VoiceInfo#getId()}) then
         * If it is set to a valid name of some other voice ({@link VoiceInfo#getName()}) then
         * in case of request failure (due to network problems or missing data), fallback request
         * will be attempted. Request will be done using the voice referenced by this parameter.
         * If it is the case, the client will be informed by a callback to the {@link
         * RequestCallbacks#onSynthesisFallback(UtteranceId)}.
         */
        public static final String FALLBACK_VOICE_ID = "fallbackVoiceId";
        public static final String FALLBACK_VOICE_NAME = "fallbackVoiceName";

        /**
         * Audio parameter for specifying a linear multiplier to the speaking speed of the voice.
@@ -252,7 +252,7 @@ public final class TextToSpeechClient {
        /**
         * Called when requested synthesis failed and fallback synthesis is about to be attempted.
         *
         * Requires voice with available {@link TextToSpeechClient.Params#FALLBACK_VOICE_ID}
         * Requires voice with available {@link TextToSpeechClient.Params#FALLBACK_VOICE_NAME}
         * parameter, and request with this parameter enabled.
         *
         * This callback will be followed by callback to the {@link #onSynthesisStart},
@@ -260,7 +260,7 @@ public final class TextToSpeechClient {
         * fallback outcome.
         *
         * For more fallback feature reference, look at the
         * {@link TextToSpeechClient.Params#FALLBACK_VOICE_ID}.
         * {@link TextToSpeechClient.Params#FALLBACK_VOICE_NAME}.
         *
         * @param utteranceId
         *            Unique identifier of synthesized utterance.
Loading