vocalstack 1.0.0a3__tar.gz → 1.0.0a5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: vocalstack
3
- Version: 1.0.0a3
3
+ Version: 1.0.0a5
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
@@ -69,13 +69,13 @@ pip install vocalstack
69
69
  | recording | one take inside a broadcast or a transcription | `vs.recordings` |
70
70
  | job | a file or link recording's transcription work | `vs.jobs` |
71
71
 
72
- The other groups: `vs.corrections`, `vs.share_links`, `vs.voices`,
73
- `vs.search`, `vs.me`, `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
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
74
  Method names are the document's `operationId`s in snake_case
75
75
  (`broadcasts.start_recording` is `POST /v1/broadcasts/{id}/recordings`).
76
76
  Request fields are keyword arguments, in snake_case or the wire's camelCase
77
77
  (`settings={"spokenLanguage": "en"}`); lists return lists; binary answers
78
- (`recordings.export`, `recordings.clip`, `voices.sample`, ...) return bytes.
78
+ (`recordings.export`, `recordings.clip`, `speakers.sample`, ...) return bytes.
79
79
 
80
80
  ```python
81
81
  VocalStack(
@@ -56,13 +56,13 @@ pip install vocalstack
56
56
  | recording | one take inside a broadcast or a transcription | `vs.recordings` |
57
57
  | job | a file or link recording's transcription work | `vs.jobs` |
58
58
 
59
- The other groups: `vs.corrections`, `vs.share_links`, `vs.voices`,
60
- `vs.search`, `vs.me`, `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
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
61
  Method names are the document's `operationId`s in snake_case
62
62
  (`broadcasts.start_recording` is `POST /v1/broadcasts/{id}/recordings`).
63
63
  Request fields are keyword arguments, in snake_case or the wire's camelCase
64
64
  (`settings={"spokenLanguage": "en"}`); lists return lists; binary answers
65
- (`recordings.export`, `recordings.clip`, `voices.sample`, ...) return bytes.
65
+ (`recordings.export`, `recordings.clip`, `speakers.sample`, ...) return bytes.
66
66
 
67
67
  ```python
68
68
  VocalStack(
@@ -226,9 +226,9 @@ except VocalStackError as e:
226
226
  ## More
227
227
 
228
228
  - The other groups: `vs.transcriptions` (`list`, `get`, `update`, `archive`,
229
- `restore`, `purge`, `list_share_links`, `create_share_link`), `vs.recordings`
229
+ `restore`, `purge`, `list_share_links`, `create_share_link`, `list_scripts`), `vs.recordings`
230
230
  (`get`, `summarize`, `summary`, `translation`, `audio_url`, `subscribe`),
231
- `vs.corrections`, `vs.share_links`, `vs.voices`, `vs.broadcasts`,
231
+ `vs.corrections`, `vs.share_links`, `vs.speakers`, `vs.voices`, `vs.broadcasts`,
232
232
  `vs.me` (`get`, `usage`), `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
233
233
  Each method is its operation's name in the OpenAPI document, in snake_case
234
234
  (`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.0a3"
7
+ version = "1.0.0a5"
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"
@@ -226,9 +226,9 @@ except VocalStackError as e:
226
226
  ## More
227
227
 
228
228
  - The other groups: `vs.transcriptions` (`list`, `get`, `update`, `archive`,
229
- `restore`, `purge`, `list_share_links`, `create_share_link`), `vs.recordings`
229
+ `restore`, `purge`, `list_share_links`, `create_share_link`, `list_scripts`), `vs.recordings`
230
230
  (`get`, `summarize`, `summary`, `translation`, `audio_url`, `subscribe`),
