@mux/ai 0.1.1 → 0.1.3

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.
Files changed (68) hide show
  1. package/LICENSE +10 -18
  2. package/README.md +493 -171
  3. package/dist/index-BNnz9P_5.d.mts +144 -0
  4. package/dist/index-Bnv7tv90.d.ts +477 -0
  5. package/dist/index-DyTSka2R.d.ts +144 -0
  6. package/dist/index-vJ5r2FNm.d.mts +477 -0
  7. package/dist/index.d.mts +13 -0
  8. package/dist/index.d.ts +13 -9
  9. package/dist/index.js +2237 -8
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +2205 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/dist/primitives/index.d.mts +3 -0
  14. package/dist/primitives/index.d.ts +3 -0
  15. package/dist/primitives/index.js +409 -0
  16. package/dist/primitives/index.js.map +1 -0
  17. package/dist/primitives/index.mjs +358 -0
  18. package/dist/primitives/index.mjs.map +1 -0
  19. package/dist/types-ktXDZ93V.d.mts +137 -0
  20. package/dist/types-ktXDZ93V.d.ts +137 -0
  21. package/dist/workflows/index.d.mts +8 -0
  22. package/dist/workflows/index.d.ts +8 -0
  23. package/dist/workflows/index.js +2217 -0
  24. package/dist/workflows/index.js.map +1 -0
  25. package/dist/workflows/index.mjs +2168 -0
  26. package/dist/workflows/index.mjs.map +1 -0
  27. package/package.json +104 -29
  28. package/dist/audio-translation.d.ts +0 -21
  29. package/dist/audio-translation.d.ts.map +0 -1
  30. package/dist/audio-translation.js +0 -229
  31. package/dist/audio-translation.js.map +0 -1
  32. package/dist/burned-in-captions.d.ts +0 -19
  33. package/dist/burned-in-captions.d.ts.map +0 -1
  34. package/dist/burned-in-captions.js +0 -243
  35. package/dist/burned-in-captions.js.map +0 -1
  36. package/dist/chapters.d.ts +0 -18
  37. package/dist/chapters.d.ts.map +0 -1
  38. package/dist/chapters.js +0 -255
  39. package/dist/chapters.js.map +0 -1
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/moderation.d.ts +0 -39
  42. package/dist/moderation.d.ts.map +0 -1
  43. package/dist/moderation.js +0 -341
  44. package/dist/moderation.js.map +0 -1
  45. package/dist/summarization.d.ts +0 -26
  46. package/dist/summarization.d.ts.map +0 -1
  47. package/dist/summarization.js +0 -337
  48. package/dist/summarization.js.map +0 -1
  49. package/dist/translation.d.ts +0 -22
  50. package/dist/translation.d.ts.map +0 -1
  51. package/dist/translation.js +0 -196
  52. package/dist/translation.js.map +0 -1
  53. package/dist/types.d.ts +0 -12
  54. package/dist/types.d.ts.map +0 -1
  55. package/dist/types.js +0 -2
  56. package/dist/types.js.map +0 -1
  57. package/dist/utils/image-download.d.ts +0 -65
  58. package/dist/utils/image-download.d.ts.map +0 -1
  59. package/dist/utils/image-download.js +0 -150
  60. package/dist/utils/image-download.js.map +0 -1
  61. package/dist/utils/storyboard-processor.d.ts +0 -40
  62. package/dist/utils/storyboard-processor.d.ts.map +0 -1
  63. package/dist/utils/storyboard-processor.js +0 -202
  64. package/dist/utils/storyboard-processor.js.map +0 -1
  65. package/dist/utils/vtt-parser.d.ts +0 -8
  66. package/dist/utils/vtt-parser.d.ts.map +0 -1
  67. package/dist/utils/vtt-parser.js +0 -43
  68. package/dist/utils/vtt-parser.js.map +0 -1
package/package.json CHANGED
@@ -1,57 +1,132 @@
1
1
  {
2
2
  "name": "@mux/ai",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "AI library for Mux",
5
- "type": "module",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "default": "./dist/index.js"
13
- }
5
+ "author": "Mux",
6
+ "license": "Apache-2.0",
7
+ "homepage": "https://github.com/muxinc/ai#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/muxinc/ai.git"
14
11
  },
