-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample5.mjs
More file actions
82 lines (71 loc) · 2.63 KB
/
example5.mjs
File metadata and controls
82 lines (71 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import fs from 'node:fs';
import process from 'node:process';
import repl from 'node:repl';
import {
Weaver,
StandardAssets,
BrowserAssetGenerator,
BingImageSearchAssetGenerator,
AzureSpeech,
UniversalDirector,
UniversalChoreographer,
WebContent,
} from './dist/src/index.js';
import { UniversalWriter } from './dist/src/writing/universal';
// eslint-disable-next-line
global.readStory = () => {
const json = fs.readFileSync('./try.json');
return JSON.parse(json);
};
global.saveStory = weaver => {
fs.writeFileSync('./try.json', JSON.stringify(weaver.story, null, 2));
// eslint-disable-next-line
console.log('saved');
};
global.weaver = new Weaver({
openaiApiKey: process.env.OPENAI_API_KEY,
supabaseUrl: 'http://localhost:54321',
supabaseServiceRoleKey:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU',
storageBucket: 'assets',
storagePrefix: 'testuser',
story: global.readStory(),
});
global.content = new WebContent('https://news.ycombinator.com', {
executablePath: '/opt/homebrew/bin/chromium',
});
const videoDescription =
"You are a professional briefer for an important executive. Brief me on the key points about this content. Ignore anything about 'subscribing' or the websites themselves, choose some core topics and concentrate on those. Just get into the content, don't bother with an introduction or conclusion. Brief in complete sentences, and be concise.";
global.writer = new UniversalWriter(videoDescription);
const sceneTypes = [
// {
// id: 'image',
// description: 'Display an image full screen, specify which image in the description',
// schema: { image_id: { type: 'string' } },
// },
{
id: 'screenshot',
description: 'Display a screenshot of a web page, specify which web page in the description',
schema: { url_id: { type: 'string' } },
},
// {
// id: 'text',
// description: 'Display some animated text on screen, specify the text in the description',
// schema: { text: { type: 'string' } },
// },
];
global.director = new UniversalDirector(sceneTypes, videoDescription);
global.choreographer = new UniversalChoreographer(sceneTypes);
global.assets = new StandardAssets(
{
image: new BingImageSearchAssetGenerator(process.env.BING_IMAGE_SEARCH_KEY),
url: new BrowserAssetGenerator({ executablePath: '/opt/homebrew/bin/chromium' }),
},
true
);
global.speech = new AzureSpeech(process.env.AZURE_SPEECH_KEY);
const local = repl.start({ useGlobal: true });
local.on('exit', () => {
// eslint-disable-next-line
process.exit();
});