Skip to content

[speech-to-text] websocket interface - end of transaction is uninformative #701

Closed

Description

@assaftibm

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.

Activity

  1. germanattanasio commented on May 16, 2017

    @germanattanasio
    Contributor

    I can add an onTranscriptionComplete() method. That way we will call that when the transcription is over.

  2. germanattanasio commented on May 16, 2017

    @germanattanasio
    Contributor

    Once #703 gets merged you will be able to test the new method with the SNAPSHOT release.

  3. assaftibm commented on May 17, 2017

    @assaftibm
    Author

    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.

  4. jeffpk62 commented on May 17, 2017

    @jeffpk62
    Contributor

    @germanattanasio, just adding myself so that I remember to update the API ref when the new callback is in place.

  5. germanattanasio commented on May 17, 2017

    @germanattanasio
    Contributor

    @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions