vocnu 0.5.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 CHANGED
@@ -26,18 +26,20 @@ progress and time left, and saves the results next to the file. Options:
26
26
  | --- | --- |
27
27
  | `--output video\|audio\|subtitles` | the video with the voice-over (default for video files), the voice-over audio, or subtitles only |
28
28
  | `--from <lang>` | spoken language (detected by default) |
29
+ | `--grade premium\|standard` | Premium (default), or Standard where Vocnu offers it: a voice-over for half the credits, with simpler voices and translation (subtitles alone are the same in both) |
29
30
  | `--voice male\|female\|<voice id>` | a voice type, read by the language's default voice of it (default: male), or a voice from `vocnu voices <lang>` |
30
31
  | `--format mp4\|mkv\|mov\|webm\|avi` | video file format, or several separated by commas (`--format mp4,mkv`: one file each, for the price of the dearest); default: the upload's own, else MP4 |
31
32
  | `--audio-format m4a\|mp3\|wav\|flac\|ogg` | voice-over audio format |
32
33
  | `--burn-subtitles` | subtitles burned into the picture |
33
- | `--original-level <0-100>` | how loud the original sound stays under the voice, in percent (default: 40; 0 silences it, 100 leaves it as it is); between the lines it plays at full volume |
34
+ | `--original-level <0-100>` | how loud the original sound stays under the voice, in percent (default: the level Vocnu recommends for the video from how loud its own speech is, else 40; 0 silences it, 100 leaves it as it is); it comes back to full volume only in long pauses in the narration |
34
35
  | `--original-off` | the original sound turned off: the voice-over alone, with silence between its lines (no original voices, music or sound effects) |
35
36
  | `--sdh` | SDH subtitles as well (sounds, speaker names and songs for deaf and hard-of-hearing viewers), one more credit per minute; with `--output subtitles` they may be in the spoken language (`--from de --to de`) |
36
37
  | `--out <dir>` | where the results go |
37
38
  | `--yes` | start without confirming the price |
38
39
  | `--no-wait` | start the job and return its id |
39
40
 
40
- `vocnu voices <lang>` lists the voices of a language with a link to a short sample of each. Other commands:
41
+ `vocnu voices <lang>` lists the voices of a language with a link to a short sample of each, Premium's, or
42
+ Standard's with `--grade standard`: a job names a voice of its own grade. Other commands:
41
43
  `vocnu credits`, `vocnu languages`, `vocnu jobs`, `vocnu status <job>`, `vocnu download <job>`,
42
44
  `vocnu cancel <job>`, `vocnu logout`.
43
45
 
