@vocalstack/payload 0.4.0 → 0.6.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/README.md +42 -9
- package/dist/api.d.ts +33 -24
- package/dist/api.js +111 -33
- package/dist/components/SpeakerField.d.ts +1 -0
- package/dist/components/{VoiceField.js → SpeakerField.js} +13 -11
- package/dist/components/SpeechField.js +1 -1
- package/dist/components/VoiceSamples.d.ts +3 -6
- package/dist/components/VoiceSamples.js +2 -2
- package/dist/endpoints/speech.js +21 -17
- package/dist/endpoints/voices.d.ts +24 -14
- package/dist/endpoints/voices.js +116 -78
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/client.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +30 -13
- package/dist/types.d.ts +41 -12
- package/package.json +1 -1
- package/dist/components/VoiceField.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -2,10 +2,11 @@ import { connectionEndpoints } from './endpoints/connection.js';
|
|
|
2
2
|
import { refreshAfterRead, speechEndpoints } from './endpoints/speech.js';
|
|
3
3
|
import { streamEndpoint } from './endpoints/stream.js';
|
|
4
4
|
import { transcribeEndpoints } from './endpoints/transcribe.js';
|
|
5
|
-
import { lookupEndpoints,
|
|
5
|
+
import { lookupEndpoints, speakerEndpoints } from './endpoints/voices.js';
|
|
6
6
|
import { readingsCollection, readingsSlug } from './readings.js';
|
|
7
7
|
import { settingsGlobal } from './settings.js';
|
|
8
8
|
export { spokenSentences, timedTokens, transcriptText } from './text.js';
|
|
9
|
+
export { migrateSpeakerFields, speakerData } from './endpoints/voices.js';
|
|
9
10
|
const isAudioDoc = (data) => typeof data?.mimeType === 'string' && data.mimeType.startsWith('audio/');
|
|
10
11
|
/** An upload collection that can hold audio: `audio/*`, a wildcard, or no restriction at all. */
|
|
11
12
|
function acceptsAudio(collection) {
|
|
@@ -84,22 +85,38 @@ function transcriptionFields(enabled, options, target) {
|
|
|
84
85
|
},
|
|
85
86
|
];
|
|
86
87
|
}
|
|
87
|
-
/** A person
|
|
88
|
-
function
|
|
88
|
+
/** A person saved as a VocalStack speaker: the panel, and what VocalStack says about the speaker and their cloned voice. */
|
|
89
|
+
function speakerFields(enabled) {
|
|
89
90
|
return [
|
|
90
91
|
...(enabled
|
|
91
92
|
? [
|
|
92
93
|
{
|
|
93
|
-
name: '
|
|
94
|
+
name: 'vocalstackSpeakerPanel',
|
|
94
95
|
type: 'ui',
|
|
95
|
-
admin: { components: { Field: '@vocalstack/payload/client#
|
|
96
|
+
admin: { components: { Field: '@vocalstack/payload/client#SpeakerField' }, position: 'sidebar' },
|
|
96
97
|
},
|
|
97
98
|
]
|
|
98
99
|
: []),
|
|
100
|
+
{
|
|
101
|
+
name: 'vocalstackSpeaker',
|
|
102
|
+
type: 'group',
|
|
103
|
+
label: 'Speaker',
|
|
104
|
+
admin: { hidden: true },
|
|
105
|
+
fields: [
|
|
106
|
+
{ name: 'speakerId', type: 'text', ...hidden },
|
|
107
|
+
{ name: 'cloneId', type: 'text', ...hidden },
|
|
108
|
+
{ name: 'state', type: 'select', defaultValue: 'none', options: ['none', 'training', 'ready', 'failed'], ...hidden },
|
|
109
|
+
{ name: 'progress', type: 'number', ...hidden },
|
|
110
|
+
{ name: 'error', type: 'text', ...hidden },
|
|
111
|
+
{ name: 'sampleS', type: 'number', ...hidden },
|
|
112
|
+
{ name: 'consentAt', type: 'date', ...hidden },
|
|
113
|
+
{ name: 'createdAt', type: 'date', ...hidden },
|
|
114
|
+
],
|
|
115
|
+
},
|
|
99
116
|
{
|
|
100
117
|
name: 'vocalstackVoice',
|
|
101
118
|
type: 'group',
|
|
102
|
-
label: 'Voice',
|
|
119
|
+
label: 'Voice (0.5)',
|
|
103
120
|
admin: { hidden: true },
|
|
104
121
|
fields: [
|
|
105
122
|
{ name: 'voiceId', type: 'text', ...hidden },
|
|
@@ -151,20 +168,20 @@ export const vocalstackPlugin = (options = {}) => (config) => {
|
|
|
151
168
|
const readings = readingsSlug(options);
|
|
152
169
|
const uploads = new Set(options.collections ?? collections.filter((c) => c.slug !== readings && acceptsAudio(c)).map((c) => c.slug));
|
|
153
170
|
const audioFields = options.audioFields ?? [];
|
|
154
|
-
const
|
|
155
|
-
for (const v of
|
|
171
|
+
const speakers = options.speakers ?? options.voices ?? [];
|
|
172
|
+
for (const v of speakers) {
|
|
156
173
|
if (!collections.some((c) => c.slug === v.collection))
|
|
157
|
-
throw new Error(`vocalstackPlugin: no collection "${v.collection}" for
|
|
174
|
+
throw new Error(`vocalstackPlugin: no collection "${v.collection}" for speakers`);
|
|
158
175
|
}
|
|
159
176
|
return {
|
|
160
177
|
...config,
|
|
161
178
|
collections: [...collections, ...(readings && !collections.some((c) => c.slug === readings) ? [(options.readings && options.readings.overrides ? options.readings.overrides : (c) => c)(readingsCollection(readings))] : [])].map((original) => {
|
|
162
|
-
const
|
|
163
|
-
const collection =
|
|
179
|
+
const speaker = speakers.find((v) => v.collection === original.slug);
|
|
180
|
+
const collection = speaker
|
|
164
181
|
? {
|
|
165
182
|
...original,
|
|
166
|
-
endpoints: enabled ? [...(original.endpoints || []), ...
|
|
167
|
-
fields: [...original.fields, ...
|
|
183
|
+
endpoints: enabled ? [...(original.endpoints || []), ...speakerEndpoints(speaker, options)] : original.endpoints,
|
|
184
|
+
fields: [...original.fields, ...speakerFields(enabled)],
|
|
168
185
|
}
|
|
169
186
|
: original;
|
|
170
187
|
const rowFields = audioFields.filter((f) => f.collection === collection.slug);
|
package/dist/types.d.ts
CHANGED
|
@@ -62,10 +62,13 @@ export type VocalStackPluginOptions = {
|
|
|
62
62
|
req: PayloadRequest;
|
|
63
63
|
}) => boolean | Promise<boolean>;
|
|
64
64
|
/**
|
|
65
|
-
* Collections of people (speakers, presenters) that each
|
|
66
|
-
* made from a stretch of a recording they speak in, or from a sample,
|
|
65
|
+
* Collections of people (speakers, presenters) that are each saved as a VocalStack speaker,
|
|
66
|
+
* with a cloned voice made from a stretch of a recording they speak in, or from a sample,
|
|
67
|
+
* with their permission.
|
|
67
68
|
*/
|
|
68
|
-
|
|
69
|
+
speakers?: SpeakerCollectionConfig[];
|
|
70
|
+
/** @deprecated Renamed to `speakers`; still read when `speakers` is not set. */
|
|
71
|
+
voices?: SpeakerCollectionConfig[];
|
|
69
72
|
/**
|
|
70
73
|
* Let the site's visitors ask for a transcript in their own language: it is translated,
|
|
71
74
|
* read aloud where VocalStack has a voice for it, and kept on the document (and the
|
|
@@ -75,8 +78,9 @@ export type VocalStackPluginOptions = {
|
|
|
75
78
|
listeners?: boolean | ListenerOptions;
|
|
76
79
|
/**
|
|
77
80
|
* Whether a transcript is read in its speakers' cloned voices or in synthetic ones, decided by
|
|
78
|
-
* the site (e.g. from the person speaking: `cloned`
|
|
79
|
-
*
|
|
81
|
+
* the site (e.g. from the person speaking: `cloned` once they have a voice). `cloned` reads each
|
|
82
|
+
* speaker in their clone where VocalStack has one for them, and in a stock voice otherwise.
|
|
83
|
+
* Answer nothing to leave it to the transcript's own toggle. When set, the toggle is not shown.
|
|
80
84
|
*/
|
|
81
85
|
voiceMode?: (args: {
|
|
82
86
|
collection: CollectionSlug;
|
|
@@ -98,9 +102,9 @@ export type ListenerOptions = {
|
|
|
98
102
|
/** New languages one visitor (by IP address) may ask for in an hour, on this server. Default 10. */
|
|
99
103
|
perHour?: number;
|
|
100
104
|
};
|
|
101
|
-
export type
|
|
105
|
+
export type SpeakerCollectionConfig = {
|
|
102
106
|
collection: CollectionSlug;
|
|
103
|
-
/** The
|
|
107
|
+
/** The speaker's name in VocalStack. Default: the collection's `useAsTitle` field, else `name`. */
|
|
104
108
|
name?: (args: {
|
|
105
109
|
doc: Record<string, unknown>;
|
|
106
110
|
}) => string;
|
|
@@ -108,25 +112,48 @@ export type VoiceCollectionConfig = {
|
|
|
108
112
|
recordings?: (args: {
|
|
109
113
|
doc: Record<string, unknown>;
|
|
110
114
|
req: PayloadRequest;
|
|
111
|
-
}) => Promise<
|
|
115
|
+
}) => Promise<SpeakerSource[]> | SpeakerSource[];
|
|
112
116
|
};
|
|
113
117
|
/** A transcribed recording to take a voice sample from. */
|
|
114
|
-
export type
|
|
118
|
+
export type SpeakerSource = {
|
|
115
119
|
label: string;
|
|
116
120
|
recordingId: string;
|
|
117
121
|
sentences?: TranscriptSentence[];
|
|
122
|
+
transcriptionId?: string;
|
|
118
123
|
};
|
|
119
|
-
export type
|
|
120
|
-
/** The `
|
|
124
|
+
export type CloneState = 'failed' | 'none' | 'ready' | 'training';
|
|
125
|
+
/** The `vocalstackSpeaker` group on a speaker collection's documents. */
|
|
126
|
+
export type SpeakerFieldData = {
|
|
127
|
+
cloneId?: null | string;
|
|
128
|
+
consentAt?: null | string;
|
|
129
|
+
createdAt?: null | string;
|
|
130
|
+
error?: null | string;
|
|
131
|
+
progress?: null | number;
|
|
132
|
+
sampleS?: null | number;
|
|
133
|
+
speakerId?: null | string;
|
|
134
|
+
state?: null | CloneState;
|
|
135
|
+
};
|
|
136
|
+
/** @deprecated The `vocalstackVoice` group of 0.5 and earlier, kept in step for a release; read `vocalstackSpeaker`. */
|
|
121
137
|
export type VoiceFieldData = {
|
|
122
138
|
consentAt?: null | string;
|
|
123
139
|
createdAt?: null | string;
|
|
124
140
|
error?: null | string;
|
|
125
141
|
progress?: null | number;
|
|
126
142
|
sampleS?: null | number;
|
|
127
|
-
state?: null |
|
|
143
|
+
state?: null | CloneState;
|
|
128
144
|
voiceId?: null | string;
|
|
129
145
|
};
|
|
146
|
+
export type SpeakerAnswer = {
|
|
147
|
+
name?: string;
|
|
148
|
+
vocalstackSpeaker: SpeakerFieldData;
|
|
149
|
+
vocalstackVoice?: VoiceFieldData;
|
|
150
|
+
};
|
|
151
|
+
/** @deprecated Renamed to `SpeakerCollectionConfig`. */
|
|
152
|
+
export type VoiceCollectionConfig = SpeakerCollectionConfig;
|
|
153
|
+
/** @deprecated Renamed to `SpeakerSource`. */
|
|
154
|
+
export type VoiceSource = SpeakerSource;
|
|
155
|
+
/** @deprecated Renamed to `CloneState`. */
|
|
156
|
+
export type VoiceState = CloneState;
|
|
130
157
|
export type Translation = {
|
|
131
158
|
/** The transcript's sentences (same ids and times), their text translated. */
|
|
132
159
|
sentences: TranscriptSentence[];
|
|
@@ -154,6 +181,8 @@ export type Speech = {
|
|
|
154
181
|
state: SpeechState;
|
|
155
182
|
/** Read in speakers' cloned voices, or in stock (synthetic) ones. */
|
|
156
183
|
cast?: null | VoiceMode;
|
|
184
|
+
/** What VocalStack read it in: `cloned`, `synthetic`, or `mixed` (some speakers had no usable clone). */
|
|
185
|
+
readIn?: 'cloned' | 'mixed' | 'synthetic' | null;
|
|
157
186
|
/** VocalStack's key for the voices it is read in (e.g. `cast:-1=M1`); `null` until VocalStack says. */
|
|
158
187
|
voice: null | string;
|
|
159
188
|
/** Once sealed: the reading's MP3, saved once in the readings upload collection and served from there. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vocalstack/payload",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "VocalStack for Payload CMS: transcribe audio, translate it into other languages and read it aloud, kept in your own database and storage.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const VoiceField: React.FC;
|