@osaas/cli 0.7.1 → 0.9.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/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/intercom/cmd.d.ts +3 -0
- package/dist/intercom/cmd.d.ts.map +1 -0
- package/dist/intercom/cmd.js +82 -0
- package/dist/intercom/cmd.js.map +1 -0
- package/dist/transcribe/cmd.d.ts +3 -0
- package/dist/transcribe/cmd.d.ts.map +1 -0
- package/dist/transcribe/cmd.js +37 -0
- package/dist/transcribe/cmd.js.map +1 -0
- package/package.json +5 -4
- package/src/cli.ts +4 -0
- package/src/intercom/cmd.ts +87 -0
- package/src/transcribe/cmd.ts +34 -0
package/dist/cli.js
CHANGED
|
@@ -34,6 +34,8 @@ const cmd_2 = __importDefault(require("./transcode/cmd"));
|
|
|
34
34
|
const cmd_3 = __importDefault(require("./vmaf/cmd"));
|
|
35
35
|
const cmd_4 = __importDefault(require("./packager/cmd"));
|
|
36
36
|
const cmd_5 = __importDefault(require("./live/cmd"));
|
|
37
|
+
const cmd_6 = __importDefault(require("./intercom/cmd"));
|
|
38
|
+
const cmd_7 = __importDefault(require("./transcribe/cmd"));
|
|
37
39
|
const cli = new commander_1.Command();
|
|
38
40
|
cli
|
|
39
41
|
.configureHelp({ showGlobalOptions: true })
|
|
@@ -46,5 +48,7 @@ cli.addCommand((0, cmd_2.default)());
|
|
|
46
48
|
cli.addCommand((0, cmd_4.default)());
|
|
47
49
|
cli.addCommand((0, cmd_3.default)());
|
|
48
50
|
cli.addCommand((0, cmd_5.default)());
|
|
51
|
+
cli.addCommand((0, cmd_6.default)());
|
|
52
|
+
cli.addCommand((0, cmd_7.default)());
|
|
49
53
|
cli.parse(process.argv);
|
|
50
54
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.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C,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cmd.d.ts","sourceRoot":"","sources":["../../src/intercom/cmd.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,CAAC,OAAO,UAAU,WAAW,YAiFlC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_core_1 = require("@osaas/client-core");
|
|
4
|
+
const client_intercom_1 = require("@osaas/client-intercom");
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const util_1 = require("../user/util");
|
|
7
|
+
function cmdIntercom() {
|
|
8
|
+
const intercom = new commander_1.Command('intercom');
|
|
9
|
+
intercom
|
|
10
|
+
.command('list-productions')
|
|
11
|
+
.description('List production in Open Source Cloud Intercom System')
|
|
12
|
+
.argument('<name>', 'Intercom system name')
|
|
13
|
+
.action(async (name, options, command) => {
|
|
14
|
+
try {
|
|
15
|
+
const globalOpts = command.optsWithGlobals();
|
|
16
|
+
const environment = globalOpts?.env || 'prod';
|
|
17
|
+
const ctx = new client_core_1.Context({ environment });
|
|
18
|
+
const intercom = new client_intercom_1.IntercomSystem({ context: ctx, name });
|
|
19
|
+
await intercom.init();
|
|
20
|
+
const productions = await intercom.listProductions();
|
|
21
|
+
for (const production of productions) {
|
|
22
|
+
console.log(production.productionId + ': ' + production.name);
|
|
23
|
+
const lines = await intercom.listLinesForProduction(production.productionId);
|
|
24
|
+
lines.map((line) => console.log('+-- ' +
|
|
25
|
+
line.id +
|
|
26
|
+
': ' +
|
|
27
|
+
line.name +
|
|
28
|
+
` (${line.participants.length})`));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
console.log(err.message);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
intercom
|
|
36
|
+
.command('create-production')
|
|
37
|
+
.description('Create production in Open Source Cloud Intercom System')
|
|
38
|
+
.argument('<name>', 'Intercom system name')
|
|
39
|
+
.argument('<production>', 'Production name to create')
|
|
40
|
+
.argument('<lines...>', 'List of lines to create')
|
|
41
|
+
.action(async (name, production, lines, options, command) => {
|
|
42
|
+
try {
|
|
43
|
+
const globalOpts = command.optsWithGlobals();
|
|
44
|
+
const environment = globalOpts?.env || 'prod';
|
|
45
|
+
const ctx = new client_core_1.Context({ environment });
|
|
46
|
+
const intercom = new client_intercom_1.IntercomSystem({ context: ctx, name });
|
|
47
|
+
await intercom.init();
|
|
48
|
+
const productions = await intercom.listProductions();
|
|
49
|
+
if (productions.find((p) => p.name === production)) {
|
|
50
|
+
console.log(`Production ${production} already exists`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const p = await intercom.createProduction(production, lines);
|
|
54
|
+
console.log(`Production '${p.name}' created with id ${p.productionId}`);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
console.log(err.message);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
intercom
|
|
61
|
+
.command('delete-production')
|
|
62
|
+
.description('Delete production in Open Source Cloud Intercom System')
|
|
63
|
+
.argument('<name>', 'Intercom system name')
|
|
64
|
+
.argument('<id>', 'Id of production to delete')
|
|
65
|
+
.action(async (name, id, options, command) => {
|
|
66
|
+
try {
|
|
67
|
+
const globalOpts = command.optsWithGlobals();
|
|
68
|
+
const environment = globalOpts?.env || 'prod';
|
|
69
|
+
const ctx = new client_core_1.Context({ environment });
|
|
70
|
+
const intercom = new client_intercom_1.IntercomSystem({ context: ctx, name });
|
|
71
|
+
await intercom.init();
|
|
72
|
+
await (0, util_1.confirm)('Are you sure you want to remove this production? (yes/no) ');
|
|
73
|
+
await intercom.deleteProduction(id);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
console.log(err.message);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return intercom;
|
|
80
|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":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,OAAO,UAAU,aAAa,YA6BpC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_core_1 = require("@osaas/client-core");
|
|
4
|
+
const client_transcode_1 = require("@osaas/client-transcode");
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
function cmdTranscribe() {
|
|
7
|
+
const transcriber = new commander_1.Command('transcribe');
|
|
8
|
+
transcriber
|
|
9
|
+
.description('Generate subtitles from video or audio using Open AI Whisper')
|
|
10
|
+
.argument('<source>', 'Source URL (supported protocols: http, https)')
|
|
11
|
+
.option('-f, --format', 'Output format (default: vtt)')
|
|
12
|
+
.option('-l, --language', 'Language (default: en)')
|
|
13
|
+
.action(async (source, options, command) => {
|
|
14
|
+
try {
|
|
15
|
+
const globalOpts = command.optsWithGlobals();
|
|
16
|
+
const environment = globalOpts?.env || 'prod';
|
|
17
|
+
const ctx = new client_core_1.Context({ environment });
|
|
18
|
+
const format = options.format || 'vtt';
|
|
19
|
+
const language = options.language || 'en';
|
|
20
|
+
const pool = new client_transcode_1.SubtitlingPool({ context: ctx, size: 1 });
|
|
21
|
+
if (!process.env.OPENAI_API_KEY) {
|
|
22
|
+
throw new Error('Environment variable OPENAI_API_KEY not set');
|
|
23
|
+
}
|
|
24
|
+
await pool.init({
|
|
25
|
+
openaikey: process.env.OPENAI_API_KEY
|
|
26
|
+
});
|
|
27
|
+
const result = await pool.transcribe(new URL(source), language, format);
|
|
28
|
+
console.log(result);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
console.log(err.message);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return transcriber;
|
|
35
|
+
}
|
|
36
|
+
exports.default = cmdTranscribe;
|
|
37
|
+
//# sourceMappingURL=cmd.js.map
|
|
@@ -0,0 +1 @@
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AC;YACxE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SACrB;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,GAAG,CAAE,GAAa,CAAC,OAAO,CAAC,CAAC;SACrC;IACH,CAAC,CAAC,CAAC;IACL,OAAO,WAAW,CAAC;AACrB,CAAC;AA7BD,gCA6BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osaas/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Open Source Cloud CLI",
|
|
5
5
|
"author": "Eyevinn Technology <work@eyevinn.se>",
|
|
6
6
|
"homepage": "https://www.osaas.io",
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
"test": "jest --pass-with-no-tests"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@osaas/client-core": "^0.
|
|
25
|
-
"@osaas/client-
|
|
24
|
+
"@osaas/client-core": "^0.8.0",
|
|
25
|
+
"@osaas/client-intercom": "^0.1.0",
|
|
26
|
+
"@osaas/client-transcode": "^0.7.0",
|
|
26
27
|
"chalk": "4.1.2",
|
|
27
28
|
"commander": "^12.1.0",
|
|
28
29
|
"fast-jwt": "^4.0.1"
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
"publishConfig": {
|
|
31
32
|
"access": "public"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "c39b000939857bd0ebc7ae2c5b497ceea018b2eb"
|
|
34
35
|
}
|
package/src/cli.ts
CHANGED
|
@@ -7,6 +7,8 @@ import cmdTranscode from './transcode/cmd';
|
|
|
7
7
|
import cmdCompare from './vmaf/cmd';
|
|
8
8
|
import cmdPackager from './packager/cmd';
|
|
9
9
|
import cmdLive from './live/cmd';
|
|
10
|
+
import cmdIntercom from './intercom/cmd';
|
|
11
|
+
import cmdTranscribe from './transcribe/cmd';
|
|
10
12
|
|
|
11
13
|
const cli = new Command();
|
|
12
14
|
|
|
@@ -21,4 +23,6 @@ cli.addCommand(cmdTranscode());
|
|
|
21
23
|
cli.addCommand(cmdPackager());
|
|
22
24
|
cli.addCommand(cmdCompare());
|
|
23
25
|
cli.addCommand(cmdLive());
|
|
26
|
+
cli.addCommand(cmdIntercom());
|
|
27
|
+
cli.addCommand(cmdTranscribe());
|
|
24
28
|
cli.parse(process.argv);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Context } from '@osaas/client-core';
|
|
2
|
+
import { IntercomSystem } from '@osaas/client-intercom';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { confirm } from '../user/util';
|
|
5
|
+
|
|
6
|
+
export default function cmdIntercom() {
|
|
7
|
+
const intercom = new Command('intercom');
|
|
8
|
+
|
|
9
|
+
intercom
|
|
10
|
+
.command('list-productions')
|
|
11
|
+
.description('List production in Open Source Cloud Intercom System')
|
|
12
|
+
.argument('<name>', 'Intercom system name')
|
|
13
|
+
.action(async (name, options, command) => {
|
|
14
|
+
try {
|
|
15
|
+
const globalOpts = command.optsWithGlobals();
|
|
16
|
+
const environment = globalOpts?.env || 'prod';
|
|
17
|
+
const ctx = new Context({ environment });
|
|
18
|
+
const intercom = new IntercomSystem({ context: ctx, name });
|
|
19
|
+
await intercom.init();
|
|
20
|
+
const productions = await intercom.listProductions();
|
|
21
|
+
for (const production of productions) {
|
|
22
|
+
console.log(production.productionId + ': ' + production.name);
|
|
23
|
+
const lines = await intercom.listLinesForProduction(
|
|
24
|
+
production.productionId
|
|
25
|
+
);
|
|
26
|
+
lines.map((line: any) =>
|
|
27
|
+
console.log(
|
|
28
|
+
'+-- ' +
|
|
29
|
+
line.id +
|
|
30
|
+
': ' +
|
|
31
|
+
line.name +
|
|
32
|
+
` (${line.participants.length})`
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.log((err as Error).message);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
intercom
|
|
42
|
+
.command('create-production')
|
|
43
|
+
.description('Create production in Open Source Cloud Intercom System')
|
|
44
|
+
.argument('<name>', 'Intercom system name')
|
|
45
|
+
.argument('<production>', 'Production name to create')
|
|
46
|
+
.argument('<lines...>', 'List of lines to create')
|
|
47
|
+
.action(async (name, production, lines, options, command) => {
|
|
48
|
+
try {
|
|
49
|
+
const globalOpts = command.optsWithGlobals();
|
|
50
|
+
const environment = globalOpts?.env || 'prod';
|
|
51
|
+
const ctx = new Context({ environment });
|
|
52
|
+
const intercom = new IntercomSystem({ context: ctx, name });
|
|
53
|
+
await intercom.init();
|
|
54
|
+
const productions = await intercom.listProductions();
|
|
55
|
+
if (productions.find((p: any) => p.name === production)) {
|
|
56
|
+
console.log(`Production ${production} already exists`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const p = await intercom.createProduction(production, lines);
|
|
60
|
+
console.log(`Production '${p.name}' created with id ${p.productionId}`);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
console.log((err as Error).message);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
intercom
|
|
67
|
+
.command('delete-production')
|
|
68
|
+
.description('Delete production in Open Source Cloud Intercom System')
|
|
69
|
+
.argument('<name>', 'Intercom system name')
|
|
70
|
+
.argument('<id>', 'Id of production to delete')
|
|
71
|
+
.action(async (name, id, options, command) => {
|
|
72
|
+
try {
|
|
73
|
+
const globalOpts = command.optsWithGlobals();
|
|
74
|
+
const environment = globalOpts?.env || 'prod';
|
|
75
|
+
const ctx = new Context({ environment });
|
|
76
|
+
const intercom = new IntercomSystem({ context: ctx, name });
|
|
77
|
+
await intercom.init();
|
|
78
|
+
await confirm(
|
|
79
|
+
'Are you sure you want to remove this production? (yes/no) '
|
|
80
|
+
);
|
|
81
|
+
await intercom.deleteProduction(id);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.log((err as Error).message);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return intercom;
|
|
87
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Context } from '@osaas/client-core';
|
|
2
|
+
import { SubtitlingPool } from '@osaas/client-transcode';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
|
|
5
|
+
export default function cmdTranscribe() {
|
|
6
|
+
const transcriber = new Command('transcribe');
|
|
7
|
+
|
|
8
|
+
transcriber
|
|
9
|
+
.description('Generate subtitles from video or audio using Open AI Whisper')
|
|
10
|
+
.argument('<source>', 'Source URL (supported protocols: http, https)')
|
|
11
|
+
.option('-f, --format', 'Output format (default: vtt)')
|
|
12
|
+
.option('-l, --language', 'Language (default: en)')
|
|
13
|
+
.action(async (source, options, command) => {
|
|
14
|
+
try {
|
|
15
|
+
const globalOpts = command.optsWithGlobals();
|
|
16
|
+
const environment = globalOpts?.env || 'prod';
|
|
17
|
+
const ctx = new Context({ environment });
|
|
18
|
+
const format = options.format || 'vtt';
|
|
19
|
+
const language = options.language || 'en';
|
|
20
|
+
const pool = new SubtitlingPool({ context: ctx, size: 1 });
|
|
21
|
+
if (!process.env.OPENAI_API_KEY) {
|
|
22
|
+
throw new Error('Environment variable OPENAI_API_KEY not set');
|
|
23
|
+
}
|
|
24
|
+
await pool.init({
|
|
25
|
+
openaikey: process.env.OPENAI_API_KEY
|
|
26
|
+
});
|
|
27
|
+
const result = await pool.transcribe(new URL(source), language, format);
|
|
28
|
+
console.log(result);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.log((err as Error).message);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return transcriber;
|
|
34
|
+
}
|