Text

Answered

Text Websocket Recognition Not working

Hi , 

I am trying to use continue recognition   but after connection i am not getting second request .

Please let me know if there is any problem in my code or api has been change 

Thanks  

import websockets
import asyncio
import json
async def hello():
    async with websockets.connect(‘wss://cloud.myscript.com/api/v3.0/recognition/ws/text’) as websocket:
        data = {
          “type”:“applicationKey”,
          “applicationKey”:“XXXXXXXX"
        }
        await websocket.send(json.dumps(data))
        greeting = await websocket.recv()
        print(greeting)



        data2 = {‘textParameter’: {‘textInputMode’: ‘CURSIVE’, ‘resultDetail’: ‘CHARACTER’, ‘textProperties’: {‘textCandidateListSize’: 3, ‘wordCandidateListSize’: 3, ‘characterCandidateListSize’: 1}, ‘language’: ‘en_US’}, ‘inputUnits’: [{‘textInputType’: ‘MULTI_LINE_TEXT’, ‘components’: [{‘type’: ‘stroke’, ‘x’: [1, 2, 3], ‘y’: [1, 2, 3]}]}], ‘containerId’: ‘form1’, ‘containerType’: ‘FORM’, ‘type’: ‘start’}
        websocket.send(json.dumps(data2))
        greeting = await websocket.recv()
        print(greeting)

asyncio.get_event_loop().run_until_complete(hello())

 

 


Best Answer

Dear Mukesh Kumar,

thank you for contacting us and your question.

First, we noticed you are using the API V3 of the cloud. Please note we do not recommend you start a new development with the latter, as it is deprecated and no longer maintained. You should use the API V4 instead.

In your case, as you do not seem to be using the HMAC authentication, can you please check the Response of your "await websocket.send(json.dumps(data))"

Can you confirm it is:
{
"type":"init",
"result":"success"
}


If not, which error message do you have?

Best regards,

Olivier

1 Comment

Answer

Dear Mukesh Kumar,

thank you for contacting us and your question.

First, we noticed you are using the API V3 of the cloud. Please note we do not recommend you start a new development with the latter, as it is deprecated and no longer maintained. You should use the API V4 instead.

In your case, as you do not seem to be using the HMAC authentication, can you please check the Response of your "await websocket.send(json.dumps(data))"

Can you confirm it is:
{
"type":"init",
"result":"success"
}


If not, which error message do you have?

Best regards,

Olivier