TTS timeout connection to server: how to keep alive the connection with javascript?

Dirk Delbaere 1 Reputation point
2021-05-06T13:46:22.647+00:00

In Azure cognitive services TTS there is a timeout after +- 2 minutes when not using the speech. There is a WebSocket connection problem: "Unable to contact server. StatusCode: 1006, undefined Reason: undefined"
Is there a way to keep alive the connection with javascript (browser)?

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,615 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 53,971 Reputation points Moderator
    2021-05-07T00:30:18.53+00:00

    Hello,

    Thanks for reaching out to us. How long you want keep the connection alive? How you are dong the authentication?

    For access token, the access token should be sent to the service as the Authorization: Bearer <TOKEN> header. Each access token is valid for 10 minutes. You can get a new token at any time, however, to minimize network traffic and latency, we recommend using the same token for nine minutes.

    This is an example for HTTP short-audio scenario:

    POST /cognitiveservices/v1 HTTP/1.1
    Authorization: Bearer YOUR_ACCESS_TOKEN
    Host: westus.stt.speech.microsoft.com
    Content-type: application/ssml+xml
    Content-Length: 199
    Connection: Keep-Alive
    
    // Message body here...
    

    Regards,
    Yutong


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.