watson-developer-cloud / java-sdk

:1st_place_medal: Java SDK to use the IBM Watson services.
http://watson-developer-cloud.github.io/java-sdk/
Apache License 2.0
593 stars 532 forks source link

[speech-to-text] Investigate the use if WebSocket #15

Closed germanattanasio closed 8 years ago

germanattanasio commented 9 years ago

HI @daniel-bolanos I was thinking we can provide support for WebSockets in the wrapper by adding an existing library and handling the authorization using the authorization service. What do you think?

We should:

daniel-bolanos commented 9 years ago

Hi @germanattanasio, I agree, I already have a working java client for the STT service, I think I pointed you to it some time ago. We can reuse that and add the token authentication part.

germanattanasio commented 9 years ago

Why don't you move that code to your github account and I will take a look at it

germanattanasio commented 9 years ago

@daniel-bolanos can you help me with this: https://gist.github.com/germanattanasio/275c6abab90b042f4925 I'm trying to write an example with websockets.

You will need to clone this repo and create a file with that content

rathnaum commented 9 years ago

I have trouble connecting to Watson STT service using Websockets. I tried the same example given here for websockets. Do I need SSL or any certificate to be installed before connecting?

birkanu commented 8 years ago

I am having the same problem. Each time I try connecting to the service, my connection is closed. I am pretty sure I am using the correct API endpoints to get a token and then connect to the WebSocket server. Can there be an SSL issue?

daniel-bolanos commented 8 years ago

Hello @birkanu and @rathnaum , what is the error message that you get? Can you please try the Python or Ruby WebSocket clients while we solve this issue?

https://github.com/watson-developer-cloud/speech-to-text-websockets-python https://github.com/watson-developer-cloud/speech-to-text-websockets-ruby

thank you

birkanu commented 8 years ago

Here is what's printed out on the console:

Transcript using WebSockets
Closed connection.
CONNECTED: false
HERE: false
java.nio.channels.NotYetConnectedException
    at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:481)
    at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:458)
    at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:176)
    at samples.IBMSpeechRecognitionSample2.transcriptUsingWebSockets(IBMSpeechRecognitionSample2.java:188)
    at samples.IBMSpeechRecognitionSample2.main(IBMSpeechRecognitionSample2.java:86)
rathnaum commented 8 years ago

I got the exact same error message too. Cheers.

birkanu commented 8 years ago

@daniel-bolanos and @germanattanasio, I am not sure if this will help you, but I tried opening a WebSocket connection using Tyrus which is a reference implementation of websockets in Java. This time I got a Handshake Error, caused by the following reason: Response code was not 101: 400. There must be something wrong with the SSL Configuration.

birkanu commented 8 years ago

@daniel-bolanos and @germanattanasio, any updates on this?

germanattanasio commented 8 years ago

I'm working in other things now, will probably have some time to look at this on Wednesday.

If you have some time please look at the documentation and the ruby and python samples in this organization. You can learn how to use the websocket api and fix the sample by the time I start working on this again.

germanattanasio commented 8 years ago

We decided to use https://github.com/TakahikoKawasaki/nv-websocket-client. It's only 60kb and works in Android.

germanattanasio commented 8 years ago

Fixed in https://github.com/watson-developer-cloud/java-sdk/releases/tag/java-sdk-2.6.0

rathnaum commented 8 years ago

Is there any C# .Net SDK for speech to text service?

daniel-bolanos commented 8 years ago

Hello @rathnaum , there is not yet, but all you need is a websockets library for .NET. Please take a look at this post: https://developer.ibm.com/answers/questions/211086/calling-the-speech-to-text-service-from-a-c-net-ap.html