vocalstack 1.0.0a3__tar.gz → 1.0.0a4__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.0a4
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(
@@ -228,7 +228,7 @@ except VocalStackError as e:
228
228
  - The other groups: `vs.transcriptions` (`list`, `get`, `update`, `archive`,
229
229
  `restore`, `purge`, `list_share_links`, `create_share_link`), `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.0a4"
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"
@@ -228,7 +228,7 @@ except VocalStackError as e:
228
228
  - The other groups: `vs.transcriptions` (`list`, `get`, `update`, `archive`,
229
229
  `restore`, `purge`, `list_share_links`, `create_share_link`), `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.0a4"
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
@@ -1371,6 +1406,7 @@ class SentenceView(_Base):
1371
1406
  class SpeakerNumber(_Base):
1372
1407
  name: Optional[str] = None
1373
1408
  number: int
1409
+ returning: Optional[bool] = None
1374
1410
  speaker: int
1375
1411
 
1376
1412
 
@@ -1383,7 +1419,7 @@ class SessionStats(_Base):
1383
1419
  class SessionOptions(_Base):
1384
1420
  audio: Optional["AudioFormat"] = None
1385
1421
  events: Optional["EventOptions"] = None
1386
- identify_voices: Optional[List["KnownVoice"]] = Field(default=None, alias="identifyVoices")
1422
+ identify_speakers: Optional[List["KnownSpeaker"]] = Field(default=None, alias="identifySpeakers")
1387
1423
  input: Optional["InputOptions"] = None
1388
1424
  latency_mode: Optional[LatencyMode] = Field(default=None, alias="latencyMode")
1389
1425
  sentences: Optional["SentenceOptions"] = None
@@ -1397,8 +1433,8 @@ class SessionOptions(_Base):
1397
1433
 
1398
1434
 
1399
1435
  class SetConsent(_Base):
1400
- """`POST /v1/voices/:id/consent`: the owner records whether the speaker
1401
- agreed to their clone."""
1436
+ """`POST /v1/speakers/{id}/consent`: the owner records whether the speaker
1437
+ agreed to have their voice cloned."""
1402
1438
 
1403
1439
  consent: Consent
1404
1440
  name: Optional[str] = None
@@ -1471,17 +1507,20 @@ plus job state to read from."""
1471
1507
  transcription_id: Optional[str] = Field(default=None, alias="transcriptionId")
1472
1508
 
1473
1509
 
1474
- class SpeakerView(_Base):
1510
+ class Speaker(_Base):
1511
+ archived_at: Optional[str] = Field(default=None, alias="archivedAt")
1512
+ color: Optional[str] = None
1513
+ consent: Consent
1514
+ consent_at: Optional[str] = Field(default=None, alias="consentAt")
1515
+ created_at: str = Field(alias="createdAt")
1516
+ draft: bool
1475
1517
  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")
1518
+ id: str
1519
+ library: Optional[bool] = None
1479
1520
  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")
1521
+ recording_id: Optional[str] = Field(default=None, alias="recordingId")
1522
+ updated_at: str = Field(alias="updatedAt")
1523
+ voice: Optional["Clone"] = None
1485
1524
 
1486
1525
 
1487
1526
  class StartJob(_Base):
@@ -1549,7 +1588,7 @@ class TranscriptSnapshot(_Base):
1549
1588
  sentences: List["SentenceView"]
1550
1589
  spans: List["CaptureSpan"]
1551
1590
  speaker_labels: Optional[SpeakerLabels] = Field(default=None, alias="speakerLabels")
1552
- speakers: List["SpeakerView"]
1591
+ speakers: List["AppearanceView"]
1553
1592
  state: RecordingState
1554
1593
  translation_pending: Optional[bool] = Field(default=None, alias="translationPending")
1555
1594
 
@@ -1723,32 +1762,6 @@ class VectorResults(_Base):
1723
1762
  state: str
1724
1763
 
1725
1764
 
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
1765
  class VoiceOption(_Base):
1753
1766
  accent: Optional[str] = None
1754
1767
  auto: Optional[bool] = None
@@ -1910,9 +1923,9 @@ class TranscriptSpeakerIdentified(_Base):
1910
1923
  confidence: Optional[float] = None
1911
1924
  name: str
1912
1925
  speaker: int
1926
+ speaker_id: Optional[str] = Field(default=None, alias="speakerId")
1913
1927
  tone: Optional[bool] = None
1914
1928
  type: Literal["transcript.speakerIdentified"] = "transcript.speakerIdentified"
1915
- voice_id: Optional[str] = Field(default=None, alias="voiceId")
1916
1929
 
1917
1930
 
1918
1931
  class TranscriptSpeakerNumbers(_Base):
@@ -2106,8 +2119,8 @@ class TranscriptSpeakerIdentified(_Base):
2106
2119
  confidence: Optional[float] = None
2107
2120
  name: str
2108
2121
  speaker: int
2122
+ speaker_id: Optional[str] = Field(default=None, alias="speakerId")
2109
2123
  type: Literal["transcript.speakerIdentified"] = "transcript.speakerIdentified"
2110
- voice_id: Optional[str] = Field(default=None, alias="voiceId")
2111
2124
 
2112
2125
 
2113
2126
  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)
@@ -348,6 +348,11 @@ class Transcriptions(_ParentResource):
348
348
  data = await self._t.json("DELETE", self._path(id, f"/broadcasts/{_p(broadcast_id)}"))
349
349
  return _one(m.Transcription, data)
350
350
 
351
+ async def name_appearance(self, id: str, appearance: int, name: Optional[str]) -> None:
352
+ """Name one speaker of the transcription: ``appearance`` is their
353
+ display number ("Speaker <number>"); ``None`` clears the name."""
354
+ await self._t.json("PUT", self._path(id, f"/appearances/{appearance}"), json_body={"name": name})
355
+
351
356
 
352
357
  class Recordings(_Group):
353
358
  """``vs.recordings``: one take, live or uploaded."""
@@ -556,9 +561,6 @@ class Recordings(_Group):
556
561
  async def media_token(self, id: str) -> Dict[str, Any]:
557
562
  return await self._t.json("GET", self._path(id, "/media-token"))
558
563
 
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
564
  async def events(self, id: str, *, after: Optional[int] = None, limit: Optional[int] = None) -> List[m.RecordingEvent]:
563
565
  """The durable event log with wall times (owner only): every event
564
566
  after ``after`` (a ``seq``; the whole log without it), read ``limit`` a page."""
@@ -724,29 +726,61 @@ class Tags(_Group):
724
726
 
725
727
 
726
728
  class Voices(_Group):
727
- """``vs.voices``: the account's cloned voices, and what a language offers."""
729
+ """``vs.voices``: the voices a language offers, and how each sounds."""
730
+
731
+ async def available(
732
+ self,
733
+ lang: str,
734
+ *,
735
+ recording: Optional[str] = None,
736
+ listener_token: Optional[str] = None,
737
+ share_code: Optional[str] = None,
738
+ as_owner: bool = True,
739
+ ) -> m.VoiceCatalogue:
740
+ """The voices that can speak ``lang``, best first (with a token, also
741
+ the account's ready clones). ``recording`` also offers the cloned
742
+ voices that recording uses, to whoever may read it: its owner, or a
743
+ listener with ``listener_token`` or ``share_code``."""
744
+ data = await self._t.json(
745
+ "GET",
746
+ "/v1/voices/available",
747
+ query={**listener_query(listener_token, share_code), "lang": lang, "recording": recording},
748
+ anonymous=not as_owner,
749
+ )
750
+ return _one(m.VoiceCatalogue, data)
728
751
 
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")
752
+ async def preview(self, voice: str, lang: str, *, format: Optional[str] = None) -> bytes:
753
+ resp = await self._t.raw(
754
+ "GET", "/v1/voices/preview", headers={"accept": "*/*"}, query={"voice": voice, "lang": lang, "format": format}
755
+ )
756
+ return resp.content
757
+
758
+
759
+ class Speakers(_Group):
760
+ """``vs.speakers``: the account's saved speakers, each with an optional
761
+ cloned voice (``voice``) built from their sample."""
731
762
 
732
- async def get(self, id: str) -> m.Voice:
733
- return _one(m.Voice, await self._t.json("GET", f"/v1/voices/{_p(id)}"))
763
+ async def list(self, *, lifecycle: Optional[str] = None) -> List[m.Speaker]:
764
+ return _many(m.Speaker, await self._t.json("GET", "/v1/speakers", query={"lifecycle": lifecycle}), "speakers")
734
765
 
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"))
766
+ async def get(self, id: str) -> m.Speaker:
767
+ return _one(m.Speaker, await self._t.json("GET", f"/v1/speakers/{_p(id)}"))
738
768
 
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"))
769
+ async def archive(self, id: str) -> m.Speaker:
770
+ """Put a speaker away: their voice stops speaking and they are unlinked from their appearances."""
771
+ return _one(m.Speaker, await self._t.json("POST", f"/v1/speakers/{_p(id)}/archive"))
772
+
773
+ async def restore(self, id: str) -> m.Speaker:
774
+ return _one(m.Speaker, await self._t.json("POST", f"/v1/speakers/{_p(id)}/restore"))
741
775
 
742
776
  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}))
