vocalstack 1.0.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.
@@ -0,0 +1,8 @@
1
+ # Packaging: hatchling reads the nearest .gitignore when it builds the sdist.
2
+ .venv/
3
+ dist/
4
+ build/
5
+ __pycache__/
6
+ *.egg-info/
7
+ .env
8
+ .env.*
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VocalStack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,124 @@
1
+ Metadata-Version: 2.5
2
+ Name: vocalstack
3
+ Version: 1.0.0
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-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: httpx>=0.27
10
+ Requires-Dist: pydantic>=2.7
11
+ Requires-Dist: websockets>=13
12
+ Description-Content-Type: text/markdown
13
+
14
+ # vocalstack
15
+
16
+ The VocalStack speech API for Python (3.10 or newer, asyncio): one client,
17
+ `VocalStack`, with one group per resource. Requests go through `httpx`; answers
18
+ are pydantic models generated from the API's one OpenAPI document
19
+ (`/v1/openapi.json`), with snake_case attributes.
20
+
21
+ Read more about the [VocalStack Python SDK](https://vocalstack.com/#developers) and our other SDKs on the [VocalStack website](https://vocalstack.com/).
22
+
23
+ ```python
24
+ import asyncio, os
25
+ from vocalstack import VocalStack
26
+
27
+ async def main():
28
+ async with VocalStack(api_key=os.environ["VOCALSTACK_API_KEY"]) as vs: # base_url defaults to https://api.vocalstack.com
29
+ tx = await vs.transcriptions.create(url="https://example.com/talk.mp3") # or file="talk.mp3"
30
+ job = await vs.jobs.wait(tx.job.recording_id) # done | failed | cropping
31
+ snap = await vs.recordings.transcript(job.recording_id)
32
+ print(" ".join(s.text for s in snap.sentences))
33
+ open("talk.srt", "wb").write(await vs.recordings.export(job.recording_id, "srt"))
34
+
35
+ asyncio.run(main())
36
+ ```
37
+
38
+ <!-- sdk-docs: generated from the VocalStack API guides; edits here are overwritten -->
39
+
40
+ ## Install
41
+
42
+ ```sh
43
+ pip install vocalstack
44
+ ```
45
+
46
+ ## Guides
47
+
48
+ - [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.
49
+ - [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.
50
+ - [Transcribe a link](https://github.com/vocalstack/python-sdk/blob/main/docs/transcribe-a-link.md): The server fetches a public URL, a YouTube video or a post on a video or audio site, then transcribes it like a file. Asynchronous, with a fetch phase first.
51
+ - [Search your transcriptions](https://github.com/vocalstack/python-sdk/blob/main/docs/search-transcriptions.md): Find transcriptions by words in their name or link, site, language, kind, tag and date, keep the shared ones, and play each with its share code.
52
+ - [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.
53
+ - [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.
54
+ - [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.
55
+ - [Listen](https://github.com/vocalstack/python-sdk/blob/main/docs/listen.md): Follow a transcription as it happens, in any language: subscribe, catch up from a snapshot, then apply live frames in order.
56
+ - [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.
57
+ - [Connect an app with one click](https://github.com/vocalstack/python-sdk/blob/main/docs/connect-an-app.md): Let the people who use your app connect their VocalStack account with one Authenticate click — OAuth 2.0 authorization code with PKCE, where the access token is an API key — instead of pasting a key.
58
+ - [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.
59
+
60
+ <!-- /sdk-docs -->
61
+
62
+ ## What is what
63
+
64
+ | Name | What it is | Group |
65
+ |---|---|---|
66
+ | realtime session | a signed token plus one socket; nothing stored | `vs.realtime` |
67
+ | broadcast | the link listeners open | `vs.broadcasts` |
68
+ | transcription | a file, link, microphone or stream, transcribed and stored | `vs.transcriptions` |
69
+ | recording | one take inside a broadcast or a transcription | `vs.recordings` |
70
+ | job | a file or link recording's transcription work | `vs.jobs` |
71
+
72
+ The other groups: `vs.corrections`, `vs.share_links`, `vs.speakers`,
73
+ `vs.voices`, `vs.search`, `vs.me`, `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
74
+ Method names are the document's `operationId`s in snake_case
75
+ (`broadcasts.start_recording` is `POST /v1/broadcasts/{id}/recordings`).
76
+ Request fields are keyword arguments, in snake_case or the wire's camelCase
77
+ (`settings={"spokenLanguage": "en"}`); lists return lists; binary answers
78
+ (`recordings.export`, `recordings.clip`, `speakers.sample`, ...) return bytes.
79
+
80
+ ```python
81
+ VocalStack(
82
+ base_url=None, # default https://api.vocalstack.com
83
+ api_key=None, # an API key (vs_key_...), for a server
84
+ token=None, # or: an access token / browser token, or a callable returning one
85
+ acting_principal=None, # act for an organization (X-Acting-Principal)
86
+ device_id=None,
87
+ max_retries=2, # 429s, and 503 unavailable on safe calls, retried after Retry-After
88
+ timeout=300.0,
89
+ ready_deadline_s=30.0, # how long a socket may take to report ready
90
+ )
91
+ ```
92
+
93
+ ## Realtime sessions and live recordings
94
+
95
+ ```python
96
+ async with VocalStack(api_key=key) as vs:
97
+ # Nothing stored: a file through one socket.
98
+ result = await vs.realtime.transcribe_file("meeting.mp3", spoken_language="en")
99
+ print(result.text)
100
+
101
+ # A stored live transcription: start a recording, stream raw PCM
102
+ # (f32le, 16 kHz, mono) into the publisher socket.
103
+ tx = await vs.transcriptions.create_live(name="Standup")
104
+ grant = await vs.transcriptions.start_recording(tx.id)
105
+ async with await vs.recordings.publish(grant) as stream:
106
+ asyncio.create_task(pace_realtime(stream, pcm)) # then eof()
107
+ async for event in stream:
108
+ if event.type == "transcript.committed":
109
+ print(event.segment.speaker, event.segment.text)
110
+ ```
111
+
112
+ - `transcript.draft` frames **fully replace** the live tail; never append them.
113
+ - `transcript.committed` segments are immutable, gapless by `segment.seq`,
114
+ and carry word timings.
115
+ - A dropped connection ends the socket (no resume): start a new one.
116
+
117
+ ## Errors
118
+
119
+ `VocalStackError` carries `code` (the contract's closed enum), `message`,
120
+ `status`, `retryable`, `details` (quota numbers, code suggestions), `headers`
121
+ and `retry_after`.
122
+
123
+ Verified against a language-agnostic conformance suite shared by every
124
+ VocalStack SDK and against a running API. For agents: `SKILL.md`.
@@ -0,0 +1,111 @@
1
+ # vocalstack
2
+
3
+ The VocalStack speech API for Python (3.10 or newer, asyncio): one client,
4
+ `VocalStack`, with one group per resource. Requests go through `httpx`; answers
5
+ are pydantic models generated from the API's one OpenAPI document
6
+ (`/v1/openapi.json`), with snake_case attributes.
7
+
8
+ Read more about the [VocalStack Python SDK](https://vocalstack.com/#developers) and our other SDKs on the [VocalStack website](https://vocalstack.com/).
9
+
10
+ ```python
11
+ import asyncio, os
12
+ from vocalstack import VocalStack
13
+
14
+ async def main():
15
+ async with VocalStack(api_key=os.environ["VOCALSTACK_API_KEY"]) as vs: # base_url defaults to https://api.vocalstack.com
16
+ tx = await vs.transcriptions.create(url="https://example.com/talk.mp3") # or file="talk.mp3"
17
+ job = await vs.jobs.wait(tx.job.recording_id) # done | failed | cropping
18
+ snap = await vs.recordings.transcript(job.recording_id)
19
+ print(" ".join(s.text for s in snap.sentences))
20
+ open("talk.srt", "wb").write(await vs.recordings.export(job.recording_id, "srt"))
21
+
22
+ asyncio.run(main())
23
+ ```
24
+
25
+ <!-- sdk-docs: generated from the VocalStack API guides; edits here are overwritten -->
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ pip install vocalstack
31
+ ```
32
+
33
+ ## Guides
34
+
35
+ - [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.
36
+ - [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.
37
+ - [Transcribe a link](https://github.com/vocalstack/python-sdk/blob/main/docs/transcribe-a-link.md): The server fetches a public URL, a YouTube video or a post on a video or audio site, then transcribes it like a file. Asynchronous, with a fetch phase first.
38
+ - [Search your transcriptions](https://github.com/vocalstack/python-sdk/blob/main/docs/search-transcriptions.md): Find transcriptions by words in their name or link, site, language, kind, tag and date, keep the shared ones, and play each with its share code.
39
+ - [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.
40
+ - [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.
41
+ - [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.
42
+ - [Listen](https://github.com/vocalstack/python-sdk/blob/main/docs/listen.md): Follow a transcription as it happens, in any language: subscribe, catch up from a snapshot, then apply live frames in order.
43
+ - [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.
44
+ - [Connect an app with one click](https://github.com/vocalstack/python-sdk/blob/main/docs/connect-an-app.md): Let the people who use your app connect their VocalStack account with one Authenticate click — OAuth 2.0 authorization code with PKCE, where the access token is an API key — instead of pasting a key.
45
+ - [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.
46
+
47
+ <!-- /sdk-docs -->
48
+
49
+ ## What is what
50
+
51
+ | Name | What it is | Group |
52
+ |---|---|---|
53
+ | realtime session | a signed token plus one socket; nothing stored | `vs.realtime` |
54
+ | broadcast | the link listeners open | `vs.broadcasts` |
55
+ | transcription | a file, link, microphone or stream, transcribed and stored | `vs.transcriptions` |
56
+ | recording | one take inside a broadcast or a transcription | `vs.recordings` |
57
+ | job | a file or link recording's transcription work | `vs.jobs` |
58
+
59
+ The other groups: `vs.corrections`, `vs.share_links`, `vs.speakers`,
60
+ `vs.voices`, `vs.search`, `vs.me`, `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
61
+ Method names are the document's `operationId`s in snake_case
62
+ (`broadcasts.start_recording` is `POST /v1/broadcasts/{id}/recordings`).
63
+ Request fields are keyword arguments, in snake_case or the wire's camelCase
64
+ (`settings={"spokenLanguage": "en"}`); lists return lists; binary answers
65
+ (`recordings.export`, `recordings.clip`, `speakers.sample`, ...) return bytes.
66
+
67
+ ```python
68
+ VocalStack(
69
+ base_url=None, # default https://api.vocalstack.com
70
+ api_key=None, # an API key (vs_key_...), for a server
71
+ token=None, # or: an access token / browser token, or a callable returning one
72
+ acting_principal=None, # act for an organization (X-Acting-Principal)
73
+ device_id=None,
74
+ max_retries=2, # 429s, and 503 unavailable on safe calls, retried after Retry-After
75
+ timeout=300.0,
76
+ ready_deadline_s=30.0, # how long a socket may take to report ready
77
+ )
78
+ ```
79
+
80
+ ## Realtime sessions and live recordings
81
+
82
+ ```python
83
+ async with VocalStack(api_key=key) as vs:
84
+ # Nothing stored: a file through one socket.
85
+ result = await vs.realtime.transcribe_file("meeting.mp3", spoken_language="en")
86
+ print(result.text)
87
+
88
+ # A stored live transcription: start a recording, stream raw PCM
89
+ # (f32le, 16 kHz, mono) into the publisher socket.
90
+ tx = await vs.transcriptions.create_live(name="Standup")
91
+ grant = await vs.transcriptions.start_recording(tx.id)
92
+ async with await vs.recordings.publish(grant) as stream:
93
+ asyncio.create_task(pace_realtime(stream, pcm)) # then eof()
94
+ async for event in stream:
95
+ if event.type == "transcript.committed":
96
+ print(event.segment.speaker, event.segment.text)
97
+ ```
98
+
99
+ - `transcript.draft` frames **fully replace** the live tail; never append them.
100
+ - `transcript.committed` segments are immutable, gapless by `segment.seq`,
101
+ and carry word timings.
102
+ - A dropped connection ends the socket (no resume): start a new one.
103
+
104
+ ## Errors
105
+
106
+ `VocalStackError` carries `code` (the contract's closed enum), `message`,
107
+ `status`, `retryable`, `details` (quota numbers, code suggestions), `headers`
108
+ and `retry_after`.
109
+
110
+ Verified against a language-agnostic conformance suite shared by every
111
+ VocalStack SDK and against a running API. For agents: `SKILL.md`.
@@ -0,0 +1,243 @@
1
+ ---
2
+ name: vocalstack
3
+ description: Use when writing Python code that calls the VocalStack speech API with the vocalstack package, for example to transcribe an audio or video URL or a local file, stream live audio for realtime transcription, fetch or export a transcript (PDF, XLSX, SRT, VTT, text, Markdown, JSON), or search transcripts. Covers installing, API keys, base URLs, five copy-paste programs and error handling (401, 402, 403, 429).
4
+ ---
5
+
6
+ # VocalStack Python SDK
7
+
8
+ The VocalStack API transcribes speech (files, links, live audio), with speaker
9
+ labels and translation. The `vocalstack` package has one asyncio client,
10
+ `VocalStack`, with one group per resource: `vs.transcriptions`,
11
+ `vs.broadcasts`, `vs.search`, `vs.realtime` and a few more
12
+ (listed at the end). Answers are pydantic models with snake_case attributes.
13
+
14
+ ## What is what
15
+
16
+ - A **transcription** is a file, a link, a microphone or a stream, transcribed
17
+ and stored. Create one with `await vs.transcriptions.create(...)`. Its id is
18
+ what you read the transcript and exports with:
19
+ `await vs.transcriptions.transcript(tx.id)`. A live one is one continuous
20
+ transcript however often it is paused and resumed.
21
+ - A **job** is a file or link transcription's work:
22
+ `await vs.transcriptions.wait_for_job(tx.id)` polls it until it is `done` or `failed`
23
+ (`on_progress=lambda job: ...` sees each read: `job.state`, `job.progress.pct`).
24
+ - A **broadcast** is a link listeners open to follow a live transcription.
25
+ - A **realtime session** (`vs.realtime`) is a socket you stream audio into and
26
+ read the transcript from. Nothing is stored. "Session" means only this.
27
+
28
+ ## Install
29
+
30
+ ```sh
31
+ python3 -m venv .venv && . .venv/bin/activate # system Pythons refuse a bare pip install
32
+ pip install vocalstack # Python 3.10 or newer
33
+ ```
34
+
35
+ Live transcription (program 4) also needs `ffmpeg` on PATH.
36
+
37
+ Speaker numbers start at 0. A speaker of `-1` means speaker labels were off
38
+ for that transcription, so print the text without a speaker.
39
+
40
+ ## Auth and base URL
41
+
42
+ - Read the key from `VOCALSTACK_API_KEY` and pass it as `api_key`. It goes
43
+ out as `Authorization: Bearer <key>`, also on sockets.
44
+ - An API key starts with `vs_key_`. There is one kind of key: every call is
45
+ real usage on the account's tier and quotas.
46
+ - Keys are for servers. Never put a key in browser code or in a URL. The API
47
+ refuses a key sent from a web page (`Origin` header) or in a query string.
48
+ - Scopes: `read` (read transcripts, search, export), `write` (transcribe
49
+ files and links, open realtime sessions, change things), `recordings:publish`
50
+ (start, pause and stop a stored live transcription and send it audio), or `*`.
51
+ - Base URL: `https://api.vocalstack.com` (the default). Override it with
52
+ `VOCALSTACK_BASE_URL` (for example, a local or staging server).
53
+
54
+ Every program below opens the client the same way, inside `async def main()`
55
+ run with `asyncio.run(main())` (a `None` base URL means the default):
56
+
57
+ ```python
58
+ async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
59
+ ...
60
+ ```
61
+
62
+ ## 1. Transcribe a URL and wait for the result
63
+
64
+ The server fetches the link itself, so it must be a public http(s) address.
65
+ Private, loopback and cloud-metadata addresses are refused.
66
+
67
+ ```python
68
+ import asyncio, os
69
+ from vocalstack import VocalStack
70
+
71
+ async def main():
72
+ async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
73
+ tx = await vs.transcriptions.create(
74
+ url="https://raw.githubusercontent.com/openai/whisper/main/tests/jfk.flac",
75
+ name="JFK sample",
76
+ )
77
+ job = await vs.transcriptions.wait_for_job(tx.id) # queued -> fetching -> transcribing -> done | failed
78
+ if job.state != "done":
79
+ raise SystemExit(f"transcription {job.state}: {job.error}")
80
+ snap = await vs.transcriptions.transcript(tx.id)
81
+ for s in snap.sentences:
82
+ print(f"[speaker {s.speaker}] {s.text}" if s.speaker >= 0 else s.text)
83
+ print("transcription id", tx.id)
84
+
85
+ asyncio.run(main())
86
+ ```
87
+
88
+ ## 2. Transcribe a local file
89
+
90
+ ```python
91
+ import asyncio, os, sys
92
+ from vocalstack import VocalStack
93
+
94
+ async def main(path): # mp3, wav, flac, ogg, m4a, mp4 ...
95
+ async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
96
+ tx = await vs.transcriptions.create(
97
+ file=path, # a path, bytes, or an open binary file
98
+ settings={"spokenLanguage": "en", "speakerLabels": "on"}, # both optional; "auto" (default) | "on" | "off"
99
+ # Off unless asked for: settings summary, title, summaryTranslations,
100
+ # translationTts (text-to-speech of translations), and share_link=True (a public share link).
101
+ )
102
+ job = await vs.transcriptions.wait_for_job(tx.id)
103
+ if job.state != "done":
104
+ raise SystemExit(f"transcription {job.state}: {job.error}")
105
+ snap = await vs.transcriptions.transcript(tx.id)
106
+ print(" ".join(s.text for s in snap.sentences))
107
+
108
+ asyncio.run(main(sys.argv[1]))
109
+ ```
110
+
111
+ ## 3. Fetch a transcript or an export file
112
+
113
+ The transcript holds segments (with word timings), sentences and speakers.
114
+ Export formats are `pdf`, `xlsx`, `srt`, `vtt`, `txt`, `md` and `json`; add
115
+ `lang="<code>"` for a translated file, `speaker_labels="off"` (or `"on"`, `"auto"`),
116
+ `timestamps="off"`, `start_s`/`end_s` for one part and `summary=True`. `export` returns the file's bytes.
117
+
118
+ ```python
119
+ import asyncio, os, sys
120
+ from vocalstack import VocalStack
121
+
122
+ async def main(tx_id):
123
+ async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
124
+ snap = await vs.transcriptions.transcript(tx_id)
125
+ print(len(snap.segments), "segments,", len(snap.sentences), "sentences, state", snap.state)
126
+ with open("transcript.srt", "wb") as f:
127
+ f.write(await vs.transcriptions.export(tx_id, "srt"))
128
+
129
+ asyncio.run(main(sys.argv[1]))
130
+ ```
131
+
132
+ ## 4. Live transcription from a microphone or a file
133
+
134
+ A live transcription takes raw PCM: 32-bit float little-endian, 16 kHz, mono.
135
+ Create it, start it, and open the publisher socket the grant names.
136
+ Here ffmpeg decodes a file, and `pace_realtime` sends it at realtime speed and
137
+ then calls `eof()`. For a microphone, read ffmpeg's stdout as it arrives
138
+ (`-f avfoundation -i :0` on macOS, `-f pulse -i default` on Linux) and call
139
+ `await stream.send_audio(chunk)` for each chunk.
140
+
141
+ ```python
142
+ import asyncio, os, subprocess, sys
143
+ from vocalstack import VocalStack, pace_realtime
144
+
145
+ async def main(path):
146
+ async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
147
+ tx = await vs.transcriptions.create_live(name="Live demo", settings={"spokenLanguage": "en"})
148
+ grant = await vs.transcriptions.start(tx.id)
149
+
150
+ pcm = subprocess.run(["ffmpeg", "-loglevel", "error", "-i", path,
151
+ "-f", "f32le", "-ac", "1", "-ar", "16000", "-"],
152
+ check=True, capture_output=True).stdout
153
+
154
+ # A cold engine can take a while to load, so allow a long ready deadline.
155
+ async with await vs.transcriptions.publish(grant, ready_deadline_s=180) as stream:
156
+ feeder = asyncio.create_task(pace_realtime(stream, pcm)) # then eof(), which ends the transcription
157
+ async for event in stream:
158
+ if event.type == "transcript.committed":
159
+ print(f"[speaker {event.segment.speaker}] {event.segment.text}", flush=True)
160
+ await feeder
161
+
162
+ # To end it without eof(): vs.transcriptions.pause(tx.id), then vs.transcriptions.stop(tx.id).
163
+ # A stopped transcription cannot be started again: create a new one.
164
+ snap = await vs.transcriptions.transcript(tx.id)
165
+ print("final:", " ".join(s.text for s in snap.sentences))
166
+
167
+ asyncio.run(main(sys.argv[1]))
168
+ ```
169
+
170
+ To transcribe without storing anything, use a realtime session instead:
171
+ `(await vs.realtime.transcribe_file("talk.mp3")).text`.
172
+
173
+ ## 5. Search transcripts
174
+
175
+ ```python
176
+ import asyncio, os, sys
177
+ from vocalstack import VocalStack
178
+
179
+ async def main(q): # 2+ characters
180
+ async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
181
+ res = await vs.search.query(q, limit=5)
182
+ for h in res.hits:
183
+ print(f"{h.link_name} @ {h.media_start:.1f}s [speaker {h.speaker}]: {h.text} (transcription {h.transcription_id})")
184
+
185
+ asyncio.run(main(sys.argv[1]))
186
+ ```
187
+
188
+ By meaning, in any language, even with none of the words (vector search). Each
189
+ hit's `passage` is its whole paragraph: give the passages to your own model as
190
+ context to answer questions about what was said (RAG). Pay as you go counts 60
191
+ an hour (`allowance`); Premium and Enterprise have no limit.
192
+
193
+ ```python
194
+ res = await vs.search.vector("how much does housing cost")
195
+ for h in res.hits:
196
+ print(f"{h.similarity:.2f}", h.passage.media_start, h.passage.text)
197
+ ```
198
+
199
+ ## Errors
200
+
201
+ A failed call raises `vocalstack.VocalStackError` with `.code`, `.message`,
202
+ `.status`, `.retryable`, `.details` (the body's `data.details`), `.headers`
203
+ and `.retry_after` (seconds, from `Retry-After`). A `429`, and a
204
+ `503 unavailable` on a call that is safe to repeat, is retried for you after
205
+ its `Retry-After`, twice by default (`max_retries` on the client).
206
+
207
+ | Status | `code` | What to do |
208
+ |---|---|---|
209
+ | 401 | `invalid_token`, `key_expired`, `key_revoked` | Check `VOCALSTACK_API_KEY`. Use the replacement key, or create a new one. |
210
+ | 403 | `forbidden` | Usually a missing scope: the message names it, and `e.headers["www-authenticate"]` lists the scopes the route needs. A suspended key or account gets `suspended`. |
211
+ | 403 | `terms_acceptance_required` | The account has not accepted the current Terms of Service and Privacy Policy: someone signs in to the Dashboard and accepts them (an organisation's keys work once an owner or admin has). Not retryable until then. |
212
+ | 402 | `insufficient_credit` | The account's credit is out, or does not cover the transcription: every transcription is billed at least the plan's minimum (`rates.minimumSeconds`, 5 minutes). `details`: `balance`, `plan`, `topUpUrl`, and `required` when the cost was known up front. Add credit; `await vs.billing.get()` shows the balance. |
213
+ | 409 | `payment_method_required` | Auto top-up (`vs.billing.set_auto_top_up`) and the portal (`vs.billing.portal()`) need a payment first (`vs.billing.create_checkout(kind="topup", amount=25, accept_terms=True)` opens one; a signed-in person's token, never an API key). |
214
+ | 402 | `quota_exceeded` | The plan's transcriptions-at-once limit is reached. `details`: `metric` (`concurrent_transcriptions`), `limit`, `used`, `plan`, `topUpUrl`. |
215
+ | 429 | `rate_limited` | Retried automatically; if it still fails, wait `e.retry_after` seconds. Every response carries `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`. |
216
+ | 503 | `unavailable` | The service is waking (its database was asleep). Retried automatically after `Retry-After` (2 s) on calls that are safe to repeat: GET, HEAD, DELETE, or any call with `idempotency_key=`. A create without a key is not retried: retry it yourself, with an `idempotency_key` so it cannot run twice. A realtime socket refused this way raises `unavailable`; a bare 503 there is `capacity_exceeded`. |
217
+
218
+ ```python
219
+ from vocalstack import VocalStackError
220
+ try:
221
+ await vs.search.query("country")
222
+ except VocalStackError as e:
223
+ if e.code in ("insufficient_credit", "quota_exceeded"):
224
+ print("billing:", e.message, e.details)
225
+ else:
226
+ print(e.status, e.code, e.message)
227
+ ```
228
+
229
+ ## More
230
+
231
+ - The other groups: `vs.transcriptions` (also `list`, `get`, `update`, `archive`,
232
+ `restore`, `purge`, `list_share_links`, `create_share_link`, `list_scripts`,
233
+ `pause`, `resume`, `stop`, `summarize`, `summary`, `translation`, `audio`,
234
+ `subscribe`, `history`, `corrections`, `apply_corrections`, `request_voice`),
235
+ `vs.corrections` (`revert`), `vs.share_links`, `vs.speakers` (with `invite`, `list_invites`, `renew_invite`,
236
+ `cancel_invite`), `vs.speaker_invites` (the invited person's link, no key), `vs.voices`, `vs.broadcasts`,
237
+ `vs.me` (`get`, `usage`), `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
238
+ Each method is its operation's name in the OpenAPI document, in snake_case
239
+ (`transcriptions.create` is `POST /v1/transcriptions`).
240
+ - `<base>/llms.txt` lists every operation in a form written for agents.
241
+ `<base>/llms-full.txt` adds parameters, auth mode, tier and scopes.
242
+ - `<base>/docs` is the interactive reference. `<base>/v1/openapi.json` is
243
+ the OpenAPI document; the SDK's models are generated from it.
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "vocalstack"
7
+ version = "1.0.0"
8
+ description = "VocalStack speech API SDK (asyncio): one client grouped by resource, typed models from the API contract, realtime WebSocket streaming."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ dependencies = [
14
+ "httpx>=0.27",
15
+ "websockets>=13",
16
+ "pydantic>=2.7",
17
+ ]
18
+
19
+ [project.urls]
20
+ Homepage = "https://vocalstack.com"
21
+
22
+ [tool.hatch.build.targets.wheel]
23
+ packages = ["src/vocalstack"]
24
+
25
+ [tool.hatch.build.targets.wheel.force-include]
26
+ "SKILL.md" = "vocalstack/SKILL.md"
27
+
28
+ [tool.hatch.build.targets.sdist]
29
+ only-include = ["src/vocalstack", "LICENSE", "README.md", "SKILL.md", "skills", "pyproject.toml"]