FileDocCategorySizeDatePackage
EventLoggerV1.javaAPI DocAndroid 5.1 API2937Thu Mar 12 22:22:10 GMT 2015android.speech.tts

EventLoggerV1

public class EventLoggerV1 extends AbstractEventLogger
Writes data about a given speech synthesis request for V1 API to the event logs. The data that is logged includes the calling app, length of the utterance, speech rate / pitch, the latency, and overall time taken.

Fields Summary
private final SynthesisRequest
mRequest
Constructors Summary
EventLoggerV1(SynthesisRequest request, int callerUid, int callerPid, String serviceApp)

        super(callerUid, callerPid, serviceApp);
        mRequest = request;
    
Methods Summary
private java.lang.StringgetLocaleString()
Returns a formatted locale string from the synthesis params of the form lang-country-variant.

        StringBuilder sb = new StringBuilder(mRequest.getLanguage());
        if (!TextUtils.isEmpty(mRequest.getCountry())) {
            sb.append('-");
            sb.append(mRequest.getCountry());

            if (!TextUtils.isEmpty(mRequest.getVariant())) {
                sb.append('-");
                sb.append(mRequest.getVariant());
            }
        }

        return sb.toString();
    
private intgetUtteranceLength()

return
the length of the utterance for the given synthesis, 0 if the utterance was {@code null}.

        final String utterance = mRequest.getText();
        return utterance == null ? 0 : utterance.length();
    
protected voidlogFailure(int statusCode)

        // We don't report stopped syntheses because their overall
        // total time spent will be inaccurate (will not correlate with
        // the length of the utterance).
        if (statusCode != TextToSpeech.STOPPED) {
            EventLogTags.writeTtsSpeakFailure(mServiceApp, mCallerUid, mCallerPid,
                    getUtteranceLength(), getLocaleString(),
                    mRequest.getSpeechRate(), mRequest.getPitch());
        }
    
protected voidlogSuccess(long audioLatency, long engineLatency, long engineTotal)

        EventLogTags.writeTtsSpeakSuccess(mServiceApp, mCallerUid, mCallerPid,
                getUtteranceLength(), getLocaleString(),
                mRequest.getSpeechRate(), mRequest.getPitch(),
                engineLatency, engineTotal, audioLatency);