777
+ return _one(m.ManyResult, await self._t.json("POST", "/v1/speakers/archive", json_body={"ids": ids}))
744
778
 
745
779
  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}))
780
+ return _one(m.ManyResult, await self._t.json("POST", "/v1/speakers/restore", json_body={"ids": ids}))
747
781
 
748
782
  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}))
783
+ return _one(m.ManyResult, await self._t.json("POST", "/v1/speakers/delete", json_body={"ids": ids}))
750
784
 
751
785
  async def create(
752
786
  self,
@@ -757,76 +791,75 @@ class Voices(_Group):
757
791
  file_name: Optional[str] = None,
758
792
  gender: Optional[str] = None,
759
793
  color: Optional[str] = None,
760
- draft: bool = False,
794
+ draft: Optional[bool] = None,
795
+ consent: Optional[bool] = None,
761
796
  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``."""
797
+ ) -> m.Speaker:
798
+ """Save a speaker from a sample or a link. Without ``consent`` they are
799
+ recognised only (``voice`` is ``None``); ``consent=True`` asserts you
800
+ have their permission and starts training their cloned voice."""
765
801
  meta = _body(
766
- m.CreateVoice,
767
- {"name": name, "sample_url": sample_url, "gender": gender, "color": color, "draft": draft or None, "consent": not draft},
802
+ m.CreateSpeaker,
803
+ {"name": name, "sample_url": sample_url, "gender": gender, "color": color, "draft": draft, "consent": consent},
768
804
  )
769
805
  files: Dict[str, Any] = {"meta": (None, json.dumps(meta), "application/json")}
770
806
  if sample is not None:
771
807
  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."""
808
+ data = await self._t.json("POST", "/v1/speakers", files=files, idempotency_key=idempotency_key)
809
+ return _one(m.Speaker, data)
810
+
811
+ async def create_from_appearance(
812
+ self,
813
+ *,
814
+ transcription_id: str,
815
+ appearance: int,
816
+ name: str,
817
+ recording_id: Optional[str] = None,
818
+ color: Optional[str] = None,
819
+ consent: Optional[bool] = None,
820
+ spans: Optional[List[Dict[str, float]]] = None,
821
+ draft: Optional[bool] = None,
822
+ library: Optional[bool] = None,
823
+ idempotency_key: Optional[str] = None,
824
+ ) -> m.Speaker:
825
+ """Save a speaker from one appearance of a transcription (``appearance``
826
+ is the ``speaker`` index of their lines). ``consent=True`` asserts
827
+ permission and clones their voice; ``library=False`` keeps them with
828
+ that transcription only."""
780
829
  body = _body(
781
- m.CreateVoiceFromSpeaker,
782
- {"recording_id": recording_id, "speaker": speaker, "name": name, "color": color, "library": library, "consent": True},
830
+ m.CreateSpeakerFromAppearance,
831
+ {
832
+ "transcription_id": transcription_id,
833
+ "recording_id": recording_id,
834
+ "appearance": appearance,
835
+ "name": name,
836
+ "color": color,
837
+ "consent": consent,
838
+ "spans": spans,
839
+ "draft": draft,
840
+ "library": library,
841
+ },
783
842
  )
784
- data = await self._t.json("POST", "/v1/voices/from-speaker", json_body=body, idempotency_key=idempotency_key)
785
- return _one(m.Voice, data)
843
+ data = await self._t.json("POST", "/v1/speakers/from-appearance", json_body=body, idempotency_key=idempotency_key)
844
+ return _one(m.Speaker, data)
786
845
 
787
- async def set_consent(self, id: str, consent: str, *, name: Optional[str] = None) -> m.Voice:
846
+ async def set_consent(self, id: str, consent: str, *, name: Optional[str] = None) -> m.Speaker:
788
847
  """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``."""
848
+ optional name) makes their voice speak; ``refused`` deletes its audio
849
+ and voice. Automatic clones start ``pending``."""
792
850
  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))
851
+ return _one(m.Speaker, await self._t.json("POST", f"/v1/speakers/{_p(id)}/consent", json_body=body))
794
852
 
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))
853
+ async def update(self, id: str, **fields: Any) -> m.Speaker:
854
+ """Rename or recolour; ``enabled`` turns the cloned voice on or off;
855
+ ``consent=True`` on a speaker without a clone starts one from their sample."""
856
+ body = _body(m.PatchSpeaker, fields)
857
+ return _one(m.Speaker, await self._t.json("PATCH", f"/v1/speakers/{_p(id)}", json_body=body))
798
858
 
799
859
  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
860
+ await self._t.json("DELETE", f"/v1/speakers/{_p(id)}")
828
861
 
829
- async def clone_preview(
862
+ async def voice_preview(
830
863
  self,
831
864
  id: str,
832
865
  *,
@@ -837,12 +870,12 @@ class Voices(_Group):
837
870
  share_code: Optional[str] = None,
838
871
  as_owner: bool = True,
839
872
  ) -> 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``)."""
873
+ """The speaker's cloned voice speaking ``lang``. With ``recording``, as
874
+ it speaks in that recording, for whoever may read it (its owner, or a
875
+ listener with ``listener_token`` or ``share_code``)."""
843
876
  resp = await self._t.raw(
844
877
  "GET",
845
- f"/v1/voices/{_p(id)}/preview",
878
+ f"/v1/speakers/{_p(id)}/preview",
846
879
  headers={"accept": "*/*"},
847
880
  query={**listener_query(listener_token, share_code), "lang": lang, "format": format, "recording": recording},
848
881
  anonymous=not as_owner,
@@ -850,7 +883,7 @@ class Voices(_Group):
850
883
  return resp.content
851
884
 
852
885
  async def sample(self, id: str) -> bytes:
853
- resp = await self._t.raw("GET", f"/v1/voices/{_p(id)}/sample", headers={"accept": "*/*"})
886
+ resp = await self._t.raw("GET", f"/v1/speakers/{_p(id)}/sample", headers={"accept": "*/*"})
854
887
  return resp.content
855
888
 
856
889
 
File without changes
File without changes