@vargai/sdk 0.1.1

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 (67) hide show
  1. package/.env.example +24 -0
  2. package/CLAUDE.md +118 -0
  3. package/HIGGSFIELD_REWRITE_SUMMARY.md +300 -0
  4. package/README.md +231 -0
  5. package/SKILLS.md +157 -0
  6. package/STRUCTURE.md +92 -0
  7. package/TEST_RESULTS.md +122 -0
  8. package/action/captions/SKILL.md +170 -0
  9. package/action/captions/index.ts +169 -0
  10. package/action/edit/SKILL.md +235 -0
  11. package/action/edit/index.ts +437 -0
  12. package/action/image/SKILL.md +140 -0
  13. package/action/image/index.ts +105 -0
  14. package/action/sync/SKILL.md +136 -0
  15. package/action/sync/index.ts +145 -0
  16. package/action/transcribe/SKILL.md +179 -0
  17. package/action/transcribe/index.ts +210 -0
  18. package/action/video/SKILL.md +116 -0
  19. package/action/video/index.ts +125 -0
  20. package/action/voice/SKILL.md +125 -0
  21. package/action/voice/index.ts +136 -0
  22. package/biome.json +33 -0
  23. package/bun.lock +842 -0
  24. package/cli/commands/find.ts +58 -0
  25. package/cli/commands/help.ts +70 -0
  26. package/cli/commands/list.ts +49 -0
  27. package/cli/commands/run.ts +237 -0
  28. package/cli/commands/which.ts +66 -0
  29. package/cli/discover.ts +66 -0
  30. package/cli/index.ts +33 -0
  31. package/cli/runner.ts +65 -0
  32. package/cli/types.ts +49 -0
  33. package/cli/ui.ts +185 -0
  34. package/index.ts +75 -0
  35. package/lib/README.md +144 -0
  36. package/lib/ai-sdk/fal.ts +106 -0
  37. package/lib/ai-sdk/replicate.ts +107 -0
  38. package/lib/elevenlabs.ts +382 -0
  39. package/lib/fal.ts +467 -0
  40. package/lib/ffmpeg.ts +467 -0
  41. package/lib/fireworks.ts +235 -0
  42. package/lib/groq.ts +246 -0
  43. package/lib/higgsfield/MIGRATION.md +308 -0
  44. package/lib/higgsfield/README.md +273 -0
  45. package/lib/higgsfield/example.ts +228 -0
  46. package/lib/higgsfield/index.ts +241 -0
  47. package/lib/higgsfield/soul.ts +262 -0
  48. package/lib/higgsfield.ts +176 -0
  49. package/lib/remotion/SKILL.md +823 -0
  50. package/lib/remotion/cli.ts +115 -0
  51. package/lib/remotion/functions.ts +283 -0
  52. package/lib/remotion/index.ts +19 -0
  53. package/lib/remotion/templates.ts +73 -0
  54. package/lib/replicate.ts +304 -0
  55. package/output.txt +1 -0
  56. package/package.json +42 -0
  57. package/pipeline/cookbooks/SKILL.md +285 -0
  58. package/pipeline/cookbooks/remotion-video.md +585 -0
  59. package/pipeline/cookbooks/round-video-character.md +337 -0
  60. package/pipeline/cookbooks/talking-character.md +59 -0
  61. package/scripts/produce-menopause-campaign.sh +202 -0
  62. package/service/music/SKILL.md +229 -0
  63. package/service/music/index.ts +296 -0
  64. package/test-import.ts +7 -0
  65. package/test-services.ts +97 -0
  66. package/tsconfig.json +29 -0
  67. package/utilities/s3.ts +147 -0
