vocnu 0.5.0 → 0.7.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\|economy` | Premium (default); Standard: a voice-over for half the credits, with simpler voices and translation (its subtitles alone are Premium's); or Economy, the lowest price: 0.5 credits a minute of a voice-over or of subtitles alone, a plain synthetic voice reading a quick translation. Standard and Economy where Vocnu offers them |
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
+ another grade's with `--grade standard` or `--grade economy`: 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 or Economy), 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.7.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
+ SUBTITLE_GRADES, VIDEO_FORMATS, videoFormatsFrom,
13
14
  } from './media.js'
14
15
  import { VERSION } from './version.js'
15
16
 
@@ -23,14 +24,20 @@ 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|economy Another grade'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|economy Premium (default); Standard: a voice-over for half the credits, with
31
+ simpler voices and translation; or Economy, the lowest price: 0.5 credits
32
+ a minute of a voice-over or of subtitles alone, a plain synthetic voice
33
+ reading a quick translation (Standard and Economy where Vocnu offers them)
28
34
  --from <lang> Spoken language (default: detected)
29
35
  --voice male|female|<voice id> A voice type, or a voice from \`vocnu voices\` (default: male)
30
36
  --format mp4|mkv|mov|webm|avi Video file format, or several: mp4,mkv (default: the upload's, else mp4)
31
37
  --audio-format m4a|mp3|wav|flac|ogg
32
38
  --burn-subtitles Subtitles burned into the picture
33
- --original-level <0-100> How loud the original stays under the voice, in % (default: 40)
39
+ --original-level <0-100> How loud the original stays under the voice, in % (default: the level
40
+ recommended for the video, else 40)
34
41
  --original-off Turn the original sound off: the voice-over alone, with silence
35
42
  between its lines
36
43
  --sdh SDH subtitles too: sounds, speaker names and songs, for deaf and
@@ -114,6 +121,15 @@ function required(value, what) {
114
121
  return value
115
122
  }
116
123
 
124
+ function checkGrade(grade) {
125
+ if (grade !== undefined && !GRADES.includes(grade)) throw new UsageError(`--grade is ${listed(GRADES)}.`)
126
+ }
127
+
128
+ // premium, standard or economy
129
+ function listed(names) {
130
+ return names.length > 1 ? `${names.slice(0, -1).join(', ')} or ${names.at(-1)}` : names.join('')
131
+ }
132
+
117
133
  function parse(args, options) {
118
134
  try {
119
135
  return parseArgs({ allowPositionals: true, args, options, strict: true })
@@ -143,8 +159,10 @@ async function languages(api, print) {
143
159
  }
144
160
 
145
161
  async function voices(args, { api, print }) {
146
- const language = required(args[0], 'language code')
147
- for (const voice of await api.voices(language)) {
162
+ const { positionals, values } = parse(args, { grade: { type: 'string' } })
163
+ const language = required(positionals[0], 'language code')
164
+ checkGrade(values.grade)
165
+ for (const voice of await api.voices(language, values.grade)) {
148
166
  const about = [voice.gender, ...(voice.traits ?? [])].join(', ')
149
167
  print(`${voice.id.padEnd(24)} ${voice.name} (${about})${voice.default ? ', default' : ''}`)
150
168
  print(`${''.padEnd(24)} ${voice.sample_url}`)
@@ -158,6 +176,7 @@ async function translate(args, { api, err, out, print }) {
158
176
  'burn-subtitles': { type: 'boolean' },
159
177
  format: { type: 'string' },
160
178
  from: { type: 'string' },
179
+ grade: { type: 'string' },
161
180
  'no-wait': { type: 'boolean' },
162
181
  'original-level': { type: 'string' },
163
182
  'original-off': { type: 'boolean' },
@@ -176,10 +195,19 @@ async function translate(args, { api, err, out, print }) {
176
195
  // A voice type, or a catalog voice of the target language, whose type the API takes.
177
196
  const voice = values.voice ?? 'male'
178
197
  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.
198
+ // How loud the original stays under the voice, in whole percent; when not given, the API's own: the level
199
+ // recommended for the video, else 40 (backend ADR 0076).
180
200
  const originalLevel = values['original-level']
181
201
  // Or none of the original at all, between the lines too (backend ADR 0067).
182
202
  const originalOff = values['original-off'] === true
203
+ // Premium unless asked (backend ADR 0080); a job that names none is Premium's on every server.
204
+ const grade = values.grade ?? 'premium'
205
+ checkGrade(values.grade)
206
+ // Subtitles alone come in Premium or in Economy's own translation; Standard's would be Premium's.
207
+ if (output === 'subtitles' && !SUBTITLE_GRADES.includes(grade)) {
208
+ const names = listed(SUBTITLE_GRADES.map((name) => GRADE_NAMES[name]))
209
+ throw new UsageError(`--grade ${grade} is for a voice-over: subtitles alone come in ${names}.`)
210
+ }
183
211
  if (!OUTPUTS.includes(output)) throw new UsageError(`--output is one of ${OUTPUTS.join(', ')}.`)
184
212
  if (!videoFormats) throw new UsageError(`--format is one or more of ${VIDEO_FORMATS.join(', ')}, separated by commas.`)
185
213
  if (!AUDIO_FORMATS.includes(audioFormat)) throw new UsageError(`--audio-format is one of ${AUDIO_FORMATS.join(', ')}.`)
@@ -192,8 +220,9 @@ async function translate(args, { api, err, out, print }) {
192
220
  if (originalOff && originalLevel !== undefined) throw new UsageError('--original-off leaves no original to set a level for: use one of them.')
193
221
  if (output === 'video' && !isVideo(path)) throw new UsageError('This is an audio file: use --output audio or subtitles.')
194
222
  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}\`.`)
