vocalstack 1.1.0__tar.gz → 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vocalstack-1.1.0 → vocalstack-1.2.0}/PKG-INFO +70 -2
- {vocalstack-1.1.0 → vocalstack-1.2.0}/README.md +69 -1
- {vocalstack-1.1.0 → vocalstack-1.2.0}/pyproject.toml +1 -1
- {vocalstack-1.1.0 → vocalstack-1.2.0}/src/vocalstack/__init__.py +1 -1
- vocalstack-1.2.0/src/vocalstack/realtime.py +1478 -0
- {vocalstack-1.1.0 → vocalstack-1.2.0}/src/vocalstack/resources.py +12 -5
- vocalstack-1.1.0/src/vocalstack/realtime.py +0 -555
- {vocalstack-1.1.0 → vocalstack-1.2.0}/.gitignore +0 -0
- {vocalstack-1.1.0 → vocalstack-1.2.0}/LICENSE +0 -0
- {vocalstack-1.1.0 → vocalstack-1.2.0}/SKILL.md +0 -0
- {vocalstack-1.1.0 → vocalstack-1.2.0}/skills/vocalstack/SKILL.md +0 -0
- {vocalstack-1.1.0 → vocalstack-1.2.0}/src/vocalstack/_http.py +0 -0
- {vocalstack-1.1.0 → vocalstack-1.2.0}/src/vocalstack/_models.py +0 -0
- {vocalstack-1.1.0 → vocalstack-1.2.0}/src/vocalstack/client.py +0 -0
- {vocalstack-1.1.0 → vocalstack-1.2.0}/src/vocalstack/errors.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: vocalstack
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: VocalStack speech API SDK (asyncio): one client grouped by resource, typed models from the API contract, realtime WebSocket streaming.
|
|
5
5
|
Project-URL: Homepage, https://vocalstack.com
|
|
6
6
|
License-Expression: MIT
|
|
@@ -112,7 +112,75 @@ async with VocalStack(api_key=key) as vs:
|
|
|
112
112
|
- `transcript.draft` frames **fully replace** the live tail; never append them.
|
|
113
113
|
- `transcript.committed` segments are immutable, gapless by `segment.seq`,
|
|
114
114
|
and carry word timings.
|
|
115
|
-
- A dropped connection ends the
|
|
115
|
+
- A dropped connection ends the realtime session (to go on, create a new one), except after a restart close (1012) or when the server it was on died: the SDK then reconnects to the same `streamUrl` and the realtime session goes on. A restart close that comes before `session.ready` is followed the same way inside `connect` (about 1, 2 and 4 s apart, three more tries at most), so it is not an error of the first connect.
|
|
116
|
+
- After a restart close (1012, a server being replaced), when the server says
|
|
117
|
+
how many bytes it took (`taken=`, said only for `input.kind` `live`), the SDK
|
|
118
|
+
sends the audio after that byte again. For this a session keeps
|
|
119
|
+
the last 30 seconds of audio sent, about 1.9 MB at 16 kHz mono.
|
|
120
|
+
`resend_buffer_s` (or `resend_buffer_bytes`) on `connect` and `publish`
|
|
121
|
+
changes the size, `0` keeps nothing, and `on_audio_lost(bytes)` is called
|
|
122
|
+
when some audio could not be sent again. A file given to `send_file` or
|
|
123
|
+
`transcribe_file` is not kept: on a live session it is read again from the
|
|
124
|
+
byte the server named; on a file session (`input.kind` `file`), where the
|
|
125
|
+
server names no byte and keeps nothing of an upload it did not finish, it is
|
|
126
|
+
sent again from its first byte. So give a path or bytes rather than a source
|
|
127
|
+
that can be read only once (a FIFO, a device: with one a reconnect ends the
|
|
128
|
+
file session with `engine_lost`). The session
|
|
129
|
+
does the reconnecting in a task of its own as soon as the close is seen, so
|
|
130
|
+
a caller that only sends audio and iterates later is carried on as well;
|
|
131
|
+
the frames read meanwhile are kept for the iterator.
|
|
132
|
+
`publish` sizes the buffer for the publisher's format, 16 kHz mono f32le
|
|
133
|
+
(64,000 bytes a second).
|
|
134
|
+
- When the session could not be carried on (the reconnect was refused for
|
|
135
|
+
good, or its tries ran out) it ends with an error. A caller that only sends
|
|
136
|
+
learns of it without iterating: `on_audio_lost` is called with the bytes
|
|
137
|
+
that were waiting for the next socket and then with the size of every
|
|
138
|
+
`send_audio` made after the end; iterating the session raises the error.
|
|
139
|
+
`send_audio` itself never raises it.
|
|
140
|
+
- A file or link session's socket URL says `refile=1` when the client can
|
|
141
|
+
start over: for a file, that it can be read and sent again; for a link, that
|
|
142
|
+
whoever collects the lines drops them when the run starts again. Only then
|
|
143
|
+
does the server, when its machine stops or its engine is lost mid-way, drop
|
|
144
|
+
the socket and transcribe again from the start on the next one; without
|
|
145
|
+
`refile` such a session ends with a retryable `engine_lost` (create a new
|
|
146
|
+
session). `transcribe_file` says it by itself for a source it can read again and
|
|
147
|
+
`transcribe_url` always does; with `connect`, pass `refile=True` when you send a file
|
|
148
|
+
you can read again with `send_file`, or collect a link's lines yourself and
|
|
149
|
+
start them over. When a run starts again the transcript starts over:
|
|
150
|
+
`seq` and `sentenceId` begin at 0 again, times are those of the new run, and
|
|
151
|
+
`on_commit` and the session's events deliver the lines again from the first.
|
|
152
|
+
`transcribe_file` and `transcribe_url` return the last run alone.
|
|
153
|
+
- The first connect follows an upgrade answered 503 with `Retry-After` (a
|
|
154
|
+
server that is stopping while another has a place): it waits that long, 30
|
|
155
|
+
seconds at most, and opens the same `streamUrl` again, three more tries at
|
|
156
|
+
most, the same tries a restart close before `session.ready` gets. A 503
|
|
157
|
+
without `Retry-After` is the connect's error, as before.
|
|
158
|
+
- `send_file` returns when `eof` is written or waits for the next socket, and
|
|
159
|
+
also when the session ended first: closed by you, ended by the server, or
|
|
160
|
+
failed. How a session ended comes once, from the iterator, which raises the
|
|
161
|
+
session's error (also a file that changed or could not be read again after a
|
|
162
|
+
restart). `send_file` raises only what reading the source raises on its first
|
|
163
|
+
pass (`OSError`: no such file), and the session is then closed. So
|
|
164
|
+
`asyncio.create_task(session.send_file(path))` beside an `async for` loop is
|
|
165
|
+
safe.
|
|
166
|
+
- Every connect of a session that keeps audio adds `resend=<ms>` to the stream
|
|
167
|
+
URL's query, the length of its buffer in milliseconds (`resend=30000` by
|
|
168
|
+
default), so the server knows this client sends again after a restart and
|
|
169
|
+
how far back; a session with the buffer set to `0` does not. With a buffer
|
|
170
|
+
under 22 seconds the server keeps the old behaviour on a restart.
|
|
171
|
+
- A reconnect the server answers with 503 "try again" is tried for up to about
|
|
172
|
+
95 seconds before the session ends with `engine_lost` (it was about 7
|
|
173
|
+
seconds: three tries). To stop sooner, `close()` the session yourself, or
|
|
174
|
+
lower `vocalstack.realtime.REFUSED_TOTAL_S` (90 by default).
|
|
175
|
+
- A 503 that carries `Retry-After` is tried again after exactly that long
|
|
176
|
+
(spread upward only, by 30% at most), not after the longer of it and the
|
|
177
|
+
session's own 1, 2, 4, 8, 15 s waits, and does not move those waits on; a
|
|
178
|
+
503 without it keeps them. The 90 seconds in all are the same.
|
|
179
|
+
- A connect that fails before the server answers raises `VocalStackError`
|
|
180
|
+
`engine_unavailable`, on the first connect too (the library's own exception
|
|
181
|
+
is its `__cause__`); a stream URL that is not one is not retryable.
|
|
182
|
+
- Cancelling the task that iterates a session while it reconnects closes the
|
|
183
|
+
session.
|
|
116
184
|
|
|
117
185
|
## Errors
|
|
118
186
|
|
|
@@ -99,7 +99,75 @@ async with VocalStack(api_key=key) as vs:
|
|
|
99
99
|
- `transcript.draft` frames **fully replace** the live tail; never append them.
|
|
100
100
|
- `transcript.committed` segments are immutable, gapless by `segment.seq`,
|
|
101
101
|
and carry word timings.
|
|
102
|
-
- A dropped connection ends the
|
|
102
|
+
- A dropped connection ends the realtime session (to go on, create a new one), except after a restart close (1012) or when the server it was on died: the SDK then reconnects to the same `streamUrl` and the realtime session goes on. A restart close that comes before `session.ready` is followed the same way inside `connect` (about 1, 2 and 4 s apart, three more tries at most), so it is not an error of the first connect.
|
|
103
|
+
- After a restart close (1012, a server being replaced), when the server says
|
|
104
|
+
how many bytes it took (`taken=`, said only for `input.kind` `live`), the SDK
|
|
105
|
+
sends the audio after that byte again. For this a session keeps
|
|
106
|
+
the last 30 seconds of audio sent, about 1.9 MB at 16 kHz mono.
|
|
107
|
+
`resend_buffer_s` (or `resend_buffer_bytes`) on `connect` and `publish`
|
|
108
|
+
changes the size, `0` keeps nothing, and `on_audio_lost(bytes)` is called
|
|
109
|
+
when some audio could not be sent again. A file given to `send_file` or
|
|
110
|
+
`transcribe_file` is not kept: on a live session it is read again from the
|
|
111
|
+
byte the server named; on a file session (`input.kind` `file`), where the
|
|
112
|
+
server names no byte and keeps nothing of an upload it did not finish, it is
|
|
113
|
+
sent again from its first byte. So give a path or bytes rather than a source
|
|
114
|
+
that can be read only once (a FIFO, a device: with one a reconnect ends the
|
|
115
|
+
file session with `engine_lost`). The session
|
|
116
|
+
does the reconnecting in a task of its own as soon as the close is seen, so
|
|
117
|
+
a caller that only sends audio and iterates later is carried on as well;
|
|
118
|
+
the frames read meanwhile are kept for the iterator.
|
|
119
|
+
`publish` sizes the buffer for the publisher's format, 16 kHz mono f32le
|
|
120
|
+
(64,000 bytes a second).
|
|
121
|
+
- When the session could not be carried on (the reconnect was refused for
|
|
122
|
+
good, or its tries ran out) it ends with an error. A caller that only sends
|
|
123
|
+
learns of it without iterating: `on_audio_lost` is called with the bytes
|
|
124
|
+
that were waiting for the next socket and then with the size of every
|
|
125
|
+
`send_audio` made after the end; iterating the session raises the error.
|
|
126
|
+
`send_audio` itself never raises it.
|
|
127
|
+
- A file or link session's socket URL says `refile=1` when the client can
|
|
128
|
+
start over: for a file, that it can be read and sent again; for a link, that
|
|
129
|
+
whoever collects the lines drops them when the run starts again. Only then
|
|
130
|
+
does the server, when its machine stops or its engine is lost mid-way, drop
|
|
131
|
+
the socket and transcribe again from the start on the next one; without
|
|
132
|
+
`refile` such a session ends with a retryable `engine_lost` (create a new
|
|
133
|
+
session). `transcribe_file` says it by itself for a source it can read again and
|
|
134
|
+
`transcribe_url` always does; with `connect`, pass `refile=True` when you send a file
|
|
135
|
+
you can read again with `send_file`, or collect a link's lines yourself and
|
|
136
|
+
start them over. When a run starts again the transcript starts over:
|
|
137
|
+
`seq` and `sentenceId` begin at 0 again, times are those of the new run, and
|
|
138
|
+
`on_commit` and the session's events deliver the lines again from the first.
|
|
139
|
+
`transcribe_file` and `transcribe_url` return the last run alone.
|
|
140
|
+
- The first connect follows an upgrade answered 503 with `Retry-After` (a
|
|
141
|
+
server that is stopping while another has a place): it waits that long, 30
|
|
142
|
+
seconds at most, and opens the same `streamUrl` again, three more tries at
|
|
143
|
+
most, the same tries a restart close before `session.ready` gets. A 503
|
|
144
|
+
without `Retry-After` is the connect's error, as before.
|
|
145
|
+
- `send_file` returns when `eof` is written or waits for the next socket, and
|
|
146
|
+
also when the session ended first: closed by you, ended by the server, or
|
|
147
|
+
failed. How a session ended comes once, from the iterator, which raises the
|
|
148
|
+
session's error (also a file that changed or could not be read again after a
|
|
149
|
+
restart). `send_file` raises only what reading the source raises on its first
|
|
150
|
+
pass (`OSError`: no such file), and the session is then closed. So
|
|
151
|
+
`asyncio.create_task(session.send_file(path))` beside an `async for` loop is
|
|
152
|
+
safe.
|
|
153
|
+
- Every connect of a session that keeps audio adds `resend=<ms>` to the stream
|
|
154
|
+
URL's query, the length of its buffer in milliseconds (`resend=30000` by
|
|
155
|
+
default), so the server knows this client sends again after a restart and
|
|
156
|
+
how far back; a session with the buffer set to `0` does not. With a buffer
|
|
157
|
+
under 22 seconds the server keeps the old behaviour on a restart.
|
|
158
|
+
- A reconnect the server answers with 503 "try again" is tried for up to about
|
|
159
|
+
95 seconds before the session ends with `engine_lost` (it was about 7
|
|
160
|
+
seconds: three tries). To stop sooner, `close()` the session yourself, or
|
|
161
|
+
lower `vocalstack.realtime.REFUSED_TOTAL_S` (90 by default).
|
|
162
|
+
- A 503 that carries `Retry-After` is tried again after exactly that long
|
|
163
|
+
(spread upward only, by 30% at most), not after the longer of it and the
|
|
164
|
+
session's own 1, 2, 4, 8, 15 s waits, and does not move those waits on; a
|
|
165
|
+
503 without it keeps them. The 90 seconds in all are the same.
|
|
166
|
+
- A connect that fails before the server answers raises `VocalStackError`
|
|
167
|
+
`engine_unavailable`, on the first connect too (the library's own exception
|
|
168
|
+
is its `__cause__`); a stream URL that is not one is not retryable.
|
|
169
|
+
- Cancelling the task that iterates a session while it reconnects closes the
|
|
170
|
+
session.
|
|
103
171
|
|
|
104
172
|
## Errors
|
|
105
173
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "vocalstack"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.2.0"
|
|
8
8
|
description = "VocalStack speech API SDK (asyncio): one client grouped by resource, typed models from the API contract, realtime WebSocket streaming."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|