@@ -0,0 +1,382 @@
1
+ #!/usr/bin/env bun
2
+
3
+ /**
4
+ * elevenlabs api wrapper for voice generation and text-to-speech
5
+ */
6
+
7
+ import { writeFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
10
+
11
+ const elevenlabs = new ElevenLabsClient({
12
+ apiKey: process.env.ELEVENLABS_API_KEY,
13
+ });
14
+
15
+ // types
16
+ export interface TextToSpeechOptions {
17
+ text: string;
18
+ voiceId?: string;
19
+ modelId?: string;
20
+ outputPath?: string;
21
+ }
22
+
23
+ export interface VoiceSettings {
24
+ stability?: number;
25
+ similarityBoost?: number;
26
+ style?: number;
27
+ useSpeakerBoost?: boolean;
28
+ }
29
+
30
+ export interface MusicGenerationOptions {
31
+ prompt?: string;
32
+ musicLengthMs?: number;
33
+ outputPath?: string;
34
+ }
35
+
36
+ export interface SoundEffectOptions {
37
+ text: string;
38
+ durationSeconds?: number;
39
+ promptInfluence?: number;
40
+ loop?: boolean;
41
+ outputPath?: string;
42
+ }
43
+
44
+ // popular voices
45
+ export const VOICES = {
46
+ RACHEL: "21m00Tcm4TlvDq8ikWAM",
47
+ DOMI: "AZnzlk1XvdvUeBnXmlld",
48
+ BELLA: "EXAVITQu4vr4xnSDxMaL",
49
+ ANTONI: "ErXwobaYiN019PkySvjV",
50
+ ELLI: "MF3mGyEYCl7XYWbV9V6O",
51
+ JOSH: "TxGEqnHWrfWFTfGW9XjX",
52
+ ARNOLD: "VR6AewLTigWG4xSOukaG",
53
+ ADAM: "pNInz6obpgDQGcFmaJgB",
54
+ SAM: "yoZ06aMxZJJ28mfd3POQ",
55
+ };
56
+
57
+ // core functions
58
+ export async function textToSpeech(options: TextToSpeechOptions) {
59
+ const {
60
+ text,
61
+ voiceId = VOICES.RACHEL,
62
+ modelId = "eleven_multilingual_v2",
63
+ outputPath,
64
+ } = options;
65
+
66
+ if (!text) {
67
+ throw new Error("text is required");
68
+ }
69
+
70
+ console.log(`[elevenlabs] generating speech with voice ${voiceId}...`);
71
+
72
+ try {
73
+ const audio = await elevenlabs.textToSpeech.convert(voiceId, {
74
+ text,
75
+ modelId,
76
+ outputFormat: "mp3_44100_128",
77
+ });
78
+
79
+ // convert readablestream to buffer
80
+ const reader = audio.getReader();
81
+ const chunks: Uint8Array[] = [];
82
+
83
+ while (true) {
84
+ const { done, value } = await reader.read();
85
+ if (done) break;
86
+ chunks.push(value);
87
+ }
88
+
89
+ const buffer = Buffer.concat(chunks);
90
+
91
+ // save to file if path provided
92
+ if (outputPath) {
93
+ writeFileSync(outputPath, buffer);
94
+ console.log(`[elevenlabs] saved to ${outputPath}`);
95
+ }
96
+
97
+ console.log(`[elevenlabs] generated ${buffer.length} bytes`);
98
+ return buffer;
99
+ } catch (error) {
100
+ console.error(`[elevenlabs] error:`, error);
101
+ throw error;
102
+ }
103
+ }
104
+
105
+ export async function listVoices() {
106
+ console.log(`[elevenlabs] fetching voices...`);
107
+
108
+ try {
109
+ const response = await elevenlabs.voices.getAll();
110
+ console.log(`[elevenlabs] found ${response.voices.length} voices`);
111
+ return response.voices;
112
+ } catch (error) {
113
+ console.error(`[elevenlabs] error:`, error);
114
+ throw error;
115
+ }
116
+ }
117
+
118
+ export async function getVoice(voiceId: string) {
119
+ console.log(`[elevenlabs] fetching voice ${voiceId}...`);
120
+
121
+ try {
122
+ const voice = await elevenlabs.voices.get(voiceId);
123
+ console.log(`[elevenlabs] found voice: ${voice.name}`);
124
+ return voice;
125
+ } catch (error) {
126
+ console.error(`[elevenlabs] error:`, error);
127
+ throw error;
128
+ }
129
+ }
130
+
131
+ export async function generateMusic(options: MusicGenerationOptions) {
132
+ const { prompt, musicLengthMs, outputPath } = options;
133
+
134
+ if (!prompt) {
135
+ throw new Error("prompt is required");
136
+ }
137
+
138
+ console.log(`[elevenlabs] generating music from prompt: "${prompt}"...`);
139
+
140
+ try {
141
+ const audio = await elevenlabs.music.compose({
142
+ prompt,
143
+ musicLengthMs,
144
+ modelId: "music_v1",
145
+ });
146
+
147
+ // convert readablestream to buffer
148
+ const reader = audio.getReader();
149
+ const chunks: Uint8Array[] = [];
150
+
151
+ while (true) {
152
+ const { done, value } = await reader.read();
153
+ if (done) break;
154
+ chunks.push(value);
155
+ }
156
+
157
+ const buffer = Buffer.concat(chunks);
158
+
159
+ // save to file if path provided
160
+ if (outputPath) {
161
+ writeFileSync(outputPath, buffer);
162
+ console.log(`[elevenlabs] saved to ${outputPath}`);
163
+ }
164
+
165
+ console.log(`[elevenlabs] generated ${buffer.length} bytes`);
166
+ return buffer;
167
+ } catch (error) {
168
+ console.error(`[elevenlabs] error:`, error);
169
+ throw error;
170
+ }
171
+ }
172
+
173
+ export async function generateSoundEffect(options: SoundEffectOptions) {
174
+ const {
175
+ text,
176
+ durationSeconds,
177
+ promptInfluence = 0.3,
178
+ loop = false,
179
+ outputPath,
180
+ } = options;
181
+
182
+ if (!text) {
183
+ throw new Error("text is required");
184
+ }
185
+
186
+ console.log(`[elevenlabs] generating sound effect: "${text}"...`);
187
+
188
+ try {
189
+ const audio = await elevenlabs.textToSoundEffects.convert({
190
+ text,
191
+ durationSeconds,
192
+ promptInfluence,
193
+ loop,
194
+ });
195
+
196
+ // convert readablestream to buffer
197
+ const reader = audio.getReader();
198
+ const chunks: Uint8Array[] = [];
199
+
200
+ while (true) {
201
+ const { done, value } = await reader.read();
202
+ if (done) break;
203
+ chunks.push(value);
204
+ }
205
+
206
+ const buffer = Buffer.concat(chunks);
207
+
208
+ // save to file if path provided
209
+ if (outputPath) {
210
+ writeFileSync(outputPath, buffer);
211
+ console.log(`[elevenlabs] saved to ${outputPath}`);
212
+ }
213
+
214
+ console.log(`[elevenlabs] generated ${buffer.length} bytes`);
215
+ return buffer;
216
+ } catch (error) {
217
+ console.error(`[elevenlabs] error:`, error);
218
+ throw error;
219
+ }
220
+ }
221
+
222
+ // cli
223
+ async function cli() {
224
+ const args = process.argv.slice(2);
225
+ const command = args[0];
226
+
227
+ if (!command || command === "help") {
228
+ console.log(`
229
+ usage:
230
+ bun run lib/elevenlabs.ts <command> [args]
231
+
232
+ commands:
233
+ tts <text> [voiceId] [outputPath] generate speech from text
234
+ music <prompt> [lengthMs] [outputPath] generate music from prompt
235
+ sfx <text> [durationSec] [outputPath] generate sound effect
236
+ voices list available voices
237
+ voice <voiceId> get voice details
238
+ help show this help
239
+
240
+ examples:
241
+ bun run lib/elevenlabs.ts tts "hello world" rachel output.mp3
242
+ bun run lib/elevenlabs.ts music "upbeat electronic dance music" 30000 music.mp3
243
+ bun run lib/elevenlabs.ts sfx "ocean waves crashing" 5 waves.mp3
244
+ bun run lib/elevenlabs.ts voices
245
+ bun run lib/elevenlabs.ts voice 21m00Tcm4TlvDq8ikWAM
246
+
247
+ popular voices:
248
+ rachel - 21m00Tcm4TlvDq8ikWAM (american female)
249
+ domi - AZnzlk1XvdvUeBnXmlld (american female)
250
+ bella - EXAVITQu4vr4xnSDxMaL (american female)
251
+ antoni - ErXwobaYiN019PkySvjV (american male)
252
+ elli - MF3mGyEYCl7XYWbV9V6O (american female)
253
+ josh - TxGEqnHWrfWFTfGW9XjX (american male)
254
+ arnold - VR6AewLTigWG4xSOukaG (american male)
255
+ adam - pNInz6obpgDQGcFmaJgB (american male)
256
+ sam - yoZ06aMxZJJ28mfd3POQ (american male)
257
+
258
+ environment:
259
+ ELEVENLABS_API_KEY - your elevenlabs api key
260
+ `);
261
+ process.exit(0);
262
+ }
263
+
264
+ try {
265
+ switch (command) {
266
+ case "tts": {
267
+ const text = args[1];
268
+ let voiceId = args[2];
269
+ const outputPath = args[3];
270
+
271
+ if (!text) {
272
+ throw new Error("text is required");
273
+ }
274
+
275
+ // map voice names to ids
276
+ const voiceNameMap: Record<string, string> = {
277
+ rachel: VOICES.RACHEL,
278
+ domi: VOICES.DOMI,
279
+ bella: VOICES.BELLA,
280
+ antoni: VOICES.ANTONI,
281
+ elli: VOICES.ELLI,
282
+ josh: VOICES.JOSH,
283
+ arnold: VOICES.ARNOLD,
284
+ adam: VOICES.ADAM,
285
+ sam: VOICES.SAM,
286
+ };
287
+
288
+ if (voiceId && voiceNameMap[voiceId.toLowerCase()]) {
289
+ voiceId = voiceNameMap[voiceId.toLowerCase()];
290
+ }
291
+
292
+ const buffer = await textToSpeech({
293
+ text,
294
+ voiceId,
295
+ outputPath: outputPath || join(process.cwd(), "output.mp3"),
296
+ });
297
+
298
+ console.log(`[elevenlabs] generated ${buffer.length} bytes`);
299
+ break;
300
+ }
301
+
302
+ case "voices": {
303
+ const voices = await listVoices();
304
+ console.log(
305
+ `\navailable voices:\n${voices.map((v) => ` ${v.voiceId} - ${v.name}`).join("\n")}`,
306
+ );
307
+ break;
308
+ }
309
+
310
+ case "voice": {
311
+ const voiceId = args[1];
312
+
313
+ if (!voiceId) {
314
+ throw new Error("voiceId is required");
315
+ }
316
+
317
+ const voice = await getVoice(voiceId);
318
+ console.log(`\nvoice details:`, {
319
+ id: voice.voiceId,
320
+ name: voice.name,
321
+ category: voice.category,
322
+ labels: voice.labels,
323
+ });
324
+ break;
325
+ }
326
+
327
+ case "music": {
328
+ const prompt = args[1];
329
+ const musicLengthMs = args[2]
330
+ ? Number.parseInt(args[2], 10)
331
+ : undefined;
332
+ const outputPath = args[3];
333
+
334
+ if (!prompt) {
335
+ throw new Error("prompt is required");
336
+ }
337
+
338
+ const buffer = await generateMusic({
339
+ prompt,
340
+ musicLengthMs,
341
+ outputPath: outputPath || join(process.cwd(), "music.mp3"),
342
+ });
343
+
344
+ console.log(`[elevenlabs] generated ${buffer.length} bytes`);
345
+ break;
346
+ }
347
+
348
+ case "sfx": {
349
+ const text = args[1];
350
+ const durationSeconds = args[2]
351
+ ? Number.parseFloat(args[2])
352
+ : undefined;
353
+ const outputPath = args[3];
354
+
355
+ if (!text) {
356
+ throw new Error("text is required");
357
+ }
358
+
359
+ const buffer = await generateSoundEffect({
360
+ text,
361
+ durationSeconds,
362
+ outputPath: outputPath || join(process.cwd(), "sfx.mp3"),
363
+ });
364
+
365
+ console.log(`[elevenlabs] generated ${buffer.length} bytes`);
366
+ break;
367
+ }
368
+
369
+ default:
370
+ console.error(`unknown command: ${command}`);
371
+ console.log(`run 'bun run lib/elevenlabs.ts help' for usage`);
372
+ process.exit(1);
373
+ }
374
+ } catch (error) {
375
+ console.error(`[elevenlabs] error:`, error);
376
+ process.exit(1);
377
+ }
378
+ }
379
+
380
+ if (import.meta.main) {
381
+ cli();
382
+ }