vocalstack 1.0.0a0__py3-none-any.whl
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/SKILL.md +235 -0
- vocalstack/__init__.py +63 -0
- vocalstack/_http.py +157 -0
- vocalstack/_models.py +1745 -0
- vocalstack/client.py +107 -0
- vocalstack/errors.py +83 -0
- vocalstack/realtime.py +411 -0
- vocalstack/resources.py +835 -0
- vocalstack-1.0.0a0.dist-info/METADATA +117 -0
- vocalstack-1.0.0a0.dist-info/RECORD +11 -0
- vocalstack-1.0.0a0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: vocalstack
|
|
3
|
+
Version: 1.0.0a0
|
|
4
|
+
Summary: VocalStack speech API SDK (asyncio): one client grouped by resource, typed models from the API contract, realtime WebSocket streaming.
|
|
5
|
+
Project-URL: Homepage, https://vocalstack.com
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: httpx>=0.27
|
|
9
|
+
Requires-Dist: pydantic>=2.7
|
|
10
|
+
Requires-Dist: websockets>=13
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# vocalstack
|
|
14
|
+
|
|
15
|
+
The VocalStack speech API for Python (3.10 or newer, asyncio): one client,
|
|
16
|
+
`VocalStack`, with one group per resource. Requests go through `httpx`; answers
|
|
17
|
+
are pydantic models generated from the API's one OpenAPI document
|
|
18
|
+
(`/v1/openapi.json`), with snake_case attributes.
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import asyncio, os
|
|
22
|
+
from vocalstack import VocalStack
|
|
23
|
+
|
|
24
|
+
async def main():
|
|
25
|
+
async with VocalStack(api_key=os.environ["VOCALSTACK_API_KEY"]) as vs: # base_url defaults to https://api.vocalstack.com
|
|
26
|
+
tx = await vs.transcriptions.create(url="https://example.com/talk.mp3") # or file="talk.mp3"
|
|
27
|
+
job = await vs.jobs.wait(tx.job.recording_id) # done | failed | cropping
|
|
28
|
+
snap = await vs.recordings.transcript(job.recording_id)
|
|
29
|
+
print(" ".join(s.text for s in snap.sentences))
|
|
30
|
+
open("talk.srt", "wb").write(await vs.recordings.export(job.recording_id, "srt"))
|
|
31
|
+
|
|
32
|
+
asyncio.run(main())
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
<!-- sdk-docs: generated by `make sdk-docs` from the guides; edit those, not this -->
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
Not on PyPI yet. The API serves its own builds to every account: [https://api.vocalstack.com/docs/guides/quickstart.md](https://api.vocalstack.com/docs/guides/quickstart.md) has the install command for the current build (it sends your API key to that host only).
|
|
40
|
+
|
|
41
|
+
## Guides
|
|
42
|
+
|
|
43
|
+
- [Quickstart](https://github.com/vocalstack/python-sdk/blob/main/docs/quickstart.md): An API key, the SDK, and your first transcript in a dozen lines.
|
|
44
|
+
- [Transcribe a file](https://github.com/vocalstack/python-sdk/blob/main/docs/transcribe-a-file.md): Upload a file, wait for its job, read the transcript and export it. Asynchronous; nothing to keep open.
|
|
45
|
+
- [Transcribe a link](https://github.com/vocalstack/python-sdk/blob/main/docs/transcribe-a-link.md): The server fetches a public URL or a YouTube video, then transcribes it like a file. Asynchronous, with a fetch phase first.
|
|
46
|
+
- [Stream a microphone](https://github.com/vocalstack/python-sdk/blob/main/docs/stream-a-microphone.md): Live audio in, transcript events out, over one WebSocket. Drafts replace the live tail; commits append.
|
|
47
|
+
- [Stream a file at full speed](https://github.com/vocalstack/python-sdk/blob/main/docs/stream-a-file.md): Send a file's bytes through a realtime session and read the transcript as fast as the server makes it. Nothing is stored.
|
|
48
|
+
- [Go live](https://github.com/vocalstack/python-sdk/blob/main/docs/go-live.md): Publish live audio to a stored transcription, and put it on a broadcast link listeners open. Control is HTTP; audio is one WebSocket.
|
|
49
|
+
- [Listen](https://github.com/vocalstack/python-sdk/blob/main/docs/listen.md): Follow a recording as it happens, in any language: subscribe, catch up from a snapshot, then apply live frames in order.
|
|
50
|
+
- [Live translation and spoken translations](https://github.com/vocalstack/python-sdk/blob/main/docs/translation-and-voices.md): Translate a stream as it is spoken, and have each translated sentence spoken back in a voice. Text frames and audio clips, over the same socket.
|
|
51
|
+
- [Errors, retries and limits](https://github.com/vocalstack/python-sdk/blob/main/docs/errors-and-limits.md): One error envelope everywhere; what to retry (429, 503 unavailable) and how to make a retry safe (Idempotency-Key); credit, plan limits and the 402s.
|
|
52
|
+
|
|
53
|
+
<!-- /sdk-docs -->
|
|
54
|
+
|
|
55
|
+
## What is what
|
|
56
|
+
|
|
57
|
+
| Name | What it is | Group |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| realtime session | a signed token plus one socket; nothing stored | `vs.realtime` |
|
|
60
|
+
| broadcast | the link listeners open | `vs.broadcasts` |
|
|
61
|
+
| transcription | a file, link, microphone or stream, transcribed and stored | `vs.transcriptions` |
|
|
62
|
+
| recording | one take inside a broadcast or a transcription | `vs.recordings` |
|
|
63
|
+
| job | a file or link recording's transcription work | `vs.jobs` |
|
|
64
|
+
|
|
65
|
+
The other groups: `vs.corrections`, `vs.share_links`, `vs.voices`,
|
|
66
|
+
`vs.search`, `vs.me`, `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
|
|
67
|
+
Method names are the document's `operationId`s in snake_case
|
|
68
|
+
(`broadcasts.start_recording` is `POST /v1/broadcasts/{id}/recordings`).
|
|
69
|
+
Request fields are keyword arguments, in snake_case or the wire's camelCase
|
|
70
|
+
(`settings={"spokenLanguage": "en"}`); lists return lists; binary answers
|
|
71
|
+
(`recordings.export`, `recordings.clip`, `voices.sample`, ...) return bytes.
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
VocalStack(
|
|
75
|
+
base_url=None, # default https://api.vocalstack.com
|
|
76
|
+
api_key=None, # an API key (vs_key_...), for a server
|
|
77
|
+
token=None, # or: an access token / browser token, or a callable returning one
|
|
78
|
+
acting_principal=None, # act for an organization (X-Acting-Principal)
|
|
79
|
+
device_id=None,
|
|
80
|
+
max_retries=2, # 429s, and 503 unavailable on safe calls, retried after Retry-After
|
|
81
|
+
timeout=300.0,
|
|
82
|
+
ready_deadline_s=30.0, # how long a socket may take to report ready
|
|
83
|
+
)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Realtime sessions and live recordings
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
async with VocalStack(api_key=key) as vs:
|
|
90
|
+
# Nothing stored: a file through one socket.
|
|
91
|
+
result = await vs.realtime.transcribe_file("meeting.mp3", spoken_language="en")
|
|
92
|
+
print(result.text)
|
|
93
|
+
|
|
94
|
+
# A stored live transcription: start a recording, stream raw PCM
|
|
95
|
+
# (f32le, 16 kHz, mono) into the publisher socket.
|
|
96
|
+
tx = await vs.transcriptions.create_live(name="Standup")
|
|
97
|
+
grant = await vs.transcriptions.start_recording(tx.id)
|
|
98
|
+
async with await vs.recordings.publish(grant) as stream:
|
|
99
|
+
asyncio.create_task(pace_realtime(stream, pcm)) # then eof()
|
|
100
|
+
async for event in stream:
|
|
101
|
+
if event.type == "transcript.committed":
|
|
102
|
+
print(event.segment.speaker, event.segment.text)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- `transcript.draft` frames **fully replace** the live tail; never append them.
|
|
106
|
+
- `transcript.committed` segments are immutable, gapless by `segment.seq`,
|
|
107
|
+
and carry word timings.
|
|
108
|
+
- A dropped connection ends the socket (no resume): start a new one.
|
|
109
|
+
|
|
110
|
+
## Errors
|
|
111
|
+
|
|
112
|
+
`VocalStackError` carries `code` (the contract's closed enum), `message`,
|
|
113
|
+
`status`, `retryable`, `details` (quota numbers, code suggestions), `headers`
|
|
114
|
+
and `retry_after`.
|
|
115
|
+
|
|
116
|
+
Verified against the language-agnostic conformance suite (`make conformance`)
|
|
117
|
+
and against a running API (`make sdk-e2e`). For agents: `SKILL.md`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
vocalstack/__init__.py,sha256=IYyumghxnxD_8rRPTzEsbMKhiDOy7RDmxpZXn4AZ5Zk,1397
|
|
2
|
+
vocalstack/_http.py,sha256=IyH3dQxQPmiZsAW-pDXhlCMsdTMkVEQdAodaCkgwKps,5544
|
|
3
|
+
vocalstack/_models.py,sha256=yhJ_hjRdg_Qn6p2AZbZi34gJhtS4r_33GWspFCbYo3s,58503
|
|
4
|
+
vocalstack/client.py,sha256=nkg7MXKvJbIDpFkeLFQkH7OW3bOch-N5rTyg3w6CQjs,3275
|
|
5
|
+
vocalstack/errors.py,sha256=mi34rAtquo8DH4HodnJsvFUfED49Fd0OjdiYqHn3iyc,2868
|
|
6
|
+
vocalstack/realtime.py,sha256=9LLg4UR-px1dgEzdUn9Uq2tW5gbrgPoY2rqs3rtfgEo,15930
|
|
7
|
+
vocalstack/resources.py,sha256=HZ76w8KMjWuoZPGevfTBKuX9uLCw-IqMC6BnqpJT9vk,39594
|
|
8
|
+
vocalstack/SKILL.md,sha256=wZydLhGWtdmpbOwBalEpQMaxKCpeoCZjw-D3kkg1GKM,11616
|
|
9
|
+
vocalstack-1.0.0a0.dist-info/METADATA,sha256=mmv26Q05h8JXGbx9YQoLkUdTaSzCER4oJn9T6fgJATI,6567
|
|
10
|
+
vocalstack-1.0.0a0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
11
|
+
vocalstack-1.0.0a0.dist-info/RECORD,,
|