#According to the documents the maximum allowed duration for inactive is 180 seconds. What is the de

1 messages · Page 1 of 1 (latest)

hard prairieBOT
#
AI-generated Answer for suraj_63976

In the context of ElevenLabs' WebSockets endpoint, "inactive" refers to the period during which no data is sent through the connection. If the connection remains idle for the specified inactivity duration, it will automatically close.

To keep the connection active, you can send a single space character " " every 20 seconds (or the duration set by the inactivity_timeout parameter). Sending an empty string "" will trigger an End of Sequence (EOS) message, which closes the socket. You can adjust the inactivity_timeout parameter up to a maximum of 180 seconds to extend the allowable idle time.

queen sorrel
#

give me an example for usage of "inactivity_timeout"

hard prairieBOT
#
AI-generated Answer for suraj_63976

The term "inactive" in this context refers periods during which no data is sent to keep the WebSocket connection open. If no activity occurs within the specified duration, the connection will close automatically.

For example, the inactivity_timeout parameter can be used to set the maximum duration of inactivity before the WebSocket connection closes. Here's a simple example in Python:

import websocket

# Define the WebSocket URL
url = "wss://api.elevenlabs.io/v1/tts"

# Set the inactivity timeout to 120 seconds
params = {
    "inactivity_timeout": 120
}

# Open the WebSocket connection
ws = websocket.WebSocket()
ws.connect(url, header=params)

# Send data periodically to keep the connection alive
while True:
    ws.send(" ")  # Sending a space to keep the connection open
    time.sleep(20)  # Send every 20 seconds

In this example, the inactivity_timeout is set to 120 seconds, meaning the connection will close if no data is sent for 120 seconds. You can adjust this value up to the maximum of 180 seconds as needed.

queen sorrel
#

when the connection is closed after inactivity what is the closeCode and reason from elevenlabs end ?

hard prairieBOT
#
AI-generated Answer for suraj_63976

The provided content does not specify the exact closeCode or reason sent by ElevenLabs when a WebSocket connection is closed due to inactivity. For detailed information on this, you may need to consult the Websockets API documentation or reach out to ElevenLabs support for clarification.

queen sorrel
#

when can the websocket error ?