vocnu 0.6.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 +3 -3
- package/package.json +1 -1
- package/src/cli.js +38 -19
- package/src/mcp.js +16 -7
- package/src/media.js +6 -4
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ 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)
|
|
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 |
|
|
30
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>` |
|
|
31
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 |
|
|
32
32
|
| `--audio-format m4a\|mp3\|wav\|flac\|ogg` | voice-over audio format |
|
|
@@ -39,7 +39,7 @@ progress and time left, and saves the results next to the file. Options:
|
|
|
39
39
|
| `--no-wait` | start the job and return its id |
|
|
40
40
|
|
|
41
41
|
`vocnu voices <lang>` lists the voices of a language with a link to a short sample of each, Premium's, or
|
|
42
|
-
|
|
42
|
+
another grade's with `--grade standard` or `--grade economy`: a job names a voice of its own grade. Other commands:
|
|
43
43
|
`vocnu credits`, `vocnu languages`, `vocnu jobs`, `vocnu status <job>`, `vocnu download <job>`,
|
|
44
44
|
`vocnu cancel <job>`, `vocnu logout`.
|
|
45
45
|
|
|
@@ -77,7 +77,7 @@ Claude Desktop (`claude_desktop_config.json`) and other MCP clients:
|
|
|
77
77
|
|
|
78
78
|
Then ask, for example, “Dub ~/Videos/film.mkv into Lithuanian with Vocnu”. The assistant uploads the file
|
|
79
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
|
|
80
|
+
Premium unless you ask for Standard or Economy), checks on it
|
|
81
81
|
(`vocnu_job_status`) and saves the files (`vocnu_download_results`) or gives you a link to send
|
|
82
82
|
(`vocnu_share_job`, turned off with `vocnu_revoke_share`). Also: `vocnu_languages`, `vocnu_voices` (the voices of a
|
|
83
83
|
language and grade with their samples, for `vocnu_start_job`'s `voice_id`), `vocnu_credits`, `vocnu_list_jobs`,
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { credentialsPath, DEFAULT_URL, forgetCredentials, loadConfig, saveCreden
|
|
|
10
10
|
import { formatTimeLeft, secondsLeft } from './estimate.js'
|
|
11
11
|
import {
|
|
12
12
|
AUDIO_FORMATS, contentType, defaultVideoFormat, GRADE_NAMES, GRADES, gradeQuote, isVideo, OUTPUTS, productsFor, quotedCredits,
|
|
13
|
-
VIDEO_FORMATS, videoFormatsFrom,
|
|
13
|
+
SUBTITLE_GRADES, VIDEO_FORMATS, videoFormatsFrom,
|
|
14
14
|
} from './media.js'
|
|
15
15
|
import { VERSION } from './version.js'
|
|
16
16
|
|
|
@@ -24,11 +24,13 @@ Usage:
|
|
|
24
24
|
vocnu credits Your credit balance
|
|
25
25
|
vocnu languages Languages you can translate into
|
|
26
26
|
vocnu voices <lang> Voices of a language, each with a short sample to listen to
|
|
27
|
-
--grade premium|standard
|
|
27
|
+
--grade premium|standard|economy Another grade's voices instead of Premium's
|
|
28
28
|
vocnu translate <file> --to <lang> Upload, see the price, translate and download the results
|
|
29
29
|
--output video|audio|subtitles What you get (default: video for a video file, else audio)
|
|
30
|
-
--grade premium|standard
|
|
31
|
-
|
|
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)
|
|
32
34
|
--from <lang> Spoken language (default: detected)
|
|
33
35
|
--voice male|female|<voice id> A voice type, or a voice from \`vocnu voices\` (default: male)
|
|
34
36
|
--format mp4|mkv|mov|webm|avi Video file format, or several: mp4,mkv (default: the upload's, else mp4)
|
|
@@ -120,7 +122,12 @@ function required(value, what) {
|
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
function checkGrade(grade) {
|
|
123
|
-
if (grade !== undefined && !GRADES.includes(grade)) throw new UsageError(`--grade is ${GRADES
|
|
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('')
|
|
124
131
|
}
|
|
125
132
|
|
|
126
133
|
function parse(args, options) {
|
|
@@ -196,8 +203,10 @@ async function translate(args, { api, err, out, print }) {
|
|
|
196
203
|
// Premium unless asked (backend ADR 0080); a job that names none is Premium's on every server.
|
|
197
204
|
const grade = values.grade ?? 'premium'
|
|
198
205
|
checkGrade(values.grade)
|
|
199
|
-
|
|
200
|
-
|
|
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}.`)
|
|
201
210
|
}
|
|
202
211
|
if (!OUTPUTS.includes(output)) throw new UsageError(`--output is one of ${OUTPUTS.join(', ')}.`)
|
|
203
212
|
if (!videoFormats) throw new UsageError(`--format is one or more of ${VIDEO_FORMATS.join(', ')}, separated by commas.`)
|
|
@@ -232,10 +241,14 @@ async function translate(args, { api, err, out, print }) {
|
|
|
232
241
|
// The grade is named once the server prices grades; a server before them makes only Premium.
|
|
233
242
|
const graded = source.quote.grades ? `, ${GRADE_NAMES[grade]}` : ''
|
|
234
243
|
print(`Price: ${credits} credits (${source.quote.minutes} min${graded}). Balance: ${balance} credits.`)
|
|
235
|
-
//
|
|
236
|
-
if (
|
|
237
|
-
const cheaper = await
|
|
238
|
-
if (cheaper
|
|
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
|
+
}
|
|
239
252
|
}
|
|
240
253
|
if (!values.yes) {
|
|
241
254
|
if (!process.stdin.isTTY) throw new UsageError('Add --yes to start without confirming the price.')
|
|
@@ -272,14 +285,20 @@ async function translate(args, { api, err, out, print }) {
|
|
|
272
285
|
return 0
|
|
273
286
|
}
|
|
274
287
|
|
|
275
|
-
//
|
|
276
|
-
// voices of the language
|
|
277
|
-
async function
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
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
|
|
283
302
|
}
|
|
284
303
|
|
|
285
304
|
async function follow(api, id, progress) {
|
package/src/mcp.js
CHANGED
|
@@ -36,7 +36,9 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
36
36
|
tool('vocnu_languages', {
|
|
37
37
|
annotations: { readOnlyHint: true },
|
|
38
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"
|
|
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.',
|
|
40
42
|
title: 'Vocnu languages',
|
|
41
43
|
}, async () => {
|
|
42
44
|
const catalog = await api.catalog()
|
|
@@ -52,7 +54,7 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
52
54
|
+ 'sounds, whether it is the default of its type, and a short sample (MP3) the user can listen to. Pass the '
|
|
53
55
|
+ 'chosen id as voice_id to vocnu_start_job, with the same grade: each grade has voices of its own.',
|
|
54
56
|
inputSchema: {
|
|
55
|
-
grade: z.enum(GRADES).optional().describe('Whose voices: "premium" (default) or "
|
|
57
|
+
grade: z.enum(GRADES).optional().describe('Whose voices: "premium" (default), "standard" or "economy"'),
|
|
56
58
|
language: z.string().describe('Language code, e.g. lt, en, de (see vocnu_languages)'),
|
|
57
59
|
},
|
|
58
60
|
title: 'Vocnu voices',
|
|
@@ -70,7 +72,10 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
70
72
|
description: 'Upload a local video or audio file (up to 10 GB) to Vocnu, wait until it is analysed and return its '
|
|
71
73
|
+ 'source_id, length and price in credits for each output: price_credits in Premium, and '
|
|
72
74
|
+ 'price_credits_by_grade in each grade offered (Standard: a voice-over for half the credits, with simpler '
|
|
73
|
-
+ 'voices and translation
|
|
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. '
|
|
74
79
|
+ 'captions_only is true for a video nobody speaks in whose story is told in captions burned into the picture: '
|
|
75
80
|
+ 'Vocnu narrates the captions. Large files take minutes to upload.',
|
|
76
81
|
inputSchema: { path: z.string().describe('Path of the video or audio file on this computer') },
|
|
@@ -81,6 +86,8 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
81
86
|
const source = await api.waitForSource(uploaded.id)
|
|
82
87
|
const { balance } = await api.credits()
|
|
83
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,
|
|
84
91
|
audio: quote.options.voiceover_audio,
|
|
85
92
|
subtitles: quote.options.subtitles,
|
|
86
93
|
video: source.has_video ? quotedCredits(quote, 'video', defaultVideoFormat(file)) : null,
|
|
@@ -115,13 +122,15 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
115
122
|
+ 'hard-of-hearing viewers to any output, at the sdh_extra price. Subtitles may be in the spoken language '
|
|
116
123
|
+ '(target_language = source_language, e.g. German SDH of a German film); a voice-over may not, except for a '
|
|
117
124
|
+ '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
|
|
119
|
-
+ '
|
|
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.',
|
|
120
128
|
inputSchema: {
|
|
121
129
|
audio_format: z.enum(AUDIO_FORMATS).optional().describe('Voice-over audio format (default m4a)'),
|
|
122
130
|
burn_subtitles: z.boolean().optional().describe('Burn the subtitles into the picture (video only)'),
|
|
123
|
-
grade: z.enum(GRADES).optional().describe('"premium" (default) or "
|
|
124
|
-
+ '
|
|
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)'),
|
|
125
134
|
original_level: z.number().int().min(0).max(100).optional()
|
|
126
135
|
.describe('How loud the original sound stays under the voice, in percent: 0 silent, 100 unchanged '
|
|
127
136
|
+ '(default: the level recommended for the upload from how loud its own speech is, else 40). Voice-over '
|
package/src/media.js
CHANGED
|
@@ -10,10 +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
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
export const
|
|
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' }
|
|
17
19
|
|
|
18
20
|
export function contentType(path) {
|
|
19
21
|
return TYPES[extname(path).toLowerCase()] ?? null
|