WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a3e20f5

Browse files
committed
type(scope): subject
1 parent 56ca30b commit a3e20f5

File tree

4 files changed

+79
-3
lines changed

4 files changed

+79
-3
lines changed

api-reference/openapi.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,46 @@ paths:
20122012
$ref: '#/components/responses/ServiceUnavailable'
20132013
security:
20142014
- auth_header: []
2015+
get:
2016+
tags:
2017+
- VoiceAPI
2018+
summary: Request Reconnection
2019+
operationId: requestReconnection
2020+
parameters:
2021+
- name: token
2022+
in: query
2023+
required: true
2024+
description: The latest ephemeral token obtained for the stream.
2025+
schema:
2026+
type: string
2027+
example: 'VGhpcyBpcyBhIGZha2UgdG9rZW4K'
2028+
responses:
2029+
200:
2030+
description: Successfully obtained streaming URL and reconnection token.
2031+
content:
2032+
application/json:
2033+
schema:
2034+
$ref: '#/components/schemas/VoiceStreamingResponse'
2035+
example:
2036+
streaming_url: 'wss://api.deepl.com/v3/voice/realtime/connect'
2037+
token: 'VGhpcyBpcyBhIGZha2UgdG9rZW4K'
2038+
session_id: '4f911080-cfe2-41d4-8269-0e6ec15a0354'
2039+
400:
2040+
$ref: '#/components/responses/BadRequest'
2041+
401:
2042+
$ref: '#/components/responses/Unauthorized'
2043+
403:
2044+
$ref: '#/components/responses/Forbidden'
2045+
429:
2046+
$ref: '#/components/responses/TooManyRequests'
2047+
456:
2048+
$ref: '#/components/responses/QuotaExceeded'
2049+
500:
2050+
$ref: '#/components/responses/InternalServerError'
2051+
503:
2052+
$ref: '#/components/responses/ServiceUnavailable'
2053+
security:
2054+
- auth_header: []
20152055
components:
20162056
parameters:
20172057
DocumentID:

api-reference/voice.mdx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

220250
You 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.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
openapi: get /v3/voice/realtime
3+
title: "Reconnect Stream"
4+
---

docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@
214214
"pages": [
215215
"api-reference/voice",
216216
"api-reference/voice/request-stream",
217-
"api-reference/voice/websocket-streaming"
217+
"api-reference/voice/websocket-streaming",
218+
"api-reference/voice/reconnect-stream"
218219
]
219220
}
220221
]

0 commit comments

Comments
 (0)