223
+ if (voice !== voiceType && !(await api.voices(target, values.grade)).some((candidate) => candidate.id === voice)) {
224
+ const listing = `vocnu voices ${target}${values.grade ? ` --grade ${grade}` : ''}`
225
+ throw new UsageError(`${target} has no ${values.grade ? `${GRADE_NAMES[grade]} ` : ''}voice ${voice}: see \`${listing}\`.`)
197
226
  }
198
227
  const { size } = await stat(path)
199
228
 
@@ -204,9 +233,23 @@ async function translate(args, { api, err, out, print }) {
204
233
  source = await api.waitForSource(source.id)
205
234
  progress.done(`Ready: ${source.title ?? basename(path)}, ${formatDuration(source.duration_seconds)}`)
206
235
 
207
- const credits = quotedCredits(source.quote, output, videoFormats, values['burn-subtitles'], values.sdh)
236
+ const prices = gradeQuote(source.quote, grade)
237
+ if (!prices) throw new VocnuError(`${GRADE_NAMES[grade]} is not available yet: use --grade premium. Nothing was charged.`)
238
+ const choice = [output, videoFormats, values['burn-subtitles'], values.sdh]
239
+ const credits = quotedCredits(prices, ...choice)
208
240
  const { balance } = await api.credits()
209
- print(`Price: ${credits} credits (${source.quote.minutes} min). Balance: ${balance} credits.`)
241
+ // The grade is named once the server prices grades; a server before them makes only Premium.
242
+ const graded = source.quote.grades ? `, ${GRADE_NAMES[grade]}` : ''
243
+ print(`Price: ${credits} credits (${source.quote.minutes} min${graded}). Balance: ${balance} credits.`)
244
+ // Short of credits in the grade asked, what the balance covers in a cheaper grade says so.
245
+ if (credits > balance) {
246
+ const cheaper = await cheaperWithin(api, source.quote, { balance, choice, grade, output, target })
247
+ if (cheaper.length > 0) {
248
+ const offers = cheaper.map(({ credits: price, grade: name }, index) =>
249
+ `in ${GRADE_NAMES[name]} ${index === 0 ? 'it costs ' : ''}${price} (add --grade ${name})`)
250
+ print(`Not enough credits for ${GRADE_NAMES[grade]}: ${offers.join(', ')}.`)
251
+ }
252
+ }
210
253
  if (!values.yes) {
211
254
  if (!process.stdin.isTTY) throw new UsageError('Add --yes to start without confirming the price.')
212
255
  const answer = (await ask('Start? [y/N] ')).trim().toLowerCase()
@@ -227,6 +270,7 @@ async function translate(args, { api, err, out, print }) {
227
270
  ...(voice === voiceType ? {} : { voice_id: voice }),
228
271
  ...(originalLevel === undefined ? {} : { original_level: Number(originalLevel) }),
229
272
  ...(originalOff ? { original_off: true } : {}),
273
+ ...(values.grade === undefined ? {} : { grade }),
230
274
  })
231
275
  print(`Started job ${created.job.id} (${created.credit_balance} credits left).`)
232
276
  if (values['no-wait']) return 0
@@ -241,6 +285,22 @@ async function translate(args, { api, err, out, print }) {
241
285
  return 0
242
286
  }
243
287
 
288
+ // The grades cheaper than the one asked, dearest first, whose price the balance covers, each with that price: Standard
289
+ // and Economy for a voice-over where they have voices of the language, Economy for subtitles alone.
290
+ async function cheaperWithin(api, quote, { balance, choice, grade, output, target }) {
291
+ const grades = output === 'subtitles' ? SUBTITLE_GRADES : GRADES
292
+ const within = []
293
+ for (const cheaper of grades.slice(grades.indexOf(grade) + 1)) {
294
+ const prices = gradeQuote(quote, cheaper)
295
+ if (!prices) continue
296
+ const credits = quotedCredits(prices, ...choice)
297
+ if (credits > balance) continue
298
+ if (output !== 'subtitles' && (await api.voices(target, cheaper)).length === 0) continue
299
+ within.push({ credits, grade: cheaper })
300
+ }
301
+ return within
302
+ }
303
+
244
304
  async function follow(api, id, progress) {
245
305
  for (;;) {
246
306
  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,31 @@ 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" and '
40
+ + '"economy". Subtitles alone come in "premium" or, where offered (price_credits_by_grade of an upload), '
41
+ + '"economy", into any language.',
37
42
  title: 'Vocnu languages',
38
43
  }, async () => {
39
44
  const catalog = await api.catalog()
40
- return (catalog.languages ?? []).map((l) => ({ code: l.code, name: l.name, voiceover: l.voiceover !== false }))
45
+ return (catalog.languages ?? []).map((l) => ({
46
+ code: l.code, name: l.name, voiceover: l.voiceover !== false,
47
+ ...(l.voiceover_grades ? { voiceover_grades: l.voiceover_grades } : {}),
48
+ }))
41
49
  })
42
50
 
43
51
  tool('vocnu_voices', {
44
52
  annotations: { readOnlyHint: true },
45
53
  description: 'Voices Vocnu can read a voice-over with in a language: id, name, type, a few words on how it '
46
54
  + '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)') },
55
+ + 'chosen id as voice_id to vocnu_start_job, with the same grade: each grade has voices of its own.',
56
+ inputSchema: {
57
+ grade: z.enum(GRADES).optional().describe('Whose voices: "premium" (default), "standard" or "economy"'),
58
+ language: z.string().describe('Language code, e.g. lt, en, de (see vocnu_languages)'),
59
+ },
49
60
  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,
61
+ }, async ({ grade, language }) => (await api.voices(language, grade)).map((v) => ({
62
+ default: v.default, gender: v.gender, grade: v.grade, id: v.id, name: v.name, sample_url: v.sample_url, traits: v.traits,
52
63
  })))
