vocalstack 1.0.0a8__tar.gz → 1.0.0a9__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.0a8 → vocalstack-1.0.0a9}/PKG-INFO +1 -1
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/pyproject.toml +1 -1
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/src/vocalstack/__init__.py +1 -1
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/src/vocalstack/_models.py +84 -1
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/src/vocalstack/client.py +2 -0
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/src/vocalstack/resources.py +87 -0
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/.gitignore +0 -0
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/LICENSE +0 -0
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/README.md +0 -0
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/SKILL.md +0 -0
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/skills/vocalstack/SKILL.md +0 -0
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/src/vocalstack/_http.py +0 -0
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/src/vocalstack/errors.py +0 -0
- {vocalstack-1.0.0a8 → vocalstack-1.0.0a9}/src/vocalstack/realtime.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.0a9
|
|
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
|
|
@@ -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.0a9"
|
|
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"
|
|
@@ -16,6 +16,8 @@ Access = Literal["public", "private"]
|
|
|
16
16
|
|
|
17
17
|
ErrorCode = Literal["invalid_audio", "invalid_options", "invalid_token", "capacity_exceeded", "slow_consumer", "engine_unavailable", "internal", "session_expired", "engine_lost", "forbidden", "broadcast_archived", "not_found", "conflict", "invalid_state", "password_required", "rate_limited", "preview_pending", "language_unavailable", "suspended", "key_expired", "key_revoked", "key_from_browser", "insufficient_credit", "usage_cap_reached", "payment_method_required", "terms_acceptance_required", "payment_method_in_use", "billing_details_required", "promo_code_invalid", "auto_top_up_off", "range_too_long", "quota_exceeded", "idempotency_key_reused", "method_not_allowed", "payload_too_large", "unsupported_media_type", "invalid_body", "timeout", "language_limit_reached", "unavailable"]
|
|
18
18
|
|
|
19
|
+
SampleWarning = Literal["overlaps", "noisy", "weak_voice", "unclear", "cut_off"]
|
|
20
|
+
|
|
19
21
|
AudioEncoding = Literal["pcm_f32le"]
|
|
20
22
|
|
|
21
23
|
FixKind = Literal["extension", "scheme", "page_stream"]
|
|
@@ -46,6 +48,8 @@ DoneReason = Literal["eof", "max_duration", "cancelled"]
|
|
|
46
48
|
|
|
47
49
|
ExportFormat = Literal["json", "srt", "xlsx", "pdf"]
|
|
48
50
|
|
|
51
|
+
FileUploadState = Literal["uploading", "complete"]
|
|
52
|
+
|
|
49
53
|
HealthStatus = Literal["ok"]
|
|
50
54
|
|
|
51
55
|
IngestState = Literal["connecting", "streaming", "reconnecting", "stopped", "failed"]
|
|
@@ -140,6 +144,40 @@ class AppStreamKey(_Base):
|
|
|
140
144
|
name: str
|
|
141
145
|
|
|
142
146
|
|
|
147
|
+
class PickedSamples(_Base):
|
|
148
|
+
"""Whether a set of samples holds enough speech to build a voice from."""
|
|
149
|
+
|
|
150
|
+
enough: bool
|
|
151
|
+
needed_s: float = Field(alias="neededS")
|
|
152
|
+
pitched_s: float = Field(alias="pitchedS")
|
|
153
|
+
seconds: float
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class SampleCandidate(_Base):
|
|
157
|
+
"""One sentence of a speaker that a voice could be cloned from."""
|
|
158
|
+
|
|
159
|
+
chosen: bool
|
|
160
|
+
end: float
|
|
161
|
+
snr_db: Optional[float] = Field(default=None, alias="snrDb")
|
|
162
|
+
speech_s: Optional[float] = Field(default=None, alias="speechS")
|
|
163
|
+
start: float
|
|
164
|
+
text: str
|
|
165
|
+
voiced: Optional[float] = None
|
|
166
|
+
warning: Optional[SampleWarning] = None
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class AppearanceSamples(_Base):
|
|
170
|
+
"""A speaker's sentences in one recording, judged as samples for a cloned
|
|
171
|
+
voice, and the ones the server would use."""
|
|
172
|
+
|
|
173
|
+
appearance: int
|
|
174
|
+
chosen_s: float = Field(alias="chosenS")
|
|
175
|
+
chosen_speech_s: float = Field(alias="chosenSpeechS")
|
|
176
|
+
picked: Optional["PickedSamples"] = None
|
|
177
|
+
recording_id: str = Field(alias="recordingId")
|
|
178
|
+
samples: List["SampleCandidate"]
|
|
179
|
+
|
|
180
|
+
|
|
143
181
|
class CloneRef(_Base):
|
|
144
182
|
id: str
|
|
145
183
|
|
|
@@ -689,6 +727,15 @@ class CommittedSegment(_Base):
|
|
|
689
727
|
words: List["Word"]
|
|
690
728
|
|
|
691
729
|
|
|
730
|
+
class FileUploadedPart(_Base):
|
|
731
|
+
etag: str
|
|
732
|
+
number: int
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
class CompleteFileUpload(_Base):
|
|
736
|
+
parts: List["FileUploadedPart"]
|
|
737
|
+
|
|
738
|
+
|
|
692
739
|
class Correction(_Base):
|
|
693
740
|
actor: "Actor"
|
|
694
741
|
applied_at: str = Field(alias="appliedAt")
|
|
@@ -768,6 +815,12 @@ class CreateCheckout(_Base):
|
|
|
768
815
|
waive_withdrawal: Optional[bool] = Field(default=None, alias="waiveWithdrawal")
|
|
769
816
|
|
|
770
817
|
|
|
818
|
+
class CreateFileUpload(_Base):
|
|
819
|
+
bytes: int
|
|
820
|
+
mime: Optional[str] = None
|
|
821
|
+
name: str
|
|
822
|
+
|
|
823
|
+
|
|
771
824
|
class CreateLiveTranscription(_Base):
|
|
772
825
|
"""`POST /v1/transcriptions/live`: a transcription captured as it is
|
|
773
826
|
spoken — this device's microphone, or a stream the server pulls.
|
|
@@ -854,6 +907,7 @@ multipart upload whose `file` part carries the media."""
|
|
|
854
907
|
settings: Optional["SettingsPatch"] = None
|
|
855
908
|
share_link: Optional[bool] = Field(default=None, alias="shareLink")
|
|
856
909
|
start_s: Optional[float] = Field(default=None, alias="startS")
|
|
910
|
+
upload_id: Optional[str] = Field(default=None, alias="uploadId")
|
|
857
911
|
url: Optional[str] = None
|
|
858
912
|
|
|
859
913
|
|
|
@@ -895,6 +949,23 @@ class EventOptions(_Base):
|
|
|
895
949
|
words: Optional[bool] = None
|
|
896
950
|
|
|
897
951
|
|
|
952
|
+
class FileUploadPart(_Base):
|
|
953
|
+
bytes: int
|
|
954
|
+
number: int
|
|
955
|
+
url: str
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
class FileUpload(_Base):
|
|
959
|
+
bytes: int
|
|
960
|
+
expires_at: str = Field(alias="expiresAt")
|
|
961
|
+
id: str
|
|
962
|
+
mime: Optional[str] = None
|
|
963
|
+
name: str
|
|
964
|
+
part_bytes: int = Field(alias="partBytes")
|
|
965
|
+
parts: Optional[List["FileUploadPart"]] = None
|
|
966
|
+
state: FileUploadState
|
|
967
|
+
|
|
968
|
+
|
|
898
969
|
class Fix(_Base):
|
|
899
970
|
"""One word-level correction inside a `transcript.amended` frame."""
|
|
900
971
|
|
|
@@ -1965,12 +2036,14 @@ class TranscriptTranslated(_Base):
|
|
|
1965
2036
|
|
|
1966
2037
|
class TranscriptVoice(_Base):
|
|
1967
2038
|
audio: Optional[str] = None
|
|
2039
|
+
caf_url: Optional[str] = Field(default=None, alias="cafUrl")
|
|
1968
2040
|
cloned: Optional[bool] = None
|
|
1969
2041
|
duration_s: float = Field(alias="durationS")
|
|
1970
2042
|
format: str
|
|
1971
2043
|
generation: int
|
|
1972
2044
|
lang: str
|
|
1973
2045
|
latency_s: Optional[float] = Field(default=None, alias="latencyS")
|
|
2046
|
+
ogg_url: Optional[str] = Field(default=None, alias="oggUrl")
|
|
1974
2047
|
part: Optional[int] = None
|
|
1975
2048
|
parts: Optional[int] = None
|
|
1976
2049
|
queue_wait_s: Optional[float] = Field(default=None, alias="queueWaitS")
|
|
@@ -2176,6 +2249,16 @@ class JobProgress(_Base):
|
|
|
2176
2249
|
type: Literal["job.progress"] = "job.progress"
|
|
2177
2250
|
|
|
2178
2251
|
|
|
2252
|
+
class SpeakerVoice(_Base):
|
|
2253
|
+
error: Optional[str] = None
|
|
2254
|
+
progress: int
|
|
2255
|
+
recording_id: str = Field(alias="recordingId")
|
|
2256
|
+
speaker: int
|
|
2257
|
+
speaker_id: Optional[str] = Field(default=None, alias="speakerId")
|
|
2258
|
+
state: str
|
|
2259
|
+
type: Literal["speaker.voice"] = "speaker.voice"
|
|
2260
|
+
|
|
2261
|
+
|
|
2179
2262
|
class StreamIngest(_Base):
|
|
2180
2263
|
detected: Optional[str] = None
|
|
2181
2264
|
error: Optional[str] = None
|
|
@@ -2206,7 +2289,7 @@ class SubscribeGap(_Base):
|
|
|
2206
2289
|
type: Literal["subscribe.gap"] = "subscribe.gap"
|
|
2207
2290
|
|
|
2208
2291
|
|
|
2209
|
-
SubscriberFrame = Annotated[Union[SubscribeReady, RecordingState, RecordingSettings, RecordingSilence, RecordingExpiring, TranscriptCorrected, TranscriptSpeakerGender, TranscriptSpeakerIdentified, TranscriptSpeakerNamed, TranscriptSpeakerNumbers, RecordingStarted, JobProgress, StreamIngest, RecordingEnded, Audience, SubscribeGap], Field(discriminator="type")]
|
|
2292
|
+
SubscriberFrame = Annotated[Union[SubscribeReady, RecordingState, RecordingSettings, RecordingSilence, RecordingExpiring, TranscriptCorrected, TranscriptSpeakerGender, TranscriptSpeakerIdentified, TranscriptSpeakerNamed, TranscriptSpeakerNumbers, RecordingStarted, JobProgress, SpeakerVoice, StreamIngest, RecordingEnded, Audience, SubscribeGap], Field(discriminator="type")]
|
|
2210
2293
|
|
|
2211
2294
|
SERVER_FRAME_TYPES = frozenset(["session.loading", "session.queued", "session.ready", "transcript.committed", "transcript.draft", "transcript.words", "transcript.amended", "transcript.latency", "transcript.speaker", "transcript.speakerGender", "transcript.speakerIdentified", "transcript.speakerNumbers", "transcript.sentence", "transcript.translated", "transcript.voice", "transcript.voiceStatus", "transcript.languageStatus", "transcript.retracted", "transcript.held", "transcript.progress", "stream.pull", "source.progress", "source.prepared", "session.done", "error"])
|
|
2212
2295
|
|
|
@@ -44,6 +44,7 @@ from .resources import (
|
|
|
44
44
|
Speakers,
|
|
45
45
|
Tags,
|
|
46
46
|
Transcriptions,
|
|
47
|
+
Uploads,
|
|
47
48
|
Voices,
|
|
48
49
|
)
|
|
49
50
|
from .realtime import DEFAULT_READY_DEADLINE_S
|
|
@@ -84,6 +85,7 @@ class VocalStack:
|
|
|
84
85
|
self.realtime = Realtime(t, ready_deadline_s)
|
|
85
86
|
self.broadcasts = Broadcasts(t)
|
|
86
87
|
self.transcriptions = Transcriptions(t)
|
|
88
|
+
self.uploads = Uploads(t)
|
|
87
89
|
self.recordings = Recordings(t, ready_deadline_s)
|
|
88
90
|
self.jobs = Jobs(t)
|
|
89
91
|
self.corrections = Corrections(t)
|
|
@@ -10,6 +10,7 @@ import os
|
|
|
10
10
|
import time
|
|
11
11
|
from typing import IO, TYPE_CHECKING, Any, Callable, Dict, List, Optional, Type, TypeVar, Union
|
|
12
12
|
|
|
13
|
+
import httpx
|
|
13
14
|
import websockets
|
|
14
15
|
from pydantic import BaseModel
|
|
15
16
|
|
|
@@ -728,6 +729,76 @@ class Tags(_Group):
|
|
|
728
729
|
return _one(m.Tag, await self._t.json("POST", f"/v1/tags/{_p(id)}/transcriptions", json_body=body))
|
|
729
730
|
|
|
730
731
|
|
|
732
|
+
class Uploads(_Group):
|
|
733
|
+
"""``vs.uploads``: files sent straight to storage in parts, then
|
|
734
|
+
transcribed with ``vs.transcriptions.create(upload_id=...)``."""
|
|
735
|
+
|
|
736
|
+
async def create(self, name: str, *, bytes: int, mime: Optional[str] = None) -> m.FileUpload:
|
|
737
|
+
body = _body(m.CreateFileUpload, {"name": name, "bytes": bytes, "mime": mime})
|
|
738
|
+
return _one(m.FileUpload, await self._t.json("POST", "/v1/uploads", json_body=body))
|
|
739
|
+
|
|
740
|
+
async def complete(self, id: str, parts: List[Dict[str, Any]]) -> m.FileUpload:
|
|
741
|
+
body = _body(m.CompleteFileUpload, {"parts": parts})
|
|
742
|
+
return _one(m.FileUpload, await self._t.json("POST", f"/v1/uploads/{_p(id)}/complete", json_body=body))
|
|
743
|
+
|
|
744
|
+
async def send(
|
|
745
|
+
self,
|
|
746
|
+
file: Upload,
|
|
747
|
+
*,
|
|
748
|
+
file_name: Optional[str] = None,
|
|
749
|
+
mime: Optional[str] = None,
|
|
750
|
+
concurrency: int = 4,
|
|
751
|
+
on_progress: Optional[Callable[[int, int], Any]] = None,
|
|
752
|
+
) -> m.FileUpload:
|
|
753
|
+
"""Create an upload, PUT every part to its link (no credential), and
|
|
754
|
+
complete it. A path is read a part at a time."""
|
|
755
|
+
path: Optional[str] = None
|
|
756
|
+
data: Optional[bytes] = None
|
|
757
|
+
if isinstance(file, (str, os.PathLike)):
|
|
758
|
+
path = os.fspath(file)
|
|
759
|
+
size = os.path.getsize(path)
|
|
760
|
+
name = file_name or os.path.basename(path)
|
|
761
|
+
else:
|
|
762
|
+
name, data = _file_part(file, file_name, "upload")
|
|
763
|
+
size = len(data)
|
|
764
|
+
up = await self.create(name, bytes=size, mime=mime)
|
|
765
|
+
sent: Dict[int, int] = {}
|
|
766
|
+
etags: Dict[int, str] = {}
|
|
767
|
+
gate = asyncio.Semaphore(max(1, concurrency))
|
|
768
|
+
|
|
769
|
+
def chunk(start: int, n: int) -> bytes:
|
|
770
|
+
if data is not None:
|
|
771
|
+
return data[start : start + n]
|
|
772
|
+
with open(path, "rb") as fh: # type: ignore[arg-type]
|
|
773
|
+
fh.seek(start)
|
|
774
|
+
return fh.read(n)
|
|
775
|
+
|
|
776
|
+
async def one(part: m.FileUploadPart) -> None:
|
|
777
|
+
async with gate:
|
|
778
|
+
body = chunk((part.number - 1) * up.part_bytes, part.bytes)
|
|
779
|
+
for attempt in range(3):
|
|
780
|
+
try:
|
|
781
|
+
resp = await self._t.http.put(part.url, content=body)
|
|
782
|
+
except httpx.TransportError:
|
|
783
|
+
if attempt == 2:
|
|
784
|
+
raise VocalStackError("unavailable", f"part {part.number} could not reach storage", retryable=True)
|
|
785
|
+
continue
|
|
786
|
+
if resp.status_code < 300:
|
|
787
|
+
etag = resp.headers.get("etag")
|
|
788
|
+
if not etag:
|
|
789
|
+
raise VocalStackError("unavailable", f"part {part.number} was sent but storage gave no ETag")
|
|
790
|
+
etags[part.number] = etag
|
|
791
|
+
sent[part.number] = part.bytes
|
|
792
|
+
if on_progress:
|
|
793
|
+
on_progress(sum(sent.values()), size)
|
|
794
|
+
return
|
|
795
|
+
if resp.status_code < 500 or attempt == 2:
|
|
796
|
+
raise VocalStackError("invalid_state", f"storage refused part {part.number} ({resp.status_code})")
|
|
797
|
+
|
|
798
|
+
await asyncio.gather(*(one(p) for p in (up.parts or [])))
|
|
799
|
+
return await self.complete(up.id, [{"number": n, "etag": e} for n, e in sorted(etags.items())])
|
|
800
|
+
|
|
801
|
+
|
|
731
802
|
class Voices(_Group):
|
|
732
803
|
"""``vs.voices``: the voices a language offers, and how each sounds."""
|
|
733
804
|
|
|
@@ -846,6 +917,22 @@ class Speakers(_Group):
|
|
|
846
917
|
data = await self._t.json("POST", "/v1/speakers/from-appearance", json_body=body, idempotency_key=idempotency_key)
|
|
847
918
|
return _one(m.Speaker, data)
|
|
848
919
|
|
|
920
|
+
async def appearance_samples(
|
|
921
|
+
self, *, transcription_id: str, appearance: int, recording_id: Optional[str] = None, spans: Optional[List[Dict[str, float]]] = None
|
|
922
|
+
) -> m.AppearanceSamples:
|
|
923
|
+
"""A speaker's sentences in a recording judged as samples for a cloned
|
|
924
|
+
voice, and the ones the server would use (``chosen``). Pass the
|
|
925
|
+
``start``/``end`` of the ones you want as ``spans`` to
|
|
926
|
+
``create_from_appearance``. With ``spans``, ``picked`` says whether
|
|
927
|
+
those samples hold enough clear speech to build a voice."""
|
|
928
|
+
picked = ",".join(f"{s['start']}-{s['end']}" for s in spans) if spans else None
|
|
929
|
+
data = await self._t.json(
|
|
930
|
+
"GET",
|
|
931
|
+
"/v1/speakers/from-appearance/samples",
|
|
932
|
+
query={"transcriptionId": transcription_id, "recordingId": recording_id, "appearance": appearance, "spans": picked},
|
|
933
|
+
)
|
|
934
|
+
return _one(m.AppearanceSamples, data)
|
|
935
|
+
|
|
849
936
|
async def set_consent(self, id: str, consent: str, *, name: Optional[str] = None) -> m.Speaker:
|
|
850
937
|
"""Record whether the speaker agreed to their clone: ``granted`` (with an
|
|
851
938
|
optional name) makes their voice speak; ``refused`` deletes its audio
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|