@@ -74,10 +76,11 @@ Claude Desktop (`claude_desktop_config.json`) and other MCP clients:
74
76
  ```
75
77
 
76
78
  Then ask, for example, “Dub ~/Videos/film.mkv into Lithuanian with Vocnu”. The assistant uploads the file
77
- (`vocnu_upload_media`), tells you the price, starts the job only after you agree (`vocnu_start_job`), checks on it
79
+ (`vocnu_upload_media`), tells you the price of each grade, starts the job only after you agree (`vocnu_start_job`,
80
+ Premium unless you ask for Standard), checks on it
78
81
  (`vocnu_job_status`) and saves the files (`vocnu_download_results`) or gives you a link to send
79
82
  (`vocnu_share_job`, turned off with `vocnu_revoke_share`). Also: `vocnu_languages`, `vocnu_voices` (the voices of a
80
- language with their samples, for `vocnu_start_job`'s `voice_id`), `vocnu_credits`, `vocnu_list_jobs`,
83
+ language and grade with their samples, for `vocnu_start_job`'s `voice_id`), `vocnu_credits`, `vocnu_list_jobs`,
81
84
  `vocnu_cancel_job`.
82
85
 
83
86
  ## Development
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vocnu",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Vocnu from your terminal and your AI assistant: AI voice-over and subtitles for your videos (CLI and MCP server).",
5
5
  "type": "module",
6
6
  "bin": {
package/src/api.js CHANGED
@@ -63,9 +63,11 @@ export class VocnuApi {
63
63
  return this.request('GET', '/credits')
64
64
  }
65
65
 
66
- // Vocnu's voice catalog for a language (backend ADR 0026): voices a job may name, each with a short sample.
67
- async voices(language) {
68
- return (await this.request('GET', `/voices?language=${encodeURIComponent(language)}`)).voices
66
+ // Vocnu's voice catalog for a language (backend ADR 0026): voices a job may name, each with a short sample. Premium's
67
+ // unless `grade` names another (backend ADR 0080).
68
+ async voices(language, grade) {
69
+ const query = `language=${encodeURIComponent(language)}${grade ? `&grade=${encodeURIComponent(grade)}` : ''}`
70
+ return (await this.request('GET', `/voices?${query}`)).voices
69
71
  }
70
72
 
71
73
  async source(id) {
package/src/cli.js CHANGED
@@ -9,7 +9,8 @@ import { VocnuApi, VocnuError } from './api.js'
9
9
  import { credentialsPath, DEFAULT_URL, forgetCredentials, loadConfig, saveCredentials } from './config.js'
10
10
  import { formatTimeLeft, secondsLeft } from './estimate.js'
11
11
  import {
12
- AUDIO_FORMATS, contentType, defaultVideoFormat, isVideo, OUTPUTS, productsFor, quotedCredits, VIDEO_FORMATS, videoFormatsFrom,
12
+ AUDIO_FORMATS, contentType, defaultVideoFormat, GRADE_NAMES, GRADES, gradeQuote, isVideo, OUTPUTS, productsFor, quotedCredits,
13
+ VIDEO_FORMATS, videoFormatsFrom,
13
14
  } from './media.js'
14
15
  import { VERSION } from './version.js'
15
16
 
@@ -23,14 +24,18 @@ Usage:
23
24
  vocnu credits Your credit balance
24
25
  vocnu languages Languages you can translate into
25
26
  vocnu voices <lang> Voices of a language, each with a short sample to listen to
27
+ --grade premium|standard Standard's voices instead of Premium's
26
28
  vocnu translate <file> --to <lang> Upload, see the price, translate and download the results
27
29
  --output video|audio|subtitles What you get (default: video for a video file, else audio)
30
+ --grade premium|standard Premium (default), or Standard: a voice-over for half the credits,
31
+ with simpler voices and translation
28
32
  --from <lang> Spoken language (default: detected)
29
33
  --voice male|female|<voice id> A voice type, or a voice from \`vocnu voices\` (default: male)
30
34
  --format mp4|mkv|mov|webm|avi Video file format, or several: mp4,mkv (default: the upload's, else mp4)
31
35
  --audio-format m4a|mp3|wav|flac|ogg
32
36
  --burn-subtitles Subtitles burned into the picture
33
- --original-level <0-100> How loud the original stays under the voice, in % (default: 40)
37
+ --original-level <0-100> How loud the original stays under the voice, in % (default: the level
38
+ recommended for the video, else 40)
34
39
  --original-off Turn the original sound off: the voice-over alone, with silence
35
40
  between its lines
36
41
  --sdh SDH subtitles too: sounds, speaker names and songs, for deaf and
@@ -114,6 +119,10 @@ function required(value, what) {
114
119
  return value
115
120
  }
116
121
 
122
+ function checkGrade(grade) {
123
+ if (grade !== undefined && !GRADES.includes(grade)) throw new UsageError(`--grade is ${GRADES.join(' or ')}.`)
124
+ }
125
+
117
126
  function parse(args, options) {
118
127
  try {
119
128
  return parseArgs({ allowPositionals: true, args, options, strict: true })
@@ -143,8 +152,10 @@ async function languages(api, print) {
143
152
  }
144
153
 
145
154
  async function voices(args, { api, print }) {
146
- const language = required(args[0], 'language code')
147
- for (const voice of await api.voices(language)) {
155
+ const { positionals, values } = parse(args, { grade: { type: 'string' } })
156
+ const language = required(positionals[0], 'language code')
157
+ checkGrade(values.grade)
158
+ for (const voice of await api.voices(language, values.grade)) {
148
159
  const about = [voice.gender, ...(voice.traits ?? [])].join(', ')
149
160
  print(`${voice.id.padEnd(24)} ${voice.name} (${about})${voice.default ? ', default' : ''}`)
150
161
  print(`${''.padEnd(24)} ${voice.sample_url}`)
@@ -158,6 +169,7 @@ async function translate(args, { api, err, out, print }) {
158
169
  'burn-subtitles': { type: 'boolean' },
159
170
  format: { type: 'string' },
160
171
  from: { type: 'string' },
172
+ grade: { type: 'string' },
161
173
  'no-wait': { type: 'boolean' },
162
174
  'original-level': { type: 'string' },
163
175
  'original-off': { type: 'boolean' },
@@ -176,10 +188,17 @@ async function translate(args, { api, err, out, print }) {
176
188
  // A voice type, or a catalog voice of the target language, whose type the API takes.
177
189
  const voice = values.voice ?? 'male'
178
190
  const voiceType = ['male', 'female'].includes(voice) ? voice : 'male'
179
- // How loud the original stays under the voice, in whole percent; the API's default (40) when not given.
191
+ // How loud the original stays under the voice, in whole percent; when not given, the API's own: the level
192
+ // recommended for the video, else 40 (backend ADR 0076).
180
193
  const originalLevel = values['original-level']
181
194
  // Or none of the original at all, between the lines too (backend ADR 0067).
182
195
  const originalOff = values['original-off'] === true
196
+ // Premium unless asked (backend ADR 0080); a job that names none is Premium's on every server.
197
+ const grade = values.grade ?? 'premium'
198
+ checkGrade(values.grade)
199
+ if (grade !== 'premium' && output === 'subtitles') {
200
+ throw new UsageError('--grade is for a voice-over; subtitles alone are the same in both grades.')
201
+ }
183
202
  if (!OUTPUTS.includes(output)) throw new UsageError(`--output is one of ${OUTPUTS.join(', ')}.`)
184
203
  if (!videoFormats) throw new UsageError(`--format is one or more of ${VIDEO_FORMATS.join(', ')}, separated by commas.`)
185
204
  if (!AUDIO_FORMATS.includes(audioFormat)) throw new UsageError(`--audio-format is one of ${AUDIO_FORMATS.join(', ')}.`)
@@ -192,8 +211,9 @@ async function translate(args, { api, err, out, print }) {
192
211
  if (originalOff && originalLevel !== undefined) throw new UsageError('--original-off leaves no original to set a level for: use one of them.')
193
212
  if (output === 'video' && !isVideo(path)) throw new UsageError('This is an audio file: use --output audio or subtitles.')
194
213
  if (!contentType(path)) throw new UsageError('Vocnu takes video and audio files (MP4, MOV, MKV, WebM, MP3, M4A, WAV...).')
195
- if (voice !== voiceType && !(await api.voices(target)).some((candidate) => candidate.id === voice)) {
196
- throw new UsageError(`${target} has no voice ${voice}: see \`vocnu voices ${target}\`.`)
214
+ if (voice !== voiceType && !(await api.voices(target, values.grade)).some((candidate) => candidate.id === voice)) {
215
+ const listing = `vocnu voices ${target}${values.grade ? ` --grade ${grade}` : ''}`
216
+ throw new UsageError(`${target} has no ${values.grade ? `${GRADE_NAMES[grade]} ` : ''}voice ${voice}: see \`${listing}\`.`)
197
217
  }
