public abstract class TTSCallback extends Object implements okhttp3.Callback
Constructor and Description |
---|
TTSCallback() |
Modifier and Type | Method and Description |
---|---|
protected AudioResponse |
createAudioResponse(SpokestackSynthesisResponse response,
String requestId)
Use data in the HTTP response to create an
AudioResponse . |
abstract void |
onError(String message)
Communicates an error during synthesis.
|
void |
onFailure(okhttp3.Call call,
IOException e) |
void |
onResponse(okhttp3.Call call,
okhttp3.Response httpResponse) |
abstract void |
onSynthesisResponse(AudioResponse response)
Delivers an audio response, including the URL where synthesized speech
can be streamed.
|
public void onFailure(@NonNull okhttp3.Call call, IOException e)
onFailure
in interface okhttp3.Callback
public void onResponse(@NonNull okhttp3.Call call, okhttp3.Response httpResponse) throws IOException
onResponse
in interface okhttp3.Callback
IOException
protected AudioResponse createAudioResponse(@NonNull SpokestackSynthesisResponse response, @Nullable String requestId)
AudioResponse
.response
- The parsed response object with a valid URL.requestId
- The request ID from the response header. May be null
.AudioResponse
containing the URI where synthesized
audio is available and any additional metadata.public abstract void onError(String message)
message
- The error message to be delivered.public abstract void onSynthesisResponse(AudioResponse response)
Delivers an audio response, including the URL where synthesized speech can be streamed.
Spokestack audio URLS must be accessed within 30 seconds; after that, the stream will not be playable.
response
- An AudioResponse containing the URL from which
synthesized audio can be streamed and other relevant
metadata, including the request ID if one was supplied.Copyright © 2021. All rights reserved.