15
- "scripts": {
16
- "build": "tsc",
17
- "dev": "tsc --watch",
18
- "test": "jest",
19
- "lint": "eslint src/**/*.ts",
20
- "typecheck": "tsc --noEmit",
21
- "chapters:basic": "npx ts-node examples/chapters/basic-example.ts",
22
- "burned-in:basic": "npx ts-node examples/burned-in-captions/basic-example.ts"
12
+ "bugs": {
13
+ "url": "https://github.com/muxinc/ai/issues"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "registry": "https://registry.npmjs.org/"
23
18
  },
24
19
  "keywords": [
25
20
  "mux",
21
+ "video",
26
22
  "ai",
23
+ "llm",
24
+ "openai",
25
+ "anthropic",
26
+ "google",
27
+ "gemini",
28
+ "multimodal",
29
+ "video-analysis",
30
+ "summarization",
31
+ "moderation",
32
+ "captions",
33
+ "translation",
34
+ "dubbing",
35
+ "chapters",
36
+ "embeddings",
27
37
  "typescript"
28
38
  ],
29
- "author": "Mux",
30
- "license": "MIT",
31
- "repository": {
32
- "type": "git",
33
- "url": "git+https://github.com/muxinc/mux-ai.git"
39
+ "exports": {
40
+ ".": {
41
+ "types": {
42
+ "import": "./dist/index.d.mts",
43
+ "require": "./dist/index.d.ts"
44
+ },
45
+ "import": "./dist/index.mjs",
46
+ "require": "./dist/index.js"
47
+ },
48
+ "./primitives": {
49
+ "types": {
50
+ "import": "./dist/primitives/index.d.mts",
51
+ "require": "./dist/primitives/index.d.ts"
52
+ },
53
+ "import": "./dist/primitives/index.mjs",
54
+ "require": "./dist/primitives/index.js"
55
+ },
56
+ "./workflows": {
57
+ "types": {
58
+ "import": "./dist/workflows/index.d.mts",
59
+ "require": "./dist/workflows/index.d.ts"
60
+ },
61
+ "import": "./dist/workflows/index.mjs",
62
+ "require": "./dist/workflows/index.js"
63
+ }
34
64
  },
65
+ "main": "./dist/index.js",
66
+ "module": "./dist/index.mjs",
67
+ "types": "./dist/index.d.ts",
35
68
  "files": [
36
69
  "dist"
37
70
  ],
71
+ "engines": {
72
+ "node": ">=20.0.0"
73
+ },
74
+ "scripts": {
75
+ "build": "tsup",
76
+ "dev": "tsup --watch",
77
+ "test": "vitest run",
78
+ "test:watch": "vitest",
79
+ "test:ui": "vitest --ui",
80
+ "test:integration": "vitest run tests/integration",
81
+ "test:unit": "vitest run tests/unit",
82
+ "test:eval": "evalite serve tests/eval",
83
+ "lint": "eslint .",
84
+ "lint:fix": "eslint . --fix",
85
+ "typecheck": "tsc --noEmit",
86
+ "prepublishOnly": "npm run build && npm run typecheck && npm run lint",
87
+ "example:chapters": "npx ts-node --transpile-only --require tsconfig-paths/register examples/chapters/basic-example.ts",
88
+ "example:chapters:compare": "npx ts-node --transpile-only --require tsconfig-paths/register examples/chapters/provider-comparison.ts",
89
+ "example:burned-in": "npx ts-node --transpile-only --require tsconfig-paths/register examples/burned-in-captions/basic-example.ts",
90
+ "example:burned-in:compare": "npx ts-node --transpile-only --require tsconfig-paths/register examples/burned-in-captions/provider-comparison.ts",
91
+ "example:summarization": "npx ts-node --transpile-only --require tsconfig-paths/register examples/summarization/basic-example.ts",
92
+ "example:summarization:compare": "npx ts-node --transpile-only --require tsconfig-paths/register examples/summarization/provider-comparison.ts",
93
+ "example:signed-playback": "npx ts-node --transpile-only --require tsconfig-paths/register examples/signed-playback/signed-playback.ts",
94
+ "example:signed-playback:summarization": "npx ts-node --transpile-only --require tsconfig-paths/register examples/signed-playback/signed-summarization.ts",
95
+ "example:moderation": "npx ts-node --transpile-only --require tsconfig-paths/register examples/moderation/basic-example.ts",
96
+ "example:moderation:compare": "npx ts-node --transpile-only --require tsconfig-paths/register examples/moderation/provider-comparison.ts",
97
+ "example:embeddings": "npx ts-node --transpile-only --require tsconfig-paths/register examples/embeddings/basic-example.ts",
98
+ "example:translate-captions": "npx ts-node --transpile-only --require tsconfig-paths/register examples/translate-captions/basic-example.ts",
99
+ "example:translate-audio": "npx ts-node --transpile-only --require tsconfig-paths/register examples/translate-audio/basic-example.ts",
100
+ "prepare": "husky"
101
+ },
38
102
  "dependencies": {
39
- "@anthropic-ai/sdk": "^0.28.0",
103
+ "@ai-sdk/anthropic": "^2.0.45",
104
+ "@ai-sdk/google": "^2.0.40",
105
+ "@ai-sdk/openai": "^2.0.71",
40
106
  "@aws-sdk/client-s3": "^3.0.0",
41
107
  "@aws-sdk/lib-storage": "^3.0.0",
42
108
  "@aws-sdk/s3-request-presigner": "^3.0.0",
43
109
  "@mux/mux-node": "^12.5.0",
110
+ "ai": "^5.0.98",
44
111
  "dotenv": "^17.2.2",
45
- "openai": "^5.13.1",
112
+ "dotenv-expand": "^12.0.3",
46
113
  "p-retry": "^7.0.0",
47
114
  "zod": "^3.25.76"
48
115
  },
49
116
  "devDependencies": {
117
+ "@antfu/eslint-config": "^6.2.0",
50
118
  "@types/node": "^20.0.0",
51
- "@typescript-eslint/eslint-plugin": "^6.0.0",
52
- "@typescript-eslint/parser": "^6.0.0",
53
- "eslint": "^8.0.0",
119
+ "@vitest/ui": "^4.0.13",
120
+ "commander": "^14.0.2",
121
+ "eslint": "^9.39.1",
122
+ "eslint-plugin-format": "^1.0.2",
123
+ "evalite": "1.0.0-beta.2",
124
+ "husky": "^9.1.7",
54
125
  "jest": "^29.0.0",
55
- "typescript": "^5.0.0"
126
+ "ts-node": "^10.9.2",
127
+ "tsconfig-paths": "^4.2.0",
128
+ "tsup": "^8.5.0",
129
+ "typescript": "^5.0.0",
130
+ "vitest": "^4.0.13"
56
131
  }
57
132
  }
@@ -1,21 +0,0 @@
1
- import { MuxAIOptions } from './types';
2
- export interface AudioTranslationResult {
3
- assetId: string;
4
- targetLanguageCode: string;
5
- dubbingId: string;
6
- uploadedTrackId?: string;
7
- presignedUrl?: string;
8
- }
9
- export interface AudioTranslationOptions extends MuxAIOptions {
10
- provider?: 'elevenlabs';
11
- numSpeakers?: number;
12
- s3Endpoint?: string;
13
- s3Region?: string;
14
- s3Bucket?: string;
15
- s3AccessKeyId?: string;
16
- s3SecretAccessKey?: string;
17
- uploadToMux?: boolean;
18
- elevenLabsApiKey?: string;
19
- }
20
- export declare function translateAudio(assetId: string, toLanguageCode: string, options?: AudioTranslationOptions): Promise<AudioTranslationResult>;
21
- //# sourceMappingURL=audio-translation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"audio-translation.d.ts","sourceRoot":"","sources":["../src/audio-translation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CA4RjC"}
@@ -1,229 +0,0 @@
1
- import Mux from '@mux/mux-node';
2
- // Using direct HTTP requests instead of SDK for better compatibility
3
- import { S3Client } from '@aws-sdk/client-s3';
4
- import { Upload } from '@aws-sdk/lib-storage';
5
- import { GetObjectCommand } from '@aws-sdk/client-s3';
6
- import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
7
- export async function translateAudio(assetId, toLanguageCode, options = {}) {
8
- // Uses the default audio track on your asset, language is auto-detected by ElevenLabs
9
- const { provider = 'elevenlabs', numSpeakers = 0, // 0 = auto-detect
10
- muxTokenId, muxTokenSecret, elevenLabsApiKey, uploadToMux = true, ...config } = options;
11
- if (provider !== 'elevenlabs') {
12
- throw new Error('Only ElevenLabs provider is currently supported for audio translation');
13
- }
14
- // Validate required credentials
15
- const muxId = muxTokenId || process.env.MUX_TOKEN_ID;
16
- const muxSecret = muxTokenSecret || process.env.MUX_TOKEN_SECRET;
17
- const elevenLabsKey = elevenLabsApiKey || process.env.ELEVENLABS_API_KEY;
18
- // S3 configuration
19
- const s3Endpoint = options.s3Endpoint || process.env.S3_ENDPOINT;
20
- const s3Region = options.s3Region || process.env.S3_REGION || 'auto';
21
- const s3Bucket = options.s3Bucket || process.env.S3_BUCKET;
22
- const s3AccessKeyId = options.s3AccessKeyId || process.env.S3_ACCESS_KEY_ID;
23
- const s3SecretAccessKey = options.s3SecretAccessKey || process.env.S3_SECRET_ACCESS_KEY;
24
- if (!muxId || !muxSecret) {
25
- throw new Error('Mux credentials are required. Provide muxTokenId and muxTokenSecret in options or set MUX_TOKEN_ID and MUX_TOKEN_SECRET environment variables.');
26
- }
27
- if (!elevenLabsKey) {
28
- throw new Error('ElevenLabs API key is required. Provide elevenLabsApiKey in options or set ELEVENLABS_API_KEY environment variable.');
29
- }
30
- if (uploadToMux && (!s3Endpoint || !s3Bucket || !s3AccessKeyId || !s3SecretAccessKey)) {
31
- throw new Error('S3 configuration is required for uploading to Mux. Provide s3Endpoint, s3Bucket, s3AccessKeyId, and s3SecretAccessKey in options or set S3_ENDPOINT, S3_BUCKET, S3_ACCESS_KEY_ID, and S3_SECRET_ACCESS_KEY environment variables.');
32
- }
33
- // Initialize clients
34
- const mux = new Mux({
35
- tokenId: muxId,
36
- tokenSecret: muxSecret,
37
- });
38
- // Fetch asset data from Mux
39
- console.log(`🎬 Fetching Mux asset: ${assetId}`);
40
- let assetData;
41
- try {
42
- const asset = await mux.video.assets.retrieve(assetId);
43
- assetData = asset;
44
- }
45
- catch (error) {
46
- throw new Error(`Failed to fetch asset from Mux: ${error instanceof Error ? error.message : 'Unknown error'}`);
47
- }
48
- // Check for audio-only static rendition
49
- console.log('🔍 Checking for audio-only static rendition...');
50
- if (!assetData.static_renditions || !assetData.static_renditions.files) {
51
- throw new Error('No static renditions found for this asset');
52
- }
53
- const staticRenditionFiles = assetData.static_renditions.files;
54
- if (staticRenditionFiles.length === 0) {
55
- throw new Error('No static rendition files found for this asset');
56
- }
57
- const audioRendition = staticRenditionFiles.find((rendition) => rendition.name === 'audio.m4a' && rendition.status === 'ready');
58
- if (!audioRendition) {
59
- throw new Error('No ready audio-only static rendition found for this asset. Please ensure the asset has an audio.m4a static rendition.');
60
- }
61
- const audioUrl = `https://stream.mux.com/${assetData.playback_ids?.[0]?.id}/audio.m4a`;
62
- console.log(`✅ Found audio rendition: ${audioUrl}`);
63
- // Create dubbing job in ElevenLabs
64
- console.log(`🎙️ Creating ElevenLabs dubbing job (auto-detect → ${toLanguageCode})`);
65
- let dubbingId;
66
- try {
67
- // Fetch audio file and create dubbing job
68
- const audioResponse = await fetch(audioUrl);
69
- if (!audioResponse.ok) {
70
- throw new Error(`Failed to fetch audio file: ${audioResponse.statusText}`);
71
- }
72
- const audioBuffer = await audioResponse.arrayBuffer();
73
- const audioBlob = new Blob([audioBuffer], { type: 'audio/mp4' });
74
- const audioFile = audioBlob; // ElevenLabs accepts Blob
75
- // Create dubbing job using direct HTTP request
76
- const formData = new FormData();
77
- formData.append('file', audioFile);
78
- formData.append('target_lang', toLanguageCode);
79
- // Note: source_lang is omitted to enable automatic language detection
80
- formData.append('num_speakers', numSpeakers.toString());
81
- formData.append('name', `Mux Asset ${assetId} - auto to ${toLanguageCode}`);
82
- const dubbingResponse = await fetch('https://api.elevenlabs.io/v1/dubbing', {
83
- method: 'POST',
84
- headers: {
85
- 'xi-api-key': elevenLabsKey
86
- },
87
- body: formData
88
- });
89
- if (!dubbingResponse.ok) {
90
- throw new Error(`ElevenLabs API error: ${dubbingResponse.statusText}`);
91
- }
92
- const dubbingData = await dubbingResponse.json();
93
- dubbingId = dubbingData.dubbing_id;
94
- console.log(`✅ Dubbing job created: ${dubbingId}`);
95
- console.log(`⏱️ Expected duration: ${dubbingData.expected_duration_sec}s`);
96
- }
97
- catch (error) {
98
- throw new Error(`Failed to create ElevenLabs dubbing job: ${error instanceof Error ? error.message : 'Unknown error'}`);
99
- }
100
- // Poll for completion
101
- console.log('⏳ Waiting for dubbing to complete...');
102
- let dubbingStatus = 'dubbing';
103
- let pollAttempts = 0;
104
- const maxPollAttempts = 180; // 30 minutes at 10s intervals
105
- while (dubbingStatus === 'dubbing' && pollAttempts < maxPollAttempts) {
106
- await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds
107
- pollAttempts++;
108
- try {
109
- const statusResponse = await fetch(`https://api.elevenlabs.io/v1/dubbing/${dubbingId}`, {
110
- headers: {
111
- 'xi-api-key': elevenLabsKey
112
- }
113
- });
114
- if (!statusResponse.ok) {
115
- throw new Error(`Status check failed: ${statusResponse.statusText}`);
116
- }
117
- const statusData = await statusResponse.json();
118
- dubbingStatus = statusData.status;
119
- console.log(`📊 Status check ${pollAttempts}: ${dubbingStatus}`);
120
- if (dubbingStatus === 'failed') {
121
- throw new Error('ElevenLabs dubbing job failed');
122
- }
123
- }
124
- catch (error) {
125
- throw new Error(`Failed to check dubbing status: ${error instanceof Error ? error.message : 'Unknown error'}`);
126
- }
127
- }
128
- if (dubbingStatus !== 'dubbed') {
129
- throw new Error(`Dubbing job timed out or failed. Final status: ${dubbingStatus}`);
130
- }
131
- console.log('✅ Dubbing completed successfully!');
132
- // If uploadToMux is false, just return the dubbing info
133
- if (!uploadToMux) {
134
- return {
135
- assetId,
136
- targetLanguageCode: toLanguageCode,
137
- dubbingId
138
- };
139
- }
140
- // Download dubbed audio from ElevenLabs
141
- console.log('📥 Downloading dubbed audio from ElevenLabs...');
142
- let dubbedAudioBuffer;
143
- try {
144
- // Get dubbed audio using fetch (since the SDK method might not be available)
145
- const audioUrl = `https://api.elevenlabs.io/v1/dubbing/${dubbingId}/audio/${toLanguageCode}`;
146
- const audioResponse = await fetch(audioUrl, {
147
- headers: {
148
- 'xi-api-key': elevenLabsKey
149
- }
150
- });
151
- if (!audioResponse.ok) {
152
- throw new Error(`Failed to fetch dubbed audio: ${audioResponse.statusText}`);
153
- }
154
- dubbedAudioBuffer = await audioResponse.arrayBuffer();
155
- console.log(`✅ Downloaded dubbed audio (${dubbedAudioBuffer.byteLength} bytes)`);
156
- }
157
- catch (error) {
158
- throw new Error(`Failed to download dubbed audio: ${error instanceof Error ? error.message : 'Unknown error'}`);
159
- }
160
- // Upload to S3-compatible storage
161
- console.log('📤 Uploading dubbed audio to S3-compatible storage...');
162
- const s3Client = new S3Client({
163
- region: s3Region,
164
- endpoint: s3Endpoint,
165
- credentials: {
166
- accessKeyId: s3AccessKeyId,
167
- secretAccessKey: s3SecretAccessKey
168
- },
169
- forcePathStyle: true
170
- });
171
- // Create unique key for the audio file
172
- const audioKey = `audio-translations/${assetId}/auto-to-${toLanguageCode}-${Date.now()}.m4a`;
173
- let presignedUrl;
174
- try {
175
- // Upload audio to S3
176
- const upload = new Upload({
177
- client: s3Client,
178
- params: {
179
- Bucket: s3Bucket,
180
- Key: audioKey,
181
- Body: new Uint8Array(dubbedAudioBuffer),
182
- ContentType: 'audio/mp4'
183
- }
184
- });
185
- await upload.done();
186
- console.log(`✅ Audio uploaded successfully to: ${audioKey}`);
187
- // Generate presigned URL (valid for 1 hour)
188
- const getObjectCommand = new GetObjectCommand({
189
- Bucket: s3Bucket,
190
- Key: audioKey
191
- });
192
- presignedUrl = await getSignedUrl(s3Client, getObjectCommand, {
193
- expiresIn: 3600 // 1 hour
194
- });
195
- console.log(`🔗 Generated presigned URL (expires in 1 hour)`);
196
- }
197
- catch (error) {
198
- throw new Error(`Failed to upload audio to S3: ${error instanceof Error ? error.message : 'Unknown error'}`);
199
- }
200
- // Add translated audio track to Mux asset
201
- console.log('🎬 Adding translated audio track to Mux asset...');
202
- let uploadedTrackId;
203
- try {
204
- const languageName = new Intl.DisplayNames(['en'], { type: 'language' }).of(toLanguageCode) || toLanguageCode.toUpperCase();
205
- const trackName = `${languageName} (auto-dubbed)`;
206
- const trackResponse = await mux.video.assets.createTrack(assetId, {
207
- type: 'audio',
208
- language_code: toLanguageCode,
209
- name: trackName,
210
- url: presignedUrl
211
- });
212
- uploadedTrackId = trackResponse.id;
213
- console.log(`✅ Audio track added to Mux asset with ID: ${uploadedTrackId}`);
214
- console.log(`🎵 Track name: "${trackName}"`);
215
- }
216
- catch (error) {
217
- console.warn(`⚠️ Failed to add audio track to Mux asset: ${error instanceof Error ? error.message : 'Unknown error'}`);
218
- console.log('🔗 You can manually add the track using this presigned URL:');
219
- console.log(presignedUrl);
220
- }
221
- return {
222
- assetId,
223
- targetLanguageCode: toLanguageCode,
224
- dubbingId,
225
- uploadedTrackId,
226
- presignedUrl
227
- };
228
- }
229
- //# sourceMappingURL=audio-translation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"audio-translation.js","sourceRoot":"","sources":["../src/audio-translation.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,qEAAqE;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAuB7D,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAe,EACf,cAAsB,EACtB,UAAmC,EAAE;IAErC,sFAAsF;IACtF,MAAM,EACJ,QAAQ,GAAG,YAAY,EACvB,WAAW,GAAG,CAAC,EAAE,kBAAkB;IACnC,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,GAAG,IAAI,EAClB,GAAG,MAAM,EACV,GAAG,OAAO,CAAC;IAEZ,IAAI,QAAQ,KAAK,YAAY,EAAE,CAAC;QAC9B,MA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AAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO;QACL,OAAO;QACP,kBAAkB,EAAE,cAAc;QAClC,SAAS;QACT,eAAe;QACf,YAAY;KACb,CAAC;AACJ,CAAC"}
@@ -1,19 +0,0 @@
1
- import { MuxAIOptions } from './types';
2
- import { ImageDownloadOptions } from './utils/image-download';
3
- export interface BurnedInCaptionsResult {
4
- assetId: string;
5
- hasBurnedInCaptions: boolean;
6
- confidence: number;
7
- detectedLanguage: string | null;
8
- storyboardUrl?: string;
9
- }
10
- export interface BurnedInCaptionsOptions extends MuxAIOptions {
11
- provider?: 'openai' | 'anthropic';
12
- model?: string;
13
- /** Method for submitting storyboard to AI providers (default: 'url') */
14
- imageSubmissionMode?: 'url' | 'base64';
15
- /** Options for image download when using base64 submission mode */
16
- imageDownloadOptions?: ImageDownloadOptions;
17
- }
18
- export declare function hasBurnedInCaptions(assetId: string, options?: BurnedInCaptionsOptions): Promise<BurnedInCaptionsResult>;
19
- //# sourceMappingURL=burned-in-captions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"burned-in-captions.d.ts","sourceRoot":"","sources":["../src/burned-in-captions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQ9D,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvC,mEAAmE;IACnE,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAkGD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAgLjC"}