@@ -132,7 +132,7 @@ The Voice API uses a two-step flow to initiate streaming.
132132 ``` json
133133 {
134134 "streaming_url" : " wss://api.deepl.com/v3/voice/realtime/connect" ,
135- "token" : <secure access token>,
135+ "token" : <authentication token>,
136136 }
137137 ```
138138
@@ -147,7 +147,7 @@ The Voice API uses a two-step flow to initiate streaming.
147147 See the [ Request Stream] ( /api-reference/voice/request-stream ) documentation for details.
148148 </Step >
149149 <Step title = " Streaming Audio and Text (WebSocket)" >
150- Use the received URL to establish a WebSocket connection to ` wss://api.deepl.com/v3/voice/realtime/connect?token=<secure access token> ` .
150+ Use the received URL to establish a WebSocket connection to ` wss://api.deepl.com/v3/voice/realtime/connect?token=<authentication token> ` .
151151 This step handles exchanging JSON messages on the WebSocket connection:
152152 * Sending audio data
153153 * Receiving transcriptions and translations in real-time
@@ -215,6 +215,36 @@ sequenceDiagram
215215` par ` means parallel execution and ` loop ` means looped execution.
216216</Accordion >
217217
218+ ## Reconnecting
219+
220+ Network connections are inherently unreliable.
221+ Disconnections are unavoidable and must be planned for.
222+ In case your stream gets disconnected, request a new authentication token to pick up where you left off.
223+ Make a GET request ` v3/voice/realtime?token=<your last authentication token> ` .
224+ The response will look like this:
225+
226+ ``` json
227+ {
228+ "streaming_url" : " wss://api.deepl.com/v3/voice/realtime/connect" ,
229+ "token" : <new authentication token>,
230+ }
231+ ```
232+
233+ Use the received URL and token to establish a new WebSocket connection.
234+ Should another reconnection become necessary, repeat the procedure.
235+
236+ See the [ Reconnect Stream] ( /api-reference/voice/reconnect-stream ) documentation for details.
237+
238+ <Note >
239+ Always use the latest authentication token to request a new authentication token.
240+ The use of outdated tokens will invalidate your session for security reasons.
241+ </Note >
242+
243+ <Note >
244+ If you still have an active connection, requesting a reconnection token will disconnect you.
245+ </Note >
246+
247+
218248## Usage Examples
219249
220250You can find a reference usage example for python at our
@@ -230,3 +260,4 @@ to interact with the API.
230260* Recommended chunk duration: 50-250 milliseconds for low latency
231261* Audio stream speed: maximum 2x real-time
232262* Timeout: If no data is received for 30 seconds, the session will be terminated
263+ * Using any given token more than once to establish a WebSocket connection will terminate associated the session immediately for security reasons.
0 commit comments