vocalstack 1.0.0a12__tar.gz → 1.0.0a13__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.0.0a12 → vocalstack-1.0.0a13}/PKG-INFO +3 -3
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/README.md +2 -2
- {vocalstack-1.0.0a12/skills/vocalstack → vocalstack-1.0.0a13}/SKILL.md +31 -28
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/pyproject.toml +1 -1
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13/skills/vocalstack}/SKILL.md +30 -28
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/src/vocalstack/__init__.py +1 -3
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/src/vocalstack/_models.py +182 -175
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/src/vocalstack/client.py +7 -9
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/src/vocalstack/realtime.py +2 -2
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/src/vocalstack/resources.py +186 -197
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/.gitignore +0 -0
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/LICENSE +0 -0
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/src/vocalstack/_http.py +0 -0
- {vocalstack-1.0.0a12 → vocalstack-1.0.0a13}/src/vocalstack/errors.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: vocalstack
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0a13
|
|
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
|
|
@@ -47,12 +47,12 @@ pip install vocalstack
|
|
|
47
47
|
|
|
48
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
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
|
|
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
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
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
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
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
|
|
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
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
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
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.
|
|
@@ -34,12 +34,12 @@ pip install vocalstack
|
|
|
34
34
|
|
|
35
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
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
|
|
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
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
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
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
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
|
|
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
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
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
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.
|
|
@@ -7,20 +7,21 @@ description: Use when writing Python code that calls the VocalStack speech API w
|
|
|
7
7
|
|
|
8
8
|
The VocalStack API transcribes speech (files, links, live audio), with speaker
|
|
9
9
|
labels and translation. The `vocalstack` package has one asyncio client,
|
|
10
|
-
`VocalStack`, with one group per resource: `vs.transcriptions`,
|
|
11
|
-
`vs.
|
|
10
|
+
`VocalStack`, with one group per resource: `vs.transcriptions`,
|
|
11
|
+
`vs.broadcasts`, `vs.search`, `vs.realtime` and a few more
|
|
12
12
|
(listed at the end). Answers are pydantic models with snake_case attributes.
|
|
13
13
|
|
|
14
14
|
## What is what
|
|
15
15
|
|
|
16
16
|
- A **transcription** is a file, a link, a microphone or a stream, transcribed
|
|
17
|
-
and stored. Create one with `await vs.transcriptions.create(...)`.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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`
|
|
22
23
|
(`on_progress=lambda job: ...` sees each read: `job.state`, `job.progress.pct`).
|
|
23
|
-
- A **broadcast** is a link listeners open to follow a live
|
|
24
|
+
- A **broadcast** is a link listeners open to follow a live transcription.
|
|
24
25
|
- A **realtime session** (`vs.realtime`) is a socket you stream audio into and
|
|
25
26
|
read the transcript from. Nothing is stored. "Session" means only this.
|
|
26
27
|
|
|
@@ -72,14 +73,13 @@ async def main():
|
|
|
72
73
|
url="https://raw.githubusercontent.com/openai/whisper/main/tests/jfk.flac",
|
|
73
74
|
name="JFK sample",
|
|
74
75
|
)
|
|
75
|
-
|
|
76
|
-
job = await vs.jobs.wait(rec) # queued -> fetching -> transcribing -> done | failed
|
|
76
|
+
job = await vs.transcriptions.wait_for_job(tx.id) # queued -> fetching -> transcribing -> done | failed
|
|
77
77
|
if job.state != "done":
|
|
78
78
|
raise SystemExit(f"transcription {job.state}: {job.error}")
|
|
79
|
-
snap = await vs.
|
|
79
|
+
snap = await vs.transcriptions.transcript(tx.id)
|
|
80
80
|
for s in snap.sentences:
|
|
81
81
|
print(f"[speaker {s.speaker}] {s.text}" if s.speaker >= 0 else s.text)
|
|
82
|
-
print("
|
|
82
|
+
print("transcription id", tx.id)
|
|
83
83
|
|
|
84
84
|
asyncio.run(main())
|
|
85
85
|
```
|
|
@@ -98,10 +98,10 @@ async def main(path): # mp3, wav, flac, ogg, m4a, mp4 ...
|
|
|
98
98
|
# Off unless asked for: settings summary, title, summaryTranslations,
|
|
99
99
|
# translationTts (text-to-speech of translations), and share_link=True (a public share link).
|
|
100
100
|
)
|
|
101
|
-
job = await vs.
|
|
101
|
+
job = await vs.transcriptions.wait_for_job(tx.id)
|
|
102
102
|
if job.state != "done":
|
|
103
103
|
raise SystemExit(f"transcription {job.state}: {job.error}")
|
|
104
|
-
snap = await vs.
|
|
104
|
+
snap = await vs.transcriptions.transcript(tx.id)
|
|
105
105
|
print(" ".join(s.text for s in snap.sentences))
|
|
106
106
|
|
|
107
107
|
asyncio.run(main(sys.argv[1]))
|
|
@@ -117,12 +117,12 @@ translated file. `export` returns the file's bytes.
|
|
|
117
117
|
import asyncio, os, sys
|
|
118
118
|
from vocalstack import VocalStack
|
|
119
119
|
|
|
120
|
-
async def main(
|
|
120
|
+
async def main(tx_id):
|
|
121
121
|
async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
|
|
122
|
-
snap = await vs.
|
|
122
|
+
snap = await vs.transcriptions.transcript(tx_id)
|
|
123
123
|
print(len(snap.segments), "segments,", len(snap.sentences), "sentences, state", snap.state)
|
|
124
124
|
with open("transcript.srt", "wb") as f:
|
|
125
|
-
f.write(await vs.
|
|
125
|
+
f.write(await vs.transcriptions.export(tx_id, "srt"))
|
|
126
126
|
|
|
127
127
|
asyncio.run(main(sys.argv[1]))
|
|
128
128
|
```
|
|
@@ -130,7 +130,7 @@ asyncio.run(main(sys.argv[1]))
|
|
|
130
130
|
## 4. Live transcription from a microphone or a file
|
|
131
131
|
|
|
132
132
|
A live transcription takes raw PCM: 32-bit float little-endian, 16 kHz, mono.
|
|
133
|
-
Create it, start
|
|
133
|
+
Create it, start it, and open the publisher socket the grant names.
|
|
134
134
|
Here ffmpeg decodes a file, and `pace_realtime` sends it at realtime speed and
|
|
135
135
|
then calls `eof()`. For a microphone, read ffmpeg's stdout as it arrives
|
|
136
136
|
(`-f avfoundation -i :0` on macOS, `-f pulse -i default` on Linux) and call
|
|
@@ -143,22 +143,23 @@ from vocalstack import VocalStack, pace_realtime
|
|
|
143
143
|
async def main(path):
|
|
144
144
|
async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
|
|
145
145
|
tx = await vs.transcriptions.create_live(name="Live demo", settings={"spokenLanguage": "en"})
|
|
146
|
-
grant = await vs.transcriptions.
|
|
146
|
+
grant = await vs.transcriptions.start(tx.id)
|
|
147
147
|
|
|
148
148
|
pcm = subprocess.run(["ffmpeg", "-loglevel", "error", "-i", path,
|
|
149
149
|
"-f", "f32le", "-ac", "1", "-ar", "16000", "-"],
|
|
150
150
|
check=True, capture_output=True).stdout
|
|
151
151
|
|
|
152
152
|
# A cold engine can take a while to load, so allow a long ready deadline.
|
|
153
|
-
async with await vs.
|
|
154
|
-
feeder = asyncio.create_task(pace_realtime(stream, pcm)) # then eof(), which ends the
|
|
153
|
+
async with await vs.transcriptions.publish(grant, ready_deadline_s=180) as stream:
|
|
154
|
+
feeder = asyncio.create_task(pace_realtime(stream, pcm)) # then eof(), which ends the transcription
|
|
155
155
|
async for event in stream:
|
|
156
156
|
if event.type == "transcript.committed":
|
|
157
157
|
print(f"[speaker {event.segment.speaker}] {event.segment.text}", flush=True)
|
|
158
158
|
await feeder
|
|
159
159
|
|
|
160
|
-
# To end
|
|
161
|
-
|
|
160
|
+
# To end it without eof(): vs.transcriptions.pause(tx.id), then vs.transcriptions.stop(tx.id).
|
|
161
|
+
# A stopped transcription cannot be started again: create a new one.
|
|
162
|
+
snap = await vs.transcriptions.transcript(tx.id)
|
|
162
163
|
print("final:", " ".join(s.text for s in snap.sentences))
|
|
163
164
|
|
|
164
165
|
asyncio.run(main(sys.argv[1]))
|
|
@@ -177,7 +178,7 @@ async def main(q): # 2+ characters
|
|
|
177
178
|
async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
|
|
178
179
|
res = await vs.search.query(q, limit=5)
|
|
179
180
|
for h in res.hits:
|
|
180
|
-
print(f"{h.link_name} @ {h.media_start:.1f}s [speaker {h.speaker}]: {h.text} (
|
|
181
|
+
print(f"{h.link_name} @ {h.media_start:.1f}s [speaker {h.speaker}]: {h.text} (transcription {h.transcription_id})")
|
|
181
182
|
|
|
182
183
|
asyncio.run(main(sys.argv[1]))
|
|
183
184
|
```
|
|
@@ -225,10 +226,12 @@ except VocalStackError as e:
|
|
|
225
226
|
|
|
226
227
|
## More
|
|
227
228
|
|
|
228
|
-
- The other groups: `vs.transcriptions` (`list`, `get`, `update`, `archive`,
|
|
229
|
-
`restore`, `purge`, `list_share_links`, `create_share_link`, `list_scripts
|
|
230
|
-
|
|
231
|
-
`
|
|
229
|
+
- The other groups: `vs.transcriptions` (also `list`, `get`, `update`, `archive`,
|
|
230
|
+
`restore`, `purge`, `list_share_links`, `create_share_link`, `list_scripts`,
|
|
231
|
+
`pause`, `resume`, `stop`, `summarize`, `summary`, `translation`, `audio`,
|
|
232
|
+
`subscribe`, `history`, `corrections`, `apply_corrections`, `request_voice`),
|
|
233
|
+
`vs.corrections` (`revert`), `vs.share_links`, `vs.speakers` (with `invite`, `list_invites`, `renew_invite`,
|
|
234
|
+
`cancel_invite`), `vs.speaker_invites` (the invited person's link, no key), `vs.voices`, `vs.broadcasts`,
|
|
232
235
|
`vs.me` (`get`, `usage`), `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
|
|
233
236
|
Each method is its operation's name in the OpenAPI document, in snake_case
|
|
234
237
|
(`transcriptions.create` is `POST /v1/transcriptions`).
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "vocalstack"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.0a13"
|
|
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"
|
|
@@ -7,20 +7,21 @@ description: Use when writing Python code that calls the VocalStack speech API w
|
|
|
7
7
|
|
|
8
8
|
The VocalStack API transcribes speech (files, links, live audio), with speaker
|
|
9
9
|
labels and translation. The `vocalstack` package has one asyncio client,
|
|
10
|
-
`VocalStack`, with one group per resource: `vs.transcriptions`,
|
|
11
|
-
`vs.
|
|
10
|
+
`VocalStack`, with one group per resource: `vs.transcriptions`,
|
|
11
|
+
`vs.broadcasts`, `vs.search`, `vs.realtime` and a few more
|
|
12
12
|
(listed at the end). Answers are pydantic models with snake_case attributes.
|
|
13
13
|
|
|
14
14
|
## What is what
|
|
15
15
|
|
|
16
16
|
- A **transcription** is a file, a link, a microphone or a stream, transcribed
|
|
17
|
-
and stored. Create one with `await vs.transcriptions.create(...)`.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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`
|
|
22
23
|
(`on_progress=lambda job: ...` sees each read: `job.state`, `job.progress.pct`).
|
|
23
|
-
- A **broadcast** is a link listeners open to follow a live
|
|
24
|
+
- A **broadcast** is a link listeners open to follow a live transcription.
|
|
24
25
|
- A **realtime session** (`vs.realtime`) is a socket you stream audio into and
|
|
25
26
|
read the transcript from. Nothing is stored. "Session" means only this.
|
|
26
27
|
|
|
@@ -72,14 +73,13 @@ async def main():
|
|
|
72
73
|
url="https://raw.githubusercontent.com/openai/whisper/main/tests/jfk.flac",
|
|
73
74
|
name="JFK sample",
|
|
74
75
|
)
|
|
75
|
-
|
|
76
|
-
job = await vs.jobs.wait(rec) # queued -> fetching -> transcribing -> done | failed
|
|
76
|
+
job = await vs.transcriptions.wait_for_job(tx.id) # queued -> fetching -> transcribing -> done | failed
|
|
77
77
|
if job.state != "done":
|
|
78
78
|
raise SystemExit(f"transcription {job.state}: {job.error}")
|
|
79
|
-
snap = await vs.
|
|
79
|
+
snap = await vs.transcriptions.transcript(tx.id)
|
|
80
80
|
for s in snap.sentences:
|
|
81
81
|
print(f"[speaker {s.speaker}] {s.text}" if s.speaker >= 0 else s.text)
|
|
82
|
-
print("
|
|
82
|
+
print("transcription id", tx.id)
|
|
83
83
|
|
|
84
84
|
asyncio.run(main())
|
|
85
85
|
```
|
|
@@ -98,10 +98,10 @@ async def main(path): # mp3, wav, flac, ogg, m4a, mp4 ...
|
|
|
98
98
|
# Off unless asked for: settings summary, title, summaryTranslations,
|
|
99
99
|
# translationTts (text-to-speech of translations), and share_link=True (a public share link).
|
|
100
100
|
)
|
|
101
|
-
job = await vs.
|
|
101
|
+
job = await vs.transcriptions.wait_for_job(tx.id)
|
|
102
102
|
if job.state != "done":
|
|
103
103
|
raise SystemExit(f"transcription {job.state}: {job.error}")
|
|
104
|
-
snap = await vs.
|
|
104
|
+
snap = await vs.transcriptions.transcript(tx.id)
|
|
105
105
|
print(" ".join(s.text for s in snap.sentences))
|
|
106
106
|
|
|
107
107
|
asyncio.run(main(sys.argv[1]))
|
|
@@ -117,12 +117,12 @@ translated file. `export` returns the file's bytes.
|
|
|
117
117
|
import asyncio, os, sys
|
|
118
118
|
from vocalstack import VocalStack
|
|
119
119
|
|
|
120
|
-
async def main(
|
|
120
|
+
async def main(tx_id):
|
|
121
121
|
async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
|
|
122
|
-
snap = await vs.
|
|
122
|
+
snap = await vs.transcriptions.transcript(tx_id)
|
|
123
123
|
print(len(snap.segments), "segments,", len(snap.sentences), "sentences, state", snap.state)
|
|
124
124
|
with open("transcript.srt", "wb") as f:
|
|
125
|
-
f.write(await vs.
|
|
125
|
+
f.write(await vs.transcriptions.export(tx_id, "srt"))
|
|
126
126
|
|
|
127
127
|
asyncio.run(main(sys.argv[1]))
|
|
128
128
|
```
|
|
@@ -130,7 +130,7 @@ asyncio.run(main(sys.argv[1]))
|
|
|
130
130
|
## 4. Live transcription from a microphone or a file
|
|
131
131
|
|
|
132
132
|
A live transcription takes raw PCM: 32-bit float little-endian, 16 kHz, mono.
|
|
133
|
-
Create it, start
|
|
133
|
+
Create it, start it, and open the publisher socket the grant names.
|
|
134
134
|
Here ffmpeg decodes a file, and `pace_realtime` sends it at realtime speed and
|
|
135
135
|
then calls `eof()`. For a microphone, read ffmpeg's stdout as it arrives
|
|
136
136
|
(`-f avfoundation -i :0` on macOS, `-f pulse -i default` on Linux) and call
|
|
@@ -143,22 +143,23 @@ from vocalstack import VocalStack, pace_realtime
|
|
|
143
143
|
async def main(path):
|
|
144
144
|
async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
|
|
145
145
|
tx = await vs.transcriptions.create_live(name="Live demo", settings={"spokenLanguage": "en"})
|
|
146
|
-
grant = await vs.transcriptions.
|
|
146
|
+
grant = await vs.transcriptions.start(tx.id)
|
|
147
147
|
|
|
148
148
|
pcm = subprocess.run(["ffmpeg", "-loglevel", "error", "-i", path,
|
|
149
149
|
"-f", "f32le", "-ac", "1", "-ar", "16000", "-"],
|
|
150
150
|
check=True, capture_output=True).stdout
|
|
151
151
|
|
|
152
152
|
# A cold engine can take a while to load, so allow a long ready deadline.
|
|
153
|
-
async with await vs.
|
|
154
|
-
feeder = asyncio.create_task(pace_realtime(stream, pcm)) # then eof(), which ends the
|
|
153
|
+
async with await vs.transcriptions.publish(grant, ready_deadline_s=180) as stream:
|
|
154
|
+
feeder = asyncio.create_task(pace_realtime(stream, pcm)) # then eof(), which ends the transcription
|
|
155
155
|
async for event in stream:
|
|
156
156
|
if event.type == "transcript.committed":
|
|
157
157
|
print(f"[speaker {event.segment.speaker}] {event.segment.text}", flush=True)
|
|
158
158
|
await feeder
|
|
159
159
|
|
|
160
|
-
# To end
|
|
161
|
-
|
|
160
|
+
# To end it without eof(): vs.transcriptions.pause(tx.id), then vs.transcriptions.stop(tx.id).
|
|
161
|
+
# A stopped transcription cannot be started again: create a new one.
|
|
162
|
+
snap = await vs.transcriptions.transcript(tx.id)
|
|
162
163
|
print("final:", " ".join(s.text for s in snap.sentences))
|
|
163
164
|
|
|
164
165
|
asyncio.run(main(sys.argv[1]))
|
|
@@ -177,7 +178,7 @@ async def main(q): # 2+ characters
|
|
|
177
178
|
async with VocalStack(os.environ.get("VOCALSTACK_BASE_URL"), api_key=os.environ["VOCALSTACK_API_KEY"]) as vs:
|
|
178
179
|
res = await vs.search.query(q, limit=5)
|
|
179
180
|
for h in res.hits:
|
|
180
|
-
print(f"{h.link_name} @ {h.media_start:.1f}s [speaker {h.speaker}]: {h.text} (
|
|
181
|
+
print(f"{h.link_name} @ {h.media_start:.1f}s [speaker {h.speaker}]: {h.text} (transcription {h.transcription_id})")
|
|
181
182
|
|
|
182
183
|
asyncio.run(main(sys.argv[1]))
|
|
183
184
|
```
|
|
@@ -225,10 +226,11 @@ except VocalStackError as e:
|
|
|
225
226
|
|
|
226
227
|
## More
|
|
227
228
|
|
|
228
|
-
- The other groups: `vs.transcriptions` (`list`, `get`, `update`, `archive`,
|
|
229
|
-
`restore`, `purge`, `list_share_links`, `create_share_link`, `list_scripts
|
|
230
|
-
|
|
231
|
-
`
|
|
229
|
+
- The other groups: `vs.transcriptions` (also `list`, `get`, `update`, `archive`,
|
|
230
|
+
`restore`, `purge`, `list_share_links`, `create_share_link`, `list_scripts`,
|
|
231
|
+
`pause`, `resume`, `stop`, `summarize`, `summary`, `translation`, `audio`,
|
|
232
|
+
`subscribe`, `history`, `corrections`, `apply_corrections`, `request_voice`),
|
|
233
|
+
`vs.corrections` (`revert`), `vs.share_links`, `vs.speakers`, `vs.voices`, `vs.broadcasts`,
|
|
232
234
|
`vs.me` (`get`, `usage`), `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
|
|
233
235
|
Each method is its operation's name in the OpenAPI document, in snake_case
|
|
234
236
|
(`transcriptions.create` is `POST /v1/transcriptions`).
|
|
@@ -10,7 +10,6 @@ from ._models import (
|
|
|
10
10
|
DraftSegment,
|
|
11
11
|
Health,
|
|
12
12
|
PublishGrant,
|
|
13
|
-
Recording,
|
|
14
13
|
SearchResults,
|
|
15
14
|
ServerFrame,
|
|
16
15
|
SessionOptions,
|
|
@@ -30,7 +29,7 @@ from .errors import VocalStackError
|
|
|
30
29
|
from .realtime import RealtimeTranscript
|
|
31
30
|
from .realtime import RealtimeSession, pace_realtime
|
|
32
31
|
|
|
33
|
-
__version__ = "1.0.
|
|
32
|
+
__version__ = "1.0.0a13"
|
|
34
33
|
|
|
35
34
|
__all__ = [
|
|
36
35
|
"DEFAULT_BASE_URL",
|
|
@@ -42,7 +41,6 @@ __all__ = [
|
|
|
42
41
|
"Health",
|
|
43
42
|
"PublishGrant",
|
|
44
43
|
"RealtimeTranscript",
|
|
45
|
-
"Recording",
|
|
46
44
|
"SearchResults",
|
|
47
45
|
"ServerFrame",
|
|
48
46
|
"SessionOptions",
|