53
64
 
54
65
  tool('vocnu_credits', {
@@ -59,7 +70,12 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
59
70
 
60
71
  tool('vocnu_upload_media', {
61
72
  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. '
73
+ + 'source_id, length and price in credits for each output: price_credits in Premium, and '
74
+ + 'price_credits_by_grade in each grade offered (Standard: a voice-over for half the credits, with simpler '
75
+ + 'voices and translation, its subtitles alone Premium\'s at Premium\'s price; Economy: the lowest price, '
76
+ + 'a voice-over or subtitles alone at 0.5 credits a minute, a plain synthetic voice reading a quick '
77
+ + 'translation), with each grade\'s credits_per_minute (rates may be fractional, every price is whole '
78
+ + 'credits). Nothing is charged until vocnu_start_job. '
63
79
  + 'captions_only is true for a video nobody speaks in whose story is told in captions burned into the picture: '
64
80
  + 'Vocnu narrates the captions. Large files take minutes to upload.',
65
81
  inputSchema: { path: z.string().describe('Path of the video or audio file on this computer') },
@@ -69,23 +85,29 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
69
85
  const uploaded = await api.upload(file)
70
86
  const source = await api.waitForSource(uploaded.id)
71
87
  const { balance } = await api.credits()
88
+ const prices = (quote) => ({
89
+ // The grade's rates a minute, such as 0.5 in Economy (null from a server before them).
90
+ credits_per_minute: quote.credits_per_minute ?? null,
91
+ audio: quote.options.voiceover_audio,
92
+ subtitles: quote.options.subtitles,
93
+ video: source.has_video ? quotedCredits(quote, 'video', defaultVideoFormat(file)) : null,
94
+ // Several video formats cost the dearest one's price.
95
+ video_by_format: source.has_video
96
+ ? Object.fromEntries(VIDEO_FORMATS.map((format) => [format, quotedCredits(quote, 'video', format)]))
97
+ : null,
98
+ video_with_burned_subtitles: source.has_video ? quote.options.voiceover_video_burned_subtitles : null,
99
+ // What SDH subtitles add to any output (null: not offered).
100
+ sdh_extra: quote.options.sdh ?? null,
101
+ })
102
+ // A server before the grades prices Premium only.
103
+ const offered = Object.keys(source.quote.grades ?? { premium: true })
72
104
  return {
73
105
  balance,
74
106
  captions_only: source.captions_only === true,
75
107
  duration_seconds: source.duration_seconds,
76
108
  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
- },
109
+ price_credits: prices(source.quote),
110
+ price_credits_by_grade: Object.fromEntries(offered.map((grade) => [grade, prices(gradeQuote(source.quote, grade))])),
89
111
  source_id: source.id,
90
112
  suggested_video_format: isVideo(file) ? defaultVideoFormat(file) : null,
91
113
  title: source.title,
@@ -99,13 +121,20 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
99
121
  + 'also includes subtitles. sdh adds SDH subtitles (sound descriptions, speaker names, songs) for deaf and '
100
122
  + 'hard-of-hearing viewers to any output, at the sdh_extra price. Subtitles may be in the spoken language '
101
123
  + '(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.',
124
+ + 'captions_only upload, whose captions the narrator then reads as written. grade "standard" makes the '
125
+ + 'voice-over for half the credits, with simpler voices and translation; "economy" makes a voice-over or '
126
+ + 'subtitles alone for the lowest price, a plain synthetic voice reading a quick translation; each where '
127
+ + 'offered (see price_credits_by_grade and vocnu_languages); the price to confirm is then that grade\'s.',
103
128
  inputSchema: {
104
129
  audio_format: z.enum(AUDIO_FORMATS).optional().describe('Voice-over audio format (default m4a)'),
105
130
  burn_subtitles: z.boolean().optional().describe('Burn the subtitles into the picture (video only)'),
131
+ grade: z.enum(GRADES).optional().describe('"premium" (default), "standard" or "economy". Standard is for a '
132
+ + 'voice-over (its subtitles alone are Premium\'s); Economy makes subtitles alone too, in its own '
133
+ + 'translation. A voice_id must be one of the grade\'s voices (vocnu_voices with the grade)'),
106
134
  original_level: z.number().int().min(0).max(100).optional()
107
135
  .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'),
136
+ + '(default: the level recommended for the upload from how loud its own speech is, else 40). Voice-over '
137
+ + 'only; the original comes back to full volume only in long pauses in the narration'),
109
138
  original_off: z.boolean().optional()
110
139
  .describe('Turn the original sound off: the voice-over alone, with silence between its lines (no original '
111
140
  + 'voices, music or sound effects). Voice-over only; original_level is then not used'),
@@ -139,8 +168,11 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
139
168
  ...(input.voice_id ? { voice_id: input.voice_id } : {}),
140
169
  ...(input.original_level === undefined || input.original_off ? {} : { original_level: input.original_level }),
141
170
  ...(input.original_off ? { original_off: true } : {}),
171
+ ...(input.grade ? { grade: input.grade } : {}),
142
172
  })
143
- return { balance_after: created.credit_balance, job_id: created.job.id, status: created.job.status }
173
+ return {
174
+ balance_after: created.credit_balance, grade: created.job.grade, job_id: created.job.id, status: created.job.status,
175
+ }
144
176
  })
