You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[speech-to-text] websocket interface - end of transaction is uninformative #701
JDK 1.8.0.131
java-sdk-3.8.0
speech-to-text:3.8.1-SNAPSHOT
Windows 7 64bit
Version 3.8.1 changed the way in which the server notifies the client about the end of a transaction. It looks like in this version the end of transaction is notified by a call to "onDisconnect". However, in this way the client is not informed whether the disconnection is due to a successful completion of a transaction or due to some error.
Looking at the code, it seems that onDisconnect is called only from the method onClosing in the class SpeechToTextWebSocketListener:
@Override
public void onClosing(WebSocket webSocket, int code, String reason) {
socketOpen = false;
callback.onDisconnected();
}
The arguments 'code' and 'reason' are ignored and as a result the callback is not informed of the reason for the disconnection. Looking at this with a debugger, it seems that when the transaction ends successfully the argument 'code' has the value 1000 and the argument 'reason' has the value "Transcription completed". In case of some error I assume that these arguments would have other values.
In 3.8.0 the server used to invoke the "onListening" method and this indicated that it reached the end of stream, has sent all transcripts, and is ready for another request. The onDisconnect was used in other scenarios. So it was clear whether the transaction ended gracefully or disconnected.
I think that you can either add onTranscriptionComplete() and use it only for successful endings of transactions while using onDisconnected() only for unexpected disconnection cases, or you can keep rename the existing onDisconnected() to onTranscriptionComplete() and add some parameters to indicate whether the transaction ended successfully or with some error. In any event, it will be helpful to get some error description in case of an error.
@assaftibm the onDisconnected() will always be called because we close the WebSocket when we get the final results. The user needs to know when the connection is close. I guess we should not write code thinking that onDisconnected() is something that happened due to an error.
Activity
germanattanasio commentedon May 16, 2017
I can add an
onTranscriptionComplete()method. That way we will call that when the transcription is over.germanattanasio commentedon May 16, 2017
Once #703 gets merged you will be able to test the new method with the SNAPSHOT release.
assaftibm commentedon May 17, 2017
I think that you can either add
onTranscriptionComplete()and use it only for successful endings of transactions while usingonDisconnected()only for unexpected disconnection cases, or you can keep rename the existingonDisconnected()toonTranscriptionComplete()and add some parameters to indicate whether the transaction ended successfully or with some error. In any event, it will be helpful to get some error description in case of an error.jeffpk62 commentedon May 17, 2017
@germanattanasio, just adding myself so that I remember to update the API ref when the new callback is in place.
germanattanasio commentedon May 17, 2017
@assaftibm the
onDisconnected()will always be called because we close the WebSocket when we get the final results. The user needs to know when the connection is close. I guess we should not write code thinking thatonDisconnected()is something that happened due to an error.