198
218
  const { size } = await stat(path)
199
219
 
@@ -204,9 +224,19 @@ async function translate(args, { api, err, out, print }) {
204
224
  source = await api.waitForSource(source.id)
205
225
  progress.done(`Ready: ${source.title ?? basename(path)}, ${formatDuration(source.duration_seconds)}`)
206
226
 
207
- const credits = quotedCredits(source.quote, output, videoFormats, values['burn-subtitles'], values.sdh)
227
+ const prices = gradeQuote(source.quote, grade)
228
+ if (!prices) throw new VocnuError(`${GRADE_NAMES[grade]} is not available yet: use --grade premium. Nothing was charged.`)
229
+ const choice = [output, videoFormats, values['burn-subtitles'], values.sdh]
230
+ const credits = quotedCredits(prices, ...choice)
208
231
  const { balance } = await api.credits()
209
- print(`Price: ${credits} credits (${source.quote.minutes} min). Balance: ${balance} credits.`)
232
+ // The grade is named once the server prices grades; a server before them makes only Premium.
233
+ const graded = source.quote.grades ? `, ${GRADE_NAMES[grade]}` : ''
234
+ print(`Price: ${credits} credits (${source.quote.minutes} min${graded}). Balance: ${balance} credits.`)
235
+ // A voice-over the balance covers in Standard but not in Premium says so.
236
+ if (output !== 'subtitles' && grade === 'premium' && credits > balance) {
237
+ const cheaper = await standardWithin(api, source.quote, target, balance, choice)
238
+ if (cheaper !== null) print(`Not enough credits for Premium: in Standard it costs ${cheaper} (add --grade standard).`)
239
+ }
210
240
  if (!values.yes) {
211
241
  if (!process.stdin.isTTY) throw new UsageError('Add --yes to start without confirming the price.')
212
242
  const answer = (await ask('Start? [y/N] ')).trim().toLowerCase()
@@ -227,6 +257,7 @@ async function translate(args, { api, err, out, print }) {
227
257
  ...(voice === voiceType ? {} : { voice_id: voice }),
228
258
  ...(originalLevel === undefined ? {} : { original_level: Number(originalLevel) }),
229
259
  ...(originalOff ? { original_off: true } : {}),
260
+ ...(values.grade === undefined ? {} : { grade }),
230
261
  })
231
262
  print(`Started job ${created.job.id} (${created.credit_balance} credits left).`)
232
263
  if (values['no-wait']) return 0
@@ -241,6 +272,16 @@ async function translate(args, { api, err, out, print }) {
241
272
  return 0
242
273
  }
243
274
 
275
+ // What a voice-over short of credits in Premium costs in Standard, when the balance covers it there and Standard has
276
+ // voices of the language; else null.
277
+ async function standardWithin(api, quote, target, balance, choice) {
278
+ const standard = gradeQuote(quote, 'standard')
279
+ if (!standard) return null
280
+ const credits = quotedCredits(standard, ...choice)
281
+ if (credits > balance || (await api.voices(target, 'standard')).length === 0) return null
282
+ return credits
283
+ }
284
+
244
285
  async function follow(api, id, progress) {
245
286
  for (;;) {
246
287
  const job = await api.job(id)
package/src/mcp.js CHANGED
@@ -11,7 +11,9 @@ import { z } from 'zod'
11
11
  import { VocnuApi } from './api.js'
12
12
  import { loadConfig } from './config.js'
13
13
  import { formatTimeLeft, secondsLeft } from './estimate.js'
14
- import { AUDIO_FORMATS, defaultVideoFormat, isVideo, OUTPUTS, productsFor, quotedCredits, VIDEO_FORMATS } from './media.js'
14
+ import {
15
+ AUDIO_FORMATS, defaultVideoFormat, GRADES, gradeQuote, isVideo, OUTPUTS, productsFor, quotedCredits, VIDEO_FORMATS,
16
+ } from './media.js'
15
17
  import { VERSION } from './version.js'
16
18
 
17
19
  export async function serve({ env = process.env, transport = new StdioServerTransport() } = {}) {
@@ -33,22 +35,29 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
33
35
 
34
36
  tool('vocnu_languages', {
35
37
  annotations: { readOnlyHint: true },
36
- description: 'Languages Vocnu translates into (code and name); some take subtitles only.',
38
+ description: 'Languages Vocnu translates into (code and name); some take subtitles only. voiceover_grades: the '
39
+ + 'grades a voice-over into the language can be made in now, "premium" and, where offered, "standard".',
37
40
  title: 'Vocnu languages',
38
41
  }, async () => {
39
42
  const catalog = await api.catalog()
40
- return (catalog.languages ?? []).map((l) => ({ code: l.code, name: l.name, voiceover: l.voiceover !== false }))
43
+ return (catalog.languages ?? []).map((l) => ({
44
+ code: l.code, name: l.name, voiceover: l.voiceover !== false,
45
+ ...(l.voiceover_grades ? { voiceover_grades: l.voiceover_grades } : {}),
46
+ }))
41
47
  })
42
48
 
43
49
  tool('vocnu_voices', {
44
50
  annotations: { readOnlyHint: true },
45
51
  description: 'Voices Vocnu can read a voice-over with in a language: id, name, type, a few words on how it '
46
52
  + 'sounds, whether it is the default of its type, and a short sample (MP3) the user can listen to. Pass the '
47
- + 'chosen id as voice_id to vocnu_start_job.',
48
- inputSchema: { language: z.string().describe('Language code, e.g. lt, en, de (see vocnu_languages)') },
53
+ + 'chosen id as voice_id to vocnu_start_job, with the same grade: each grade has voices of its own.',
54
+ inputSchema: {
55
+ grade: z.enum(GRADES).optional().describe('Whose voices: "premium" (default) or "standard"'),
56
+ language: z.string().describe('Language code, e.g. lt, en, de (see vocnu_languages)'),
57
+ },
49
58
  title: 'Vocnu voices',
50
- }, async ({ language }) => (await api.voices(language)).map((v) => ({
51
- default: v.default, gender: v.gender, id: v.id, name: v.name, sample_url: v.sample_url, traits: v.traits,
59
+ }, async ({ grade, language }) => (await api.voices(language, grade)).map((v) => ({
60
+ default: v.default, gender: v.gender, grade: v.grade, id: v.id, name: v.name, sample_url: v.sample_url, traits: v.traits,
52
61
  })))
53
62
 
54
63
  tool('vocnu_credits', {
@@ -59,7 +68,9 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
59
68
 
60
69
  tool('vocnu_upload_media', {
61
70
  description: 'Upload a local video or audio file (up to 10 GB) to Vocnu, wait until it is analysed and return its '
62
- + 'source_id, length and price in credits for each output. Nothing is charged until vocnu_start_job. '
71
+ + 'source_id, length and price in credits for each output: price_credits in Premium, and '
72
+ + 'price_credits_by_grade in each grade offered (Standard: a voice-over for half the credits, with simpler '
73
+ + 'voices and translation; subtitles alone cost the same). Nothing is charged until vocnu_start_job. '
63
74
  + 'captions_only is true for a video nobody speaks in whose story is told in captions burned into the picture: '
64
75
  + 'Vocnu narrates the captions. Large files take minutes to upload.',
65
76
  inputSchema: { path: z.string().describe('Path of the video or audio file on this computer') },
@@ -69,23 +80,27 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
69
80
  const uploaded = await api.upload(file)
70
81
  const source = await api.waitForSource(uploaded.id)
71
82
  const { balance } = await api.credits()
83
+ const prices = (quote) => ({
84
+ audio: quote.options.voiceover_audio,
85
+ subtitles: quote.options.subtitles,
86
+ video: source.has_video ? quotedCredits(quote, 'video', defaultVideoFormat(file)) : null,
87
+ // Several video formats cost the dearest one's price.
88
+ video_by_format: source.has_video
89
+ ? Object.fromEntries(VIDEO_FORMATS.map((format) => [format, quotedCredits(quote, 'video', format)]))
90
+ : null,
91
+ video_with_burned_subtitles: source.has_video ? quote.options.voiceover_video_burned_subtitles : null,
92
+ // What SDH subtitles add to any output (null: not offered).
93
+ sdh_extra: quote.options.sdh ?? null,
94
+ })
95
+ // A server before the grades prices Premium only.
96
+ const offered = Object.keys(source.quote.grades ?? { premium: true })
72
97
  return {
73
98
  balance,
74
99
  captions_only: source.captions_only === true,
75
100
  duration_seconds: source.duration_seconds,
76
101
  has_video: source.has_video,
77
- price_credits: {
78
- audio: source.quote.options.voiceover_audio,
79
- subtitles: source.quote.options.subtitles,
80
- video: source.has_video ? quotedCredits(source.quote, 'video', defaultVideoFormat(file)) : null,
81
- // Several video formats cost the dearest one's price.
82
- video_by_format: source.has_video
83
- ? Object.fromEntries(VIDEO_FORMATS.map((format) => [format, quotedCredits(source.quote, 'video', format)]))
84
- : null,
85
- video_with_burned_subtitles: source.has_video ? source.quote.options.voiceover_video_burned_subtitles : null,
86
- // What SDH subtitles add to any output (null: not offered).
87
- sdh_extra: source.quote.options.sdh ?? null,
88
- },
102
+ price_credits: prices(source.quote),
103
+ price_credits_by_grade: Object.fromEntries(offered.map((grade) => [grade, prices(gradeQuote(source.quote, grade))])),
89
104
  source_id: source.id,
90
105
  suggested_video_format: isVideo(file) ? defaultVideoFormat(file) : null,
91
106
  title: source.title,
@@ -99,13 +114,18 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
99
114
  + 'also includes subtitles. sdh adds SDH subtitles (sound descriptions, speaker names, songs) for deaf and '
100
115
  + 'hard-of-hearing viewers to any output, at the sdh_extra price. Subtitles may be in the spoken language '
101
116
  + '(target_language = source_language, e.g. German SDH of a German film); a voice-over may not, except for a '
102
- + 'captions_only upload, whose captions the narrator then reads as written.',
117
+ + 'captions_only upload, whose captions the narrator then reads as written. grade "standard" makes the '
118
+ + 'voice-over for half the credits, with simpler voices and translation, where offered (see '
119
+ + 'price_credits_by_grade and vocnu_languages); the price to confirm is then that grade\'s.',
103
120
  inputSchema: {
104
121
  audio_format: z.enum(AUDIO_FORMATS).optional().describe('Voice-over audio format (default m4a)'),
105
122
  burn_subtitles: z.boolean().optional().describe('Burn the subtitles into the picture (video only)'),
123
+ grade: z.enum(GRADES).optional().describe('"premium" (default) or "standard". Voice-over only: subtitles alone '
124
+ + 'are the same in both. A voice_id must be one of the grade\'s voices (vocnu_voices with the grade)'),
106
125
  original_level: z.number().int().min(0).max(100).optional()
107
126
  .describe('How loud the original sound stays under the voice, in percent: 0 silent, 100 unchanged '
108
- + '(default 40). Voice-over only; between the lines the original plays at full volume'),
127
+ + '(default: the level recommended for the upload from how loud its own speech is, else 40). Voice-over '
128
+ + 'only; the original comes back to full volume only in long pauses in the narration'),
109
129
  original_off: z.boolean().optional()
110
130
  .describe('Turn the original sound off: the voice-over alone, with silence between its lines (no original '
111
131
  + 'voices, music or sound effects). Voice-over only; original_level is then not used'),
@@ -139,8 +159,11 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
139
159
  ...(input.voice_id ? { voice_id: input.voice_id } : {}),
140
160
  ...(input.original_level === undefined || input.original_off ? {} : { original_level: input.original_level }),
141
161
  ...(input.original_off ? { original_off: true } : {}),
162
+ ...(input.grade ? { grade: input.grade } : {}),
142
163
  })
143
- return { balance_after: created.credit_balance, job_id: created.job.id, status: created.job.status }
164
+ return {
165
+ balance_after: created.credit_balance, grade: created.job.grade, job_id: created.job.id, status: created.job.status,
166
+ }
144
167
  })
145
168
 
146
169
  tool('vocnu_job_status', {
@@ -206,6 +229,7 @@ function summary(job) {
206
229
  return {
207
230
  error: job.error,
208
231
  files: (job.outputs ?? []).map((o) => ({ bytes: o.byte_size, format: o.format, kind: o.kind, language: o.language })),
232
+ grade: job.grade,
209
233
  job_id: job.id,
210
234
  output: job.products?.voiceover_video ? 'video' : job.products?.voiceover_audio ? 'audio' : 'subtitles',
211
235
  sdh: job.products?.sdh === true,
package/src/media.js CHANGED
@@ -10,6 +10,10 @@ const TYPES = {
10
10
  export const VIDEO_FORMATS = ['mp4', 'mkv', 'mov', 'webm', 'avi']
11
11
  export const AUDIO_FORMATS = ['m4a', 'mp3', 'wav', 'flac', 'ogg']
12
12
  export const OUTPUTS = ['video', 'audio', 'subtitles']
13
+ // The grades of voice-over (backend ADR 0080): Premium, the default, and Standard, a voice-over for half the
14
+ // credits. Subtitles alone are the same in both.
15
+ export const GRADES = ['premium', 'standard']
16
+ export const GRADE_NAMES = { premium: 'Premium', standard: 'Standard' }
13
17
 
14
18
  export function contentType(path) {
15
19
  return TYPES[extname(path).toLowerCase()] ?? null
@@ -45,6 +49,12 @@ export function productsFor(output, burnSubtitles = false, sdh = false) {
45
49
  }
46
50
  }
47
51
 
52
+ // A source's prices in a grade: Premium's are the quote itself, as before the grades; another grade's come under
53
+ // `quote.grades` while it is offered. Null for a grade not offered.
54
+ export function gradeQuote(quote, grade = 'premium') {
55
+ return quote.grades?.[grade] ?? (grade === 'premium' ? quote : null)
56
+ }
57
+
48
58
  // Credits the quote asks for this output and video format, or formats: several cost the dearest one's price (a copy
49
59
  // of the picture into another container is free, re-encoding it is charged once). SDH adds `options.sdh`.
50
60
  export function quotedCredits(quote, output, videoFormats, burnSubtitles = false, sdh = false) {