vocnu 0.4.1 → 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 +8 -4
- package/package.json +1 -1
- package/src/api.js +5 -3
- package/src/cli.js +58 -9
- package/src/mcp.js +52 -24
- package/src/media.js +10 -0
package/README.md
CHANGED
|
@@ -26,17 +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);
|
|
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 |
|
|
35
|
+
| `--original-off` | the original sound turned off: the voice-over alone, with silence between its lines (no original voices, music or sound effects) |
|
|
34
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`) |
|
|
35
37
|
| `--out <dir>` | where the results go |
|
|
36
38
|
| `--yes` | start without confirming the price |
|
|
37
39
|
| `--no-wait` | start the job and return its id |
|
|
38
40
|
|
|
39
|
-
`vocnu voices <lang>` lists the voices of a language with a link to a short sample of each
|
|
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:
|
|
40
43
|
`vocnu credits`, `vocnu languages`, `vocnu jobs`, `vocnu status <job>`, `vocnu download <job>`,
|
|
41
44
|
`vocnu cancel <job>`, `vocnu logout`.
|
|
42
45
|
|
|
@@ -73,10 +76,11 @@ Claude Desktop (`claude_desktop_config.json`) and other MCP clients:
|
|
|
73
76
|
```
|
|
74
77
|
|
|
75
78
|
Then ask, for example, “Dub ~/Videos/film.mkv into Lithuanian with Vocnu”. The assistant uploads the file
|
|
76
|
-
(`vocnu_upload_media`), tells you the price, starts the job only after you agree (`vocnu_start_job
|
|
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
|
|
77
81
|
(`vocnu_job_status`) and saves the files (`vocnu_download_results`) or gives you a link to send
|
|
78
82
|
(`vocnu_share_job`, turned off with `vocnu_revoke_share`). Also: `vocnu_languages`, `vocnu_voices` (the voices of a
|
|
79
|
-
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`,
|
|
80
84
|
`vocnu_cancel_job`.
|
|
81
85
|
|
|
82
86
|
## Development
|
package/package.json
CHANGED
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
|
-
|
|
68
|
-
|
|
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,
|
|
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,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 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:
|
|
37
|
+
--original-level <0-100> How loud the original stays under the voice, in % (default: the level
|
|
38
|
+
recommended for the video, else 40)
|
|
39
|
+
--original-off Turn the original sound off: the voice-over alone, with silence
|
|
40
|
+
between its lines
|
|
34
41
|
--sdh SDH subtitles too: sounds, speaker names and songs, for deaf and
|
|
35
42
|
hard-of-hearing viewers (subtitles may be in the spoken language)
|
|
36
43
|
--out <directory> Where the results go (default: next to the file)
|
|
@@ -112,6 +119,10 @@ function required(value, what) {
|
|
|
112
119
|
return value
|
|
113
120
|
}
|
|
114
121
|
|
|
122
|
+
function checkGrade(grade) {
|
|
123
|
+
if (grade !== undefined && !GRADES.includes(grade)) throw new UsageError(`--grade is ${GRADES.join(' or ')}.`)
|
|
124
|
+
}
|
|
125
|
+
|
|
115
126
|
function parse(args, options) {
|
|
116
127
|
try {
|
|
117
128
|
return parseArgs({ allowPositionals: true, args, options, strict: true })
|
|
@@ -141,8 +152,10 @@ async function languages(api, print) {
|
|
|
141
152
|
}
|
|
142
153
|
|
|
143
154
|
async function voices(args, { api, print }) {
|
|
144
|
-
const
|
|
145
|
-
|
|
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)) {
|
|
146
159
|
const about = [voice.gender, ...(voice.traits ?? [])].join(', ')
|
|
147
160
|
print(`${voice.id.padEnd(24)} ${voice.name} (${about})${voice.default ? ', default' : ''}`)
|
|
148
161
|
print(`${''.padEnd(24)} ${voice.sample_url}`)
|
|
@@ -156,8 +169,10 @@ async function translate(args, { api, err, out, print }) {
|
|
|
156
169
|
'burn-subtitles': { type: 'boolean' },
|
|
157
170
|
format: { type: 'string' },
|
|
158
171
|
from: { type: 'string' },
|
|
172
|
+
grade: { type: 'string' },
|
|
159
173
|
'no-wait': { type: 'boolean' },
|
|
160
174
|
'original-level': { type: 'string' },
|
|
175
|
+
'original-off': { type: 'boolean' },
|
|
161
176
|
out: { type: 'string' },
|
|
162
177
|
output: { type: 'string' },
|
|
163
178
|
sdh: { type: 'boolean' },
|
|
@@ -173,8 +188,17 @@ async function translate(args, { api, err, out, print }) {
|
|
|
173
188
|
// A voice type, or a catalog voice of the target language, whose type the API takes.
|
|
174
189
|
const voice = values.voice ?? 'male'
|
|
175
190
|
const voiceType = ['male', 'female'].includes(voice) ? voice : 'male'
|
|
176
|
-
// How loud the original stays under the voice, in whole percent; the API's
|
|
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).
|
|
177
193
|
const originalLevel = values['original-level']
|
|
194
|
+
// Or none of the original at all, between the lines too (backend ADR 0067).
|
|
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
|
+
}
|
|
178
202
|
if (!OUTPUTS.includes(output)) throw new UsageError(`--output is one of ${OUTPUTS.join(', ')}.`)
|
|
179
203
|
if (!videoFormats) throw new UsageError(`--format is one or more of ${VIDEO_FORMATS.join(', ')}, separated by commas.`)
|
|
180
204
|
if (!AUDIO_FORMATS.includes(audioFormat)) throw new UsageError(`--audio-format is one of ${AUDIO_FORMATS.join(', ')}.`)
|
|
@@ -183,10 +207,13 @@ async function translate(args, { api, err, out, print }) {
|
|
|
183
207
|
throw new UsageError('--original-level is a whole percent from 0 to 100.')
|
|
184
208
|
}
|
|
185
209
|
if (originalLevel !== undefined && output === 'subtitles') throw new UsageError('--original-level is for a voice-over; subtitles lower nothing.')
|
|
210
|
+
if (originalOff && output === 'subtitles') throw new UsageError('--original-off is for a voice-over; subtitles have no sound to turn off.')
|
|
211
|
+
if (originalOff && originalLevel !== undefined) throw new UsageError('--original-off leaves no original to set a level for: use one of them.')
|
|
186
212
|
if (output === 'video' && !isVideo(path)) throw new UsageError('This is an audio file: use --output audio or subtitles.')
|
|
187
213
|
if (!contentType(path)) throw new UsageError('Vocnu takes video and audio files (MP4, MOV, MKV, WebM, MP3, M4A, WAV...).')
|
|
188
|
-
if (voice !== voiceType && !(await api.voices(target)).some((candidate) => candidate.id === voice)) {
|
|
189
|
-
|
|
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}\`.`)
|
|
190
217
|
}
|
|
191
218
|
const { size } = await stat(path)
|
|
192
219
|
|
|
@@ -197,9 +224,19 @@ async function translate(args, { api, err, out, print }) {
|
|
|
197
224
|
source = await api.waitForSource(source.id)
|
|
198
225
|
progress.done(`Ready: ${source.title ?? basename(path)}, ${formatDuration(source.duration_seconds)}`)
|
|
199
226
|
|
|
200
|
-
const
|
|
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)
|
|
201
231
|
const { balance } = await api.credits()
|
|
202
|
-
|
|
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
|
+
}
|
|
203
240
|
if (!values.yes) {
|
|
204
241
|
if (!process.stdin.isTTY) throw new UsageError('Add --yes to start without confirming the price.')
|
|
205
242
|
const answer = (await ask('Start? [y/N] ')).trim().toLowerCase()
|
|
@@ -219,6 +256,8 @@ async function translate(args, { api, err, out, print }) {
|
|
|
219
256
|
voice: voiceType,
|
|
220
257
|
...(voice === voiceType ? {} : { voice_id: voice }),
|
|
221
258
|
...(originalLevel === undefined ? {} : { original_level: Number(originalLevel) }),
|
|
259
|
+
...(originalOff ? { original_off: true } : {}),
|
|
260
|
+
...(values.grade === undefined ? {} : { grade }),
|
|
222
261
|
})
|
|
223
262
|
print(`Started job ${created.job.id} (${created.credit_balance} credits left).`)
|
|
224
263
|
if (values['no-wait']) return 0
|
|
@@ -233,6 +272,16 @@ async function translate(args, { api, err, out, print }) {
|
|
|
233
272
|
return 0
|
|
234
273
|
}
|
|
235
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
|
+
|
|
236
285
|
async function follow(api, id, progress) {
|
|
237
286
|
for (;;) {
|
|
238
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 {
|
|
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) => ({
|
|
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: {
|
|
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
|
|
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
|
-
|
|
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,21 @@ 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
|
|
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'),
|
|
129
|
+
original_off: z.boolean().optional()
|
|
130
|
+
.describe('Turn the original sound off: the voice-over alone, with silence between its lines (no original '
|
|
131
|
+
+ 'voices, music or sound effects). Voice-over only; original_level is then not used'),
|
|
109
132
|
output: z.enum(OUTPUTS),
|
|
110
133
|
sdh: z.boolean().optional()
|
|
111
134
|
.describe('Also SDH subtitles for deaf and hard-of-hearing viewers: sounds, speaker names and songs'),
|
|
@@ -134,9 +157,13 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
134
157
|
video_formats: videoFormats,
|
|
135
158
|
voice: input.voice ?? 'male',
|
|
136
159
|
...(input.voice_id ? { voice_id: input.voice_id } : {}),
|
|
137
|
-
...(input.original_level === undefined ? {} : { original_level: input.original_level }),
|
|
160
|
+
...(input.original_level === undefined || input.original_off ? {} : { original_level: input.original_level }),
|
|
161
|
+
...(input.original_off ? { original_off: true } : {}),
|
|
162
|
+
...(input.grade ? { grade: input.grade } : {}),
|
|
138
163
|
})
|
|
139
|
-
return {
|
|
164
|
+
return {
|
|
165
|
+
balance_after: created.credit_balance, grade: created.job.grade, job_id: created.job.id, status: created.job.status,
|
|
166
|
+
}
|
|
140
167
|
})
|
|
141
168
|
|
|
142
169
|
tool('vocnu_job_status', {
|
|
@@ -202,6 +229,7 @@ function summary(job) {
|
|
|
202
229
|
return {
|
|
203
230
|
error: job.error,
|
|
204
231
|
files: (job.outputs ?? []).map((o) => ({ bytes: o.byte_size, format: o.format, kind: o.kind, language: o.language })),
|
|
232
|
+
grade: job.grade,
|
|
205
233
|
job_id: job.id,
|
|
206
234
|
output: job.products?.voiceover_video ? 'video' : job.products?.voiceover_audio ? 'audio' : 'subtitles',
|
|
207
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) {
|