@vocalstack/payload 0.1.0 → 0.2.0

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.
package/dist/types.d.ts CHANGED
@@ -1,5 +1,21 @@
1
- import type { CollectionSlug, PayloadRequest, TypeWithID } from 'payload';
1
+ import type { CollectionConfig, CollectionSlug, PayloadRequest, TypeWithID } from 'payload';
2
2
  export type VocalStackPluginOptions = {
3
+ /**
4
+ * Where finished spoken readings are kept: the plugin downloads each one's MP3
5
+ * once and saves it as an upload here, so listeners are served from your
6
+ * storage and VocalStack is not asked again. Default: an upload collection
7
+ * `vocalstack-readings` the plugin adds (point your storage adapter at it).
8
+ * `false` streams readings from VocalStack instead.
9
+ *
10
+ * `overrides` adjusts the added collection (access, labels, admin, upload
11
+ * options). A host may instead define its own upload collection with that slug;
12
+ * the plugin then uses it as it is. It needs to accept `audio/mpeg` and have text
13
+ * fields `lang`, `recordingId` and `voice`.
14
+ */
15
+ readings?: false | {
16
+ overrides?: (collection: CollectionConfig) => CollectionConfig;
17
+ slug?: CollectionSlug;
18
+ };
3
19
  /** Turn the plugin off without removing it (fields stay in the schema). */
4
20
  enabled?: boolean;
5
21
  /**
@@ -45,6 +61,73 @@ export type VocalStackPluginOptions = {
45
61
  access?: (args: {
46
62
  req: PayloadRequest;
47
63
  }) => boolean | Promise<boolean>;
64
+ /**
65
+ * Collections of people (speakers, presenters) that each get a cloned VocalStack voice:
66
+ * made from a stretch of a recording they speak in, or from a sample, with their permission.
67
+ */
68
+ voices?: VoiceCollectionConfig[];
69
+ /**
70
+ * The VocalStack voice (`clone:<id>`, `F1`, …) a transcript's translations are spoken in
71
+ * by default, e.g. the cloned voice of the person speaking. Nothing: VocalStack's default.
72
+ */
73
+ speechVoice?: (args: {
74
+ collection: CollectionSlug;
75
+ doc: Record<string, unknown>;
76
+ req: PayloadRequest;
77
+ row?: ArrayRow;
78
+ }) => Promise<string | undefined> | string | undefined;
79
+ };
80
+ export type VoiceCollectionConfig = {
81
+ collection: CollectionSlug;
82
+ /** The voice's name in VocalStack. Default: the collection's `useAsTitle` field, else `name`. */
83
+ name?: (args: {
84
+ doc: Record<string, unknown>;
85
+ }) => string;
86
+ /** Transcribed recordings this person speaks in, offered as the sample to clone from. */
87
+ recordings?: (args: {
88
+ doc: Record<string, unknown>;
89
+ req: PayloadRequest;
90
+ }) => Promise<VoiceSource[]> | VoiceSource[];
91
+ };
92
+ /** A transcribed recording to take a voice sample from. */
93
+ export type VoiceSource = {
94
+ label: string;
95
+ recordingId: string;
96
+ sentences?: TranscriptSentence[];
97
+ };
98
+ export type VoiceState = 'failed' | 'none' | 'ready' | 'training';
99
+ /** The `vocalstackVoice` group on a voice collection's documents. */
100
+ export type VoiceFieldData = {
101
+ consentAt?: null | string;
102
+ createdAt?: null | string;
103
+ error?: null | string;
104
+ progress?: null | number;
105
+ sampleS?: null | number;
106
+ state?: null | VoiceState;
107
+ voiceId?: null | string;
108
+ };
109
+ export type Translation = {
110
+ /** The transcript's sentences (same ids and times), their text translated. */
111
+ sentences: TranscriptSentence[];
112
+ translatedAt: string;
113
+ };
114
+ export type SpeechState = 'failed' | 'queued' | 'running' | 'sealed';
115
+ export type Speech = {
116
+ durationS?: null | number;
117
+ error?: null | string;
118
+ renderedAt?: null | string;
119
+ requestedAt: string;
120
+ /** Once sealed: the translated sentences in the spoken track's timing, with their words. */
121
+ sentences?: null | TranscriptSentence[];
122
+ state: SpeechState;
123
+ /** The voice it is spoken in; `null` for VocalStack's default. */
124
+ voice: null | string;
125
+ /** Once sealed: the reading's MP3, saved once in the readings upload collection and served from there. */
126
+ audio?: null | {
127
+ filename?: null | string;
128
+ id: number | string;
129
+ url: string;
130
+ };
48
131
  };
49
132
  export type ArrayRow = Record<string, unknown> & {
50
133
  id?: null | string;
@@ -84,6 +167,10 @@ export type VocalStackFieldData = {
84
167
  transcript?: null | string;
85
168
  transcriptionId?: null | string;
86
169
  transcribedAt?: null | string;
170
+ /** By language code. */
171
+ translations?: null | Record<string, Translation>;
172
+ /** Spoken translations, by language code. */
173
+ speech?: null | Record<string, Speech>;
87
174
  };
88
175
  /** [start, end, text], seconds. */
89
176
  export type TranscriptWord = [number, number, string];
@@ -121,3 +208,11 @@ export type ConnectionResponse = {
121
208
  /** `options`: the key is in the plugin config; `admin`: connected from the admin panel. */
122
209
  source?: 'admin' | 'options';
123
210
  };
211
+ /** What the translate and speak endpoints answer. */
212
+ export type SpeechResponse = {
213
+ /** The voice readings use unless one is picked (`speechVoice`); `null`: VocalStack's default. */
214
+ defaultVoice?: null | string;
215
+ /** The translate endpoint ran out of time; call it again to carry on. */
216
+ more?: boolean;
217
+ vocalstack: VocalStackFieldData;
218
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocalstack/payload",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "VocalStack for Payload CMS: a Transcribe button on every audio upload.",
5
5
  "license": "MIT",
6
6
  "type": "module",