145
177
 
146
178
  tool('vocnu_job_status', {
@@ -206,6 +238,7 @@ function summary(job) {
206
238
  return {
207
239
  error: job.error,
208
240
  files: (job.outputs ?? []).map((o) => ({ bytes: o.byte_size, format: o.format, kind: o.kind, language: o.language })),
241
+ grade: job.grade,
209
242
  job_id: job.id,
210
243
  output: job.products?.voiceover_video ? 'video' : job.products?.voiceover_audio ? 'audio' : 'subtitles',
211
244
  sdh: job.products?.sdh === true,
package/src/media.js CHANGED
@@ -10,6 +10,12 @@ 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 (backend ADR 0080, 0083): Premium, the default, Standard, a voice-over for half the credits, and Economy,
14
+ // the cheapest, at half a credit a minute of a voice-over or of subtitles alone. Subtitles alone are Premium's
15
+ // translation in Premium and Standard, Economy's own in Economy.
16
+ export const GRADES = ['premium', 'standard', 'economy']
17
+ export const SUBTITLE_GRADES = ['premium', 'economy']
18
+ export const GRADE_NAMES = { premium: 'Premium', standard: 'Standard', economy: 'Economy' }
13
19
 
14
20
  export function contentType(path) {
15
21
  return TYPES[extname(path).toLowerCase()] ?? null
@@ -45,6 +51,12 @@ export function productsFor(output, burnSubtitles = false, sdh = false) {
45
51
  }
46
52
  }
47
53
 
54
+ // A source's prices in a grade: Premium's are the quote itself, as before the grades; another grade's come under
55
+ // `quote.grades` while it is offered. Null for a grade not offered.
56
+ export function gradeQuote(quote, grade = 'premium') {
57
+ return quote.grades?.[grade] ?? (grade === 'premium' ? quote : null)
58
+ }
59
+
48
60
  // Credits the quote asks for this output and video format, or formats: several cost the dearest one's price (a copy
49
61
  // of the picture into another container is free, re-encoding it is charged once). SDH adds `options.sdh`.
50
62
  export function quotedCredits(quote, output, videoFormats, burnSubtitles = false, sdh = false) {