231
- `vs.corrections`, `vs.share_links`, `vs.voices`, `vs.broadcasts`,
231
+ `vs.corrections`, `vs.share_links`, `vs.speakers`, `vs.voices`, `vs.broadcasts`,
232
232
  `vs.me` (`get`, `usage`), `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
233
233
  Each method is its operation's name in the OpenAPI document, in snake_case
234
234
  (`transcriptions.create` is `POST /v1/transcriptions`).
@@ -30,7 +30,7 @@ from .errors import VocalStackError
30
30
  from .realtime import RealtimeTranscript
31
31
  from .realtime import RealtimeSession, pace_realtime
32
32
 
33
- __version__ = "1.0.0a3"
33
+ __version__ = "1.0.0a5"
34
34
 
35
35
  __all__ = [
36
36
  "DEFAULT_BASE_URL",
@@ -140,6 +140,25 @@ class AppStreamKey(_Base):
140
140
  name: str
141
141
 
142
142
 
143
+ class CloneRef(_Base):
144
+ id: str
145
+
146
+
147
+ class AppearanceView(_Base):
148
+ gender: Optional[str] = None
149
+ gender_confidence: Optional[float] = Field(default=None, alias="genderConfidence")
150
+ identified: Optional[bool] = None
151
+ identified_confidence: Optional[float] = Field(default=None, alias="identifiedConfidence")
152
+ name: str
153
+ number: Optional[int] = None
154
+ returning: Optional[bool] = None
155
+ speaker: int
156
+ speaker_color: Optional[str] = Field(default=None, alias="speakerColor")
157
+ speaker_id: Optional[str] = Field(default=None, alias="speakerId")
158
+ speech_s: Optional[float] = Field(default=None, alias="speechS")
159
+ voice: Optional["CloneRef"] = None
160
+
161
+
143
162
  class AudioCapabilities(_Base):
144
163
  channels: List[int]
145
164
  encodings: List[AudioEncoding]
@@ -274,9 +293,9 @@ class Limits2(_Base):
274
293
  questions_per_day: Optional[int] = Field(default=None, alias="questionsPerDay")
275
294
  requests_per_min: Optional[int] = Field(default=None, alias="requestsPerMin")
276
295
  retention_audio_days: Optional[int] = Field(default=None, alias="retentionAudioDays")
296
+ retention_speakers_days: Optional[int] = Field(default=None, alias="retentionSpeakersDays")
277
297
  retention_transcriptions_days: Optional[int] = Field(default=None, alias="retentionTranscriptionsDays")
278
298
  retention_video_days: Optional[int] = Field(default=None, alias="retentionVideoDays")
279
- retention_voices_days: Optional[int] = Field(default=None, alias="retentionVoicesDays")
280
299
  vector_searches_per_hour: Optional[int] = Field(default=None, alias="vectorSearchesPerHour")
281
300
 
282
301
 
@@ -632,6 +651,22 @@ class ClientPolicy(_Base):
632
651
  unsupported_below: Optional[str] = Field(default=None, alias="unsupportedBelow")
633
652
 
634
653
 
654
+ class Clone(_Base):
655
+ """A speaker's cloned voice: the sound, built from the speaker's sample.
656
+ Its id is the speaker's, so `clone:<id>` names it as a voice."""
657
+
658
+ disabled_at: Optional[str] = Field(default=None, alias="disabledAt")
659
+ enabled: bool
660
+ error: Optional[str] = None
661
+ id: str
662
+ preview_url: Optional[str] = Field(default=None, alias="previewUrl")
663
+ progress: int
664
+ sample_s: float = Field(alias="sampleS")
665
+ speech_s: Optional[float] = Field(default=None, alias="speechS")
666
+ state: str
667
+ uses: int
668
+
669
+
635
670
  class CommittedSegment(_Base):
636
671
  catchup: Optional[bool] = None
637
672
  confidence: Optional[float] = None
@@ -757,6 +792,32 @@ class CreateShareLink(_Base):
757
792
  label: str
758
793
 
759
794
 
795
+ class CreateSpeaker(_Base):
796
+ color: Optional[str] = None
797
+ consent: Optional[bool] = None
798
+ draft: Optional[bool] = None
799
+ gender: Optional[str] = None
800
+ name: str
801
+ sample_url: Optional[str] = Field(default=None, alias="sampleUrl")
802
+
803
+
804
+ class SampleSpan(_Base):
805
+ end: float
806
+ start: float
807
+
808
+
809
+ class CreateSpeakerFromAppearance(_Base):
810
+ appearance: int
811
+ color: Optional[str] = None
812
+ consent: Optional[bool] = None
813
+ draft: Optional[bool] = None
814
+ library: Optional[bool] = None
815
+ name: str
816
+ recording_id: Optional[str] = Field(default=None, alias="recordingId")
817
+ spans: Optional[List["SampleSpan"]] = None
818
+ transcription_id: str = Field(alias="transcriptionId")
819
+
820
+
760
821
  class CreateTag(_Base):
761
822
  color: Optional[Literal["coral", "amber", "lime", "green", "teal", "blue", "violet", "pink"]] = None
762
823
  name: str
@@ -796,31 +857,6 @@ multipart upload whose `file` part carries the media."""
796
857
  url: Optional[str] = None
797
858
 
798
859
 
799
- class CreateVoice(_Base):
800
- color: Optional[str] = None
801
- consent: Optional[bool] = None
802
- draft: Optional[bool] = None
803
- gender: Optional[str] = None
804
- name: str
805
- sample_url: Optional[str] = Field(default=None, alias="sampleUrl")
806
-
807
-
808
- class SampleSpan(_Base):
809
- end: float
810
- start: float
811
-
812
-
813
- class CreateVoiceFromSpeaker(_Base):
814
- color: Optional[str] = None
815
- consent: Optional[bool] = None
816
- draft: Optional[bool] = None
817
- library: Optional[bool] = None
818
- name: str
819
- recording_id: str = Field(alias="recordingId")
820
- spans: Optional[List["SampleSpan"]] = None
821
- speaker: int
822
-
823
-
824
860
  class CreatedAppStreamKey(_Base):
825
861
  """The answer that made an app stream key: the one time it is in full."""
826
862
 
@@ -897,15 +933,14 @@ class JobQueue(_Base):
897
933
  reason: QueueReason
898
934
 
899
935
 
900
- class KnownVoice(_Base):
901
- """One voice a realtime session may recognise a speaker as.
936
+ class KnownSpeaker(_Base):
937
+ """One saved speaker a realtime session may recognise a speaker as.
902
938
 
903
- The `id` is a cloned voice's id; the engine loads its embedding from
904
- the same place it loads the voice itself, so a caller names the voice
905
- and never carries a vector over the wire. `name` is what to call the
906
- person when they are recognised — the voice's own name, ordinarily,
907
- but the caller's to choose, because a voice called "Marcus —
908
- narration" belongs to a person called Marcus Reed."""
939
+ The `id` is a saved speaker's id (`GET /v1/speakers`); the server
940
+ supplies their fingerprint, so a caller names the speaker and never
941
+ carries a vector over the wire. `name` is what to call the person
942
+ when they are recognised — the speaker's own name, ordinarily, but the
943
+ caller's to choose."""
909
944
 
910
945
  color: Optional[str] = None
911
946
  id: str
@@ -1037,7 +1072,7 @@ model as context, with `mediaStart` to cite or play the moment."""
1037
1072
  text: str
1038
1073
 
1039
1074
 
1040
- class PatchVoice(_Base):
1075
+ class PatchSpeaker(_Base):
1041
1076
  color: Optional[str] = None
1042
1077
  consent: Optional[bool] = None
1043
1078
  draft: Optional[bool] = None
@@ -1280,6 +1315,23 @@ class RtmpStatus(_Base):
1280
1315
  stream_key: Optional[str] = Field(default=None, alias="streamKey")
1281
1316
 
1282
1317
 
1318
+ class Script(_Base):
1319
+ """The broadcast or transcription something belongs to (a script, a share
1320
+ link): exactly one of `broadcastId` and `transcriptionId` is set.
1321
+ Flattened into its owner."""
1322
+
1323
+ broadcast_id: Optional[str] = Field(default=None, alias="broadcastId")
1324
+ created_at: str = Field(alias="createdAt")
1325
+ id: str
1326
+ locked: bool
1327
+ recording_id: Optional[str] = Field(default=None, alias="recordingId")
1328
+ scheduled_at: Optional[str] = Field(default=None, alias="scheduledAt")
1329
+ text: str
1330
+ transcription_id: Optional[str] = Field(default=None, alias="transcriptionId")
1331
+ updated_at: str = Field(alias="updatedAt")
1332
+ word_count: int = Field(alias="wordCount")
1333
+
1334
+
1283
1335
  class SearchHit(_Base):
1284
1336
  link_code: str = Field(alias="linkCode")
1285
1337
  link_name: str = Field(alias="linkName")
@@ -1371,6 +1423,7 @@ class SentenceView(_Base):
1371
1423
  class SpeakerNumber(_Base):
1372
1424
  name: Optional[str] = None
1373
1425
  number: int
1426
+ returning: Optional[bool] = None
1374
1427
  speaker: int
1375
1428
 
1376
1429
 
@@ -1383,7 +1436,7 @@ class SessionStats(_Base):
1383
1436
  class SessionOptions(_Base):
1384
1437
  audio: Optional["AudioFormat"] = None
1385
1438
  events: Optional["EventOptions"] = None
1386
- identify_voices: Optional[List["KnownVoice"]] = Field(default=None, alias="identifyVoices")
1439
+ identify_speakers: Optional[List["KnownSpeaker"]] = Field(default=None, alias="identifySpeakers")
1387
1440
  input: Optional["InputOptions"] = None
1388
1441
  latency_mode: Optional[LatencyMode] = Field(default=None, alias="latencyMode")
1389
1442
  sentences: Optional["SentenceOptions"] = None
@@ -1397,8 +1450,8 @@ class SessionOptions(_Base):
1397
1450
 
1398
1451
 
1399
1452
  class SetConsent(_Base):
1400
- """`POST /v1/voices/:id/consent`: the owner records whether the speaker
1401
- agreed to their clone."""
1453
+ """`POST /v1/speakers/{id}/consent`: the owner records whether the speaker
1454
+ agreed to have their voice cloned."""
1402
1455
 
1403
1456
  consent: Consent
1404
1457
  name: Optional[str] = None
@@ -1471,17 +1524,20 @@ plus job state to read from."""
1471
1524
  transcription_id: Optional[str] = Field(default=None, alias="transcriptionId")
1472
1525
 
1473
1526
 
1474
- class SpeakerView(_Base):
1527
+ class Speaker(_Base):
1528
+ archived_at: Optional[str] = Field(default=None, alias="archivedAt")
1529
+ color: Optional[str] = None
1530
+ consent: Consent
1531
+ consent_at: Optional[str] = Field(default=None, alias="consentAt")
1532
+ created_at: str = Field(alias="createdAt")
1533
+ draft: bool
1475
1534
  gender: Optional[str] = None
1476
- gender_confidence: Optional[float] = Field(default=None, alias="genderConfidence")
1477
- identified: Optional[bool] = None
1478
- identified_confidence: Optional[float] = Field(default=None, alias="identifiedConfidence")
1535
+ id: str
1536
+ library: Optional[bool] = None
1479
1537
  name: str
1480
- number: Optional[int] = None
1481
- speaker: int
1482
- speech_s: Optional[float] = Field(default=None, alias="speechS")
1483
- voice_color: Optional[str] = Field(default=None, alias="voiceColor")
1484
- voice_id: Optional[str] = Field(default=None, alias="voiceId")
1538
+ recording_id: Optional[str] = Field(default=None, alias="recordingId")
1539
+ updated_at: str = Field(alias="updatedAt")
1540
+ voice: Optional["Clone"] = None
1485
1541
 
1486
1542
 
1487
1543
  class StartJob(_Base):
@@ -1549,7 +1605,7 @@ class TranscriptSnapshot(_Base):
1549
1605
  sentences: List["SentenceView"]
1550
1606
  spans: List["CaptureSpan"]
1551
1607
  speaker_labels: Optional[SpeakerLabels] = Field(default=None, alias="speakerLabels")
1552
- speakers: List["SpeakerView"]
1608
+ speakers: List["AppearanceView"]
1553
1609
  state: RecordingState
1554
1610
  translation_pending: Optional[bool] = Field(default=None, alias="translationPending")
1555
1611
 
@@ -1723,32 +1779,6 @@ class VectorResults(_Base):
1723
1779
  state: str
1724
1780
 
1725
1781
 
1726
- class Voice(_Base):
1727
- archived_at: Optional[str] = Field(default=None, alias="archivedAt")
1728
- auto: Optional[bool] = None
1729
- color: Optional[str] = None
1730
- consent: Consent
1731
- consent_at: Optional[str] = Field(default=None, alias="consentAt")
1732
- created_at: str = Field(alias="createdAt")
1733
- disabled_at: Optional[str] = Field(default=None, alias="disabledAt")
1734
- draft: bool
1735
- enabled: bool
1736
- error: Optional[str] = None
1737
- gender: Optional[str] = None
1738
- id: str
1739
- library: Optional[bool] = None
1740
- name: str
1741
- preview_url: Optional[str] = Field(default=None, alias="previewUrl")
1742
- progress: int
1743
- recording_id: Optional[str] = Field(default=None, alias="recordingId")
1744
- sample_s: float = Field(alias="sampleS")
1745
- speaker: Optional[int] = None
1746
- speech_s: Optional[float] = Field(default=None, alias="speechS")
1747
- state: str
1748
- updated_at: str = Field(alias="updatedAt")
1749
- uses: int
1750
-
1751
-
1752
1782
  class VoiceOption(_Base):
1753
1783
  accent: Optional[str] = None
1754
1784
  auto: Optional[bool] = None
@@ -1910,9 +1940,9 @@ class TranscriptSpeakerIdentified(_Base):
1910
1940
  confidence: Optional[float] = None
1911
1941
  name: str
1912
1942
  speaker: int
1943
+ speaker_id: Optional[str] = Field(default=None, alias="speakerId")
1913
1944
  tone: Optional[bool] = None
1914
1945
  type: Literal["transcript.speakerIdentified"] = "transcript.speakerIdentified"
1915
- voice_id: Optional[str] = Field(default=None, alias="voiceId")
1916
1946
 
1917
1947
 
1918
1948
  class TranscriptSpeakerNumbers(_Base):
@@ -2106,8 +2136,8 @@ class TranscriptSpeakerIdentified(_Base):
2106
2136
  confidence: Optional[float] = None
2107
2137
  name: str
2108
2138
  speaker: int
2139
+ speaker_id: Optional[str] = Field(default=None, alias="speakerId")
2109
2140
  type: Literal["transcript.speakerIdentified"] = "transcript.speakerIdentified"
2110
- voice_id: Optional[str] = Field(default=None, alias="voiceId")
2111
2141
 
2112
2142
 
2113
2143
  class TranscriptSpeakerNamed(_Base):
@@ -41,6 +41,7 @@ from .resources import (
41
41
  Rtmp,
42
42
  Search,
43
43
  ShareLinks,
44
+ Speakers,
44
45
  Tags,
45
46
  Transcriptions,
46
47
  Voices,
@@ -88,6 +89,7 @@ class VocalStack:
88
89
  self.corrections = Corrections(t)
89
90
  self.share_links = ShareLinks(t)
90
91
  self.tags = Tags(t)
92
+ self.speakers = Speakers(t)
91
93
  self.voices = Voices(t)
92
94
  self.search = Search(t)
93
95
  self.me = Me(t)
@@ -150,6 +150,9 @@ class _ParentResource(_Group):
150
150
  async def list_share_links(self, id: str) -> List[m.ShareLink]:
151
151
  return _many(m.ShareLink, await self._t.json("GET", self._path(id, "/share-links")), "links")
152
152
 
153
+ async def list_scripts(self, id: str) -> List[m.Script]:
154
+ return _many(m.Script, await self._t.json("GET", self._path(id, "/scripts")), "scripts")
155
+
153
156
  async def create_share_link(self, id: str, **fields: Any) -> m.ShareLink:
154
157
  body = _body(m.CreateShareLink, fields)
155
158
  return _one(m.ShareLink, await self._t.json("POST", self._path(id, "/share-links"), json_body=body))
@@ -348,6 +351,11 @@ class Transcriptions(_ParentResource):
348
351
  data = await self._t.json("DELETE", self._path(id, f"/broadcasts/{_p(broadcast_id)}"))
349
352
  return _one(m.Transcription, data)
350
353
 
354
+ async def name_appearance(self, id: str, appearance: int, name: Optional[str]) -> None:
355
+ """Name one speaker of the transcription: ``appearance`` is their
356
+ display number ("Speaker <number>"); ``None`` clears the name."""
357
+ await self._t.json("PUT", self._path(id, f"/appearances/{appearance}"), json_body={"name": name})
358
+
351
359
 
352
360
  class Recordings(_Group):
353
361
  """``vs.recordings``: one take, live or uploaded."""
@@ -556,9 +564,6 @@ class Recordings(_Group):
556
564
  async def media_token(self, id: str) -> Dict[str, Any]:
557
565
  return await self._t.json("GET", self._path(id, "/media-token"))
558
566
 
559
- async def name_speaker(self, id: str, speaker: int, name: Optional[str]) -> None:
560
- await self._t.json("PUT", self._path(id, f"/speakers/{speaker}"), json_body={"name": name})
561
-
562
567
  async def events(self, id: str, *, after: Optional[int] = None, limit: Optional[int] = None) -> List[m.RecordingEvent]:
563
568
  """The durable event log with wall times (owner only): every event
564
569
  after ``after`` (a ``seq``; the whole log without it), read ``limit`` a page."""
@@ -724,29 +729,61 @@ class Tags(_Group):
724
729
 
725
730
 
726
731
  class Voices(_Group):
727
- """``vs.voices``: the account's cloned voices, and what a language offers."""
732
+ """``vs.voices``: the voices a language offers, and how each sounds."""
728
733
 
729
- async def list(self, *, lifecycle: Optional[str] = None) -> List[m.Voice]:
730
- return _many(m.Voice, await self._t.json("GET", "/v1/voices", query={"lifecycle": lifecycle}), "voices")
734
+ async def available(
735
+ self,
736
+ lang: str,
737
+ *,
738
+ recording: Optional[str] = None,
739
+ listener_token: Optional[str] = None,
740
+ share_code: Optional[str] = None,
741
+ as_owner: bool = True,
742
+ ) -> m.VoiceCatalogue:
743
+ """The voices that can speak ``lang``, best first (with a token, also
744
+ the account's ready clones). ``recording`` also offers the cloned
745
+ voices that recording uses, to whoever may read it: its owner, or a
746
+ listener with ``listener_token`` or ``share_code``."""
747
+ data = await self._t.json(
748
+ "GET",
749
+ "/v1/voices/available",
750
+ query={**listener_query(listener_token, share_code), "lang": lang, "recording": recording},
751
+ anonymous=not as_owner,
752
+ )
753
+ return _one(m.VoiceCatalogue, data)
731
754
 
732
- async def get(self, id: str) -> m.Voice:
733
- return _one(m.Voice, await self._t.json("GET", f"/v1/voices/{_p(id)}"))
755
+ async def preview(self, voice: str, lang: str, *, format: Optional[str] = None) -> bytes:
756
+ resp = await self._t.raw(
757
+ "GET", "/v1/voices/preview", headers={"accept": "*/*"}, query={"voice": voice, "lang": lang, "format": format}
758
+ )
759
+ return resp.content
760
+
761
+
762
+ class Speakers(_Group):
763
+ """``vs.speakers``: the account's saved speakers, each with an optional
764
+ cloned voice (``voice``) built from their sample."""
765
+
766
+ async def list(self, *, lifecycle: Optional[str] = None) -> List[m.Speaker]:
767
+ return _many(m.Speaker, await self._t.json("GET", "/v1/speakers", query={"lifecycle": lifecycle}), "speakers")
734
768
 
735
- async def archive(self, id: str) -> m.Voice:
736
- """Put a voice away: it stops speaking and is unlinked from its speakers."""
737
- return _one(m.Voice, await self._t.json("POST", f"/v1/voices/{_p(id)}/archive"))
769
+ async def get(self, id: str) -> m.Speaker:
770
+ return _one(m.Speaker, await self._t.json("GET", f"/v1/speakers/{_p(id)}"))
738
771
 
739
- async def restore(self, id: str) -> m.Voice:
740
- return _one(m.Voice, await self._t.json("POST", f"/v1/voices/{_p(id)}/restore"))
772
+ async def archive(self, id: str) -> m.Speaker:
773
+ """Put a speaker away: their voice stops speaking and they are unlinked from their appearances."""
774
+ return _one(m.Speaker, await self._t.json("POST", f"/v1/speakers/{_p(id)}/archive"))
775
+
776
+ async def restore(self, id: str) -> m.Speaker:
777
+ return _one(m.Speaker, await self._t.json("POST", f"/v1/speakers/{_p(id)}/restore"))
741
778
 
742
779
  async def archive_many(self, ids: List[str]) -> m.ManyResult:
743
- return _one(m.ManyResult, await self._t.json("POST", "/v1/voices/archive", json_body={"ids": ids}))
780
+ return _one(m.ManyResult, await self._t.json("POST", "/v1/speakers/archive", json_body={"ids": ids}))
744
781
 
745
782
  async def restore_many(self, ids: List[str]) -> m.ManyResult:
746
- return _one(m.ManyResult, await self._t.json("POST", "/v1/voices/restore", json_body={"ids": ids}))
783
+ return _one(m.ManyResult, await self._t.json("POST", "/v1/speakers/restore", json_body={"ids": ids}))
747
784
 
748
785
  async def delete_many(self, ids: List[str]) -> m.ManyResult:
749
- return _one(m.ManyResult, await self._t.json("POST", "/v1/voices/delete", json_body={"ids": ids}))
786
+ return _one(m.ManyResult, await self._t.json("POST", "/v1/speakers/delete", json_body={"ids": ids}))
750
787
 
751
788
  async def create(
752
789
  self,
@@ -757,76 +794,75 @@ class Voices(_Group):
757
794
  file_name: Optional[str] = None,
758
795
  gender: Optional[str] = None,
759
796
  color: Optional[str] = None,
760
- draft: bool = False,
797
+ draft: Optional[bool] = None,
798
+ consent: Optional[bool] = None,
761
799
  idempotency_key: Optional[str] = None,
762
- ) -> m.Voice:
763
- """Build a voice from a sample or a link. Calling it asserts you have
764
- the speaker's permission, unless ``draft``."""
800
+ ) -> m.Speaker:
801
+ """Save a speaker from a sample or a link. Without ``consent`` they are
802
+ recognised only (``voice`` is ``None``); ``consent=True`` asserts you
803
+ have their permission and starts training their cloned voice."""
765
804
  meta = _body(
766
- m.CreateVoice,
767
- {"name": name, "sample_url": sample_url, "gender": gender, "color": color, "draft": draft or None, "consent": not draft},
805
+ m.CreateSpeaker,
806
+ {"name": name, "sample_url": sample_url, "gender": gender, "color": color, "draft": draft, "consent": consent},
768
807
  )
769
808
  files: Dict[str, Any] = {"meta": (None, json.dumps(meta), "application/json")}
770
809
  if sample is not None:
771
810
  files["sample"] = await asyncio.to_thread(_file_part, sample, file_name, "sample.webm")
772
- data = await self._t.json("POST", "/v1/voices", files=files, idempotency_key=idempotency_key)
773
- return _one(m.Voice, data)
774
-
775
- async def create_from_speaker(
776
- self, *, recording_id: str, speaker: int, name: str, color: Optional[str] = None, library: Optional[bool] = None, idempotency_key: Optional[str] = None
777
- ) -> m.Voice:
778
- """Build a voice from one speaker of a recording (asserts permission).
779
- ``library=False`` keeps it with that recording only."""
811
+ data = await self._t.json("POST", "/v1/speakers", files=files, idempotency_key=idempotency_key)
812
+ return _one(m.Speaker, data)
813
+
814
+ async def create_from_appearance(
815
+ self,
816
+ *,
817
+ transcription_id: str,
818
+ appearance: int,
819
+ name: str,
820
+ recording_id: Optional[str] = None,
821
+ color: Optional[str] = None,
822
+ consent: Optional[bool] = None,
823
+ spans: Optional[List[Dict[str, float]]] = None,
824
+ draft: Optional[bool] = None,
825
+ library: Optional[bool] = None,
826
+ idempotency_key: Optional[str] = None,
827
+ ) -> m.Speaker:
828
+ """Save a speaker from one appearance of a transcription (``appearance``
829
+ is the ``speaker`` index of their lines). ``consent=True`` asserts
830
+ permission and clones their voice; ``library=False`` keeps them with
831
+ that transcription only."""
780
832
  body = _body(
781
- m.CreateVoiceFromSpeaker,
782
- {"recording_id": recording_id, "speaker": speaker, "name": name, "color": color, "library": library, "consent": True},
833
+ m.CreateSpeakerFromAppearance,
834
+ {
835
+ "transcription_id": transcription_id,
836
+ "recording_id": recording_id,
837
+ "appearance": appearance,
838
+ "name": name,
839
+ "color": color,
840
+ "consent": consent,
841
+ "spans": spans,
842
+ "draft": draft,
843
+ "library": library,
844
+ },
783
845
  )
784
- data = await self._t.json("POST", "/v1/voices/from-speaker", json_body=body, idempotency_key=idempotency_key)
785
- return _one(m.Voice, data)
846
+ data = await self._t.json("POST", "/v1/speakers/from-appearance", json_body=body, idempotency_key=idempotency_key)
847
+ return _one(m.Speaker, data)
786
848
 
787
- async def set_consent(self, id: str, consent: str, *, name: Optional[str] = None) -> m.Voice:
849
+ async def set_consent(self, id: str, consent: str, *, name: Optional[str] = None) -> m.Speaker:
788
850
  """Record whether the speaker agreed to their clone: ``granted`` (with an
789
- optional name, which also names the speaker in its recording) makes it
790
- speak; ``refused`` deletes its audio and voice. Automatic clones start
791
- ``pending``."""
851
+ optional name) makes their voice speak; ``refused`` deletes its audio
852
+ and voice. Automatic clones start ``pending``."""
792
853
  body = _body(m.SetConsent, {"consent": consent, "name": name})
793
- return _one(m.Voice, await self._t.json("POST", f"/v1/voices/{_p(id)}/consent", json_body=body))
854
+ return _one(m.Speaker, await self._t.json("POST", f"/v1/speakers/{_p(id)}/consent", json_body=body))
794
855
 
795
- async def update(self, id: str, **fields: Any) -> m.Voice:
796
- body = _body(m.PatchVoice, fields)
797
- return _one(m.Voice, await self._t.json("PATCH", f"/v1/voices/{_p(id)}", json_body=body))
856
+ async def update(self, id: str, **fields: Any) -> m.Speaker:
857
+ """Rename or recolour; ``enabled`` turns the cloned voice on or off;
858
+ ``consent=True`` on a speaker without a clone starts one from their sample."""
859
+ body = _body(m.PatchSpeaker, fields)
860
+ return _one(m.Speaker, await self._t.json("PATCH", f"/v1/speakers/{_p(id)}", json_body=body))
798
861
 
799
862
  async def delete(self, id: str) -> None:
800
- await self._t.json("DELETE", f"/v1/voices/{_p(id)}")
801
-
802
- async def available(
803
- self,
804
- lang: str,
805
- *,
806
- recording: Optional[str] = None,
807
- listener_token: Optional[str] = None,
808
- share_code: Optional[str] = None,
809
- as_owner: bool = True,
810
- ) -> m.VoiceCatalogue:
811
- """The voices that can speak ``lang``, best first (with a token, also
812
- the account's ready clones). ``recording`` also offers the cloned
813
- voices that recording uses, to whoever may read it: its owner, or a
814
- listener with ``listener_token`` or ``share_code``."""
815
- data = await self._t.json(
816
- "GET",
817
- "/v1/voices/available",
818
- query={**listener_query(listener_token, share_code), "lang": lang, "recording": recording},
819
- anonymous=not as_owner,
820
- )
821
- return _one(m.VoiceCatalogue, data)
822
-
823
- async def preview(self, voice: str, lang: str, *, format: Optional[str] = None) -> bytes:
824
- resp = await self._t.raw(
825
- "GET", "/v1/voices/preview", headers={"accept": "*/*"}, query={"voice": voice, "lang": lang, "format": format}
826
- )
827
- return resp.content
863
+ await self._t.json("DELETE", f"/v1/speakers/{_p(id)}")
828
864
 
829
- async def clone_preview(
865
+ async def voice_preview(
830
866
  self,
831
867
  id: str,
832
868
  *,
@@ -837,12 +873,12 @@ class Voices(_Group):
837
873
  share_code: Optional[str] = None,
838
874
  as_owner: bool = True,
839
875
  ) -> bytes:
840
- """A cloned voice speaking ``lang``. With ``recording``, as it speaks
841
- in that recording, for whoever may read it (its owner, or a listener
842
- with ``listener_token`` or ``share_code``)."""
876
+ """The speaker's cloned voice speaking ``lang``. With ``recording``, as
877
+ it speaks in that recording, for whoever may read it (its owner, or a
878
+ listener with ``listener_token`` or ``share_code``)."""
843
879
  resp = await self._t.raw(
844
880
  "GET",
845
- f"/v1/voices/{_p(id)}/preview",
881
+ f"/v1/speakers/{_p(id)}/preview",
846
882
  headers={"accept": "*/*"},
847
883
  query={**listener_query(listener_token, share_code), "lang": lang, "format": format, "recording": recording},
848
884
  anonymous=not as_owner,
@@ -850,7 +886,7 @@ class Voices(_Group):
850
886
  return resp.content
851
887
 
852
888
  async def sample(self, id: str) -> bytes:
853
- resp = await self._t.raw("GET", f"/v1/voices/{_p(id)}/sample", headers={"accept": "*/*"})
889
+ resp = await self._t.raw("GET", f"/v1/speakers/{_p(id)}/sample", headers={"accept": "*/*"})
854
890
  return resp.content
855
891
 
856
892
 
File without changes
File without changes