vocnu 0.2.0 → 0.4.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 +2 -1
- package/package.json +1 -1
- package/src/cli.js +13 -4
- package/src/mcp.js +11 -4
package/README.md
CHANGED
|
@@ -26,10 +26,11 @@ 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
|
-
| `--voice female
|
|
29
|
+
| `--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
30
|
| `--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
31
|
| `--audio-format m4a\|mp3\|wav\|flac\|ogg` | voice-over audio format |
|
|
32
32
|
| `--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 |
|
|
33
34
|
| `--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`) |
|
|
34
35
|
| `--out <dir>` | where the results go |
|
|
35
36
|
| `--yes` | start without confirming the price |
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -26,10 +26,11 @@ Usage:
|
|
|
26
26
|
vocnu translate <file> --to <lang> Upload, see the price, translate and download the results
|
|
27
27
|
--output video|audio|subtitles What you get (default: video for a video file, else audio)
|
|
28
28
|
--from <lang> Spoken language (default: detected)
|
|
29
|
-
--voice female
|
|
29
|
+
--voice male|female|<voice id> A voice type, or a voice from \`vocnu voices\` (default: male)
|
|
30
30
|
--format mp4|mkv|mov|webm|avi Video file format, or several: mp4,mkv (default: the upload's, else mp4)
|
|
31
31
|
--audio-format m4a|mp3|wav|flac|ogg
|
|
32
32
|
--burn-subtitles Subtitles burned into the picture
|
|
33
|
+
--original-level <0-100> How loud the original stays under the voice, in % (default: 40)
|
|
33
34
|
--sdh SDH subtitles too: sounds, speaker names and songs, for deaf and
|
|
34
35
|
hard-of-hearing viewers (subtitles may be in the spoken language)
|
|
35
36
|
--out <directory> Where the results go (default: next to the file)
|
|
@@ -156,6 +157,7 @@ async function translate(args, { api, err, out, print }) {
|
|
|
156
157
|
format: { type: 'string' },
|
|
157
158
|
from: { type: 'string' },
|
|
158
159
|
'no-wait': { type: 'boolean' },
|
|
160
|
+
'original-level': { type: 'string' },
|
|
159
161
|
out: { type: 'string' },
|
|
160
162
|
output: { type: 'string' },
|
|
161
163
|
sdh: { type: 'boolean' },
|
|
@@ -169,12 +171,18 @@ async function translate(args, { api, err, out, print }) {
|
|
|
169
171
|
const videoFormats = values.format === undefined ? [defaultVideoFormat(path)] : videoFormatsFrom(values.format)
|
|
170
172
|
const audioFormat = values['audio-format'] ?? 'm4a'
|
|
171
173
|
// A voice type, or a catalog voice of the target language, whose type the API takes.
|
|
172
|
-
const voice = values.voice ?? '
|
|
173
|
-
const voiceType = ['
|
|
174
|
+
const voice = values.voice ?? 'male'
|
|
175
|
+
const voiceType = ['male', 'female'].includes(voice) ? voice : 'male'
|
|
176
|
+
// How loud the original stays under the voice, in whole percent; the API's default (40) when not given.
|
|
177
|
+
const originalLevel = values['original-level']
|
|
174
178
|
if (!OUTPUTS.includes(output)) throw new UsageError(`--output is one of ${OUTPUTS.join(', ')}.`)
|
|
175
179
|
if (!videoFormats) throw new UsageError(`--format is one or more of ${VIDEO_FORMATS.join(', ')}, separated by commas.`)
|
|
176
180
|
if (!AUDIO_FORMATS.includes(audioFormat)) throw new UsageError(`--audio-format is one of ${AUDIO_FORMATS.join(', ')}.`)
|
|
177
|
-
if (!/^[a-z0-9-]+$/.test(voice)) throw new UsageError('--voice is
|
|
181
|
+
if (!/^[a-z0-9-]+$/.test(voice)) throw new UsageError('--voice is male, female or a voice id from `vocnu voices <lang>`.')
|
|
182
|
+
if (originalLevel !== undefined && !(/^\d{1,3}$/.test(originalLevel) && Number(originalLevel) <= 100)) {
|
|
183
|
+
throw new UsageError('--original-level is a whole percent from 0 to 100.')
|
|
184
|
+
}
|
|
185
|
+
if (originalLevel !== undefined && output === 'subtitles') throw new UsageError('--original-level is for a voice-over; subtitles lower nothing.')
|
|
178
186
|
if (output === 'video' && !isVideo(path)) throw new UsageError('This is an audio file: use --output audio or subtitles.')
|
|
179
187
|
if (!contentType(path)) throw new UsageError('Vocnu takes video and audio files (MP4, MOV, MKV, WebM, MP3, M4A, WAV...).')
|
|
180
188
|
if (voice !== voiceType && !(await api.voices(target)).some((candidate) => candidate.id === voice)) {
|
|
@@ -210,6 +218,7 @@ async function translate(args, { api, err, out, print }) {
|
|
|
210
218
|
video_formats: videoFormats,
|
|
211
219
|
voice: voiceType,
|
|
212
220
|
...(voice === voiceType ? {} : { voice_id: voice }),
|
|
221
|
+
...(originalLevel === undefined ? {} : { original_level: Number(originalLevel) }),
|
|
213
222
|
})
|
|
214
223
|
print(`Started job ${created.job.id} (${created.credit_balance} credits left).`)
|
|
215
224
|
if (values['no-wait']) return 0
|
package/src/mcp.js
CHANGED
|
@@ -60,7 +60,8 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
60
60
|
tool('vocnu_upload_media', {
|
|
61
61
|
description: 'Upload a local video or audio file (up to 10 GB) to Vocnu, wait until it is analysed and return its '
|
|
62
62
|
+ 'source_id, length and price in credits for each output. Nothing is charged until vocnu_start_job. '
|
|
63
|
-
+ '
|
|
63
|
+
+ 'captions_only is true for a video nobody speaks in whose story is told in captions burned into the picture: '
|
|
64
|
+
+ 'Vocnu narrates the captions. Large files take minutes to upload.',
|
|
64
65
|
inputSchema: { path: z.string().describe('Path of the video or audio file on this computer') },
|
|
65
66
|
title: 'Upload media to Vocnu',
|
|
66
67
|
}, async ({ path }) => {
|
|
@@ -70,6 +71,7 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
70
71
|
const { balance } = await api.credits()
|
|
71
72
|
return {
|
|
72
73
|
balance,
|
|
74
|
+
captions_only: source.captions_only === true,
|
|
73
75
|
duration_seconds: source.duration_seconds,
|
|
74
76
|
has_video: source.has_video,
|
|
75
77
|
price_credits: {
|
|
@@ -96,10 +98,14 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
96
98
|
+ 'is the video with the voice-over, "audio" the voice-over audio, "subtitles" subtitles only; every output '
|
|
97
99
|
+ 'also includes subtitles. sdh adds SDH subtitles (sound descriptions, speaker names, songs) for deaf and '
|
|
98
100
|
+ 'hard-of-hearing viewers to any output, at the sdh_extra price. Subtitles may be in the spoken language '
|
|
99
|
-
+ '(target_language = source_language, e.g. German SDH of a German film); a voice-over may not
|
|
101
|
+
+ '(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.',
|
|
100
103
|
inputSchema: {
|
|
101
104
|
audio_format: z.enum(AUDIO_FORMATS).optional().describe('Voice-over audio format (default m4a)'),
|
|
102
105
|
burn_subtitles: z.boolean().optional().describe('Burn the subtitles into the picture (video only)'),
|
|
106
|
+
original_level: z.number().int().min(0).max(100).optional()
|
|
107
|
+
.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'),
|
|
103
109
|
output: z.enum(OUTPUTS),
|
|
104
110
|
sdh: z.boolean().optional()
|
|
105
111
|
.describe('Also SDH subtitles for deaf and hard-of-hearing viewers: sounds, speaker names and songs'),
|
|
@@ -110,7 +116,7 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
110
116
|
video_formats: z.array(z.enum(VIDEO_FORMATS)).min(1).optional()
|
|
111
117
|
.describe('Several video file formats at once, e.g. ["mp4", "mkv"], each its own file (instead of '
|
|
112
118
|
+ 'video_format); they cost what the dearest of them costs'),
|
|
113
|
-
voice: z.enum(['
|
|
119
|
+
voice: z.enum(['male', 'female']).optional().describe('Voice type (default male), read by the language\'s '
|
|
114
120
|
+ 'default voice of that type'),
|
|
115
121
|
voice_id: z.string().optional().describe('A voice of the target language from vocnu_voices, instead of a type'),
|
|
116
122
|
},
|
|
@@ -126,8 +132,9 @@ export function createServer(api, { cwd = process.cwd() } = {}) {
|
|
|
126
132
|
target_language: input.target_language,
|
|
127
133
|
video_format: videoFormats[0],
|
|
128
134
|
video_formats: videoFormats,
|
|
129
|
-
voice: input.voice ?? '
|
|
135
|
+
voice: input.voice ?? 'male',
|
|
130
136
|
...(input.voice_id ? { voice_id: input.voice_id } : {}),
|
|
137
|
+
...(input.original_level === undefined ? {} : { original_level: input.original_level }),
|
|
131
138
|
})
|
|
132
139
|
return { balance_after: created.credit_balance, job_id: created.job.id, status: created.job.status }
|
|
133
140
|
})
|