save chrrent changes
This commit is contained in:
54
src/index.ts
54
src/index.ts
@ -3,6 +3,7 @@ import { describeImage } from './lib/image-describer';
|
||||
import { generateImage } from './lib/image-generator';
|
||||
import { generateVideo } from './lib/video-generator';
|
||||
import { logger } from './lib/logger';
|
||||
import * as fs from 'fs/promises';
|
||||
|
||||
async function prepareImageForKeyword(keyword: string): Promise<{ keyword: string; generatedImagePath: string } | null> {
|
||||
const numberOfPages = 1;
|
||||
@ -17,6 +18,18 @@ async function prepareImageForKeyword(keyword: string): Promise<{ keyword: strin
|
||||
const randomImagePath = imagePaths[Math.floor(Math.random() * imagePaths.length)];
|
||||
logger.debug(`Randomly selected image for "${keyword}": ${randomImagePath}`);
|
||||
|
||||
// Delete all other images
|
||||
for (const imagePath of imagePaths) {
|
||||
if (imagePath !== randomImagePath) {
|
||||
try {
|
||||
await fs.unlink(imagePath);
|
||||
logger.debug(`Deleted image: ${imagePath}`);
|
||||
} catch (error) {
|
||||
logger.error(`Failed to delete image ${imagePath}:`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const imagePromptResponse = await describeImage(randomImagePath,
|
||||
`Describe this image as a prompt for an image generation model.
|
||||
@ -33,7 +46,12 @@ async function prepareImageForKeyword(keyword: string): Promise<{ keyword: strin
|
||||
|
||||
const timestamp = new Date().getTime();
|
||||
const imageFileName = `${keyword.replace(/\s/g, '_')}_${timestamp}.png`;
|
||||
const generatedImagePath = await generateImage(imagePrompt, imageFileName);
|
||||
const generatedImagePath = await generateImage(
|
||||
imagePrompt,
|
||||
imageFileName,
|
||||
'flux',
|
||||
{ width: 720, height: 1280 }
|
||||
);
|
||||
logger.debug(`Generated new image from prompt, saved to: ${generatedImagePath}`);
|
||||
return { keyword, generatedImagePath };
|
||||
} catch (error) {
|
||||
@ -59,7 +77,12 @@ async function generateVideoFromImagePath(keyword: string, generatedImagePath: s
|
||||
|
||||
const timestamp = new Date().getTime();
|
||||
const videoFileName = `${keyword.replace(/\s/g, '_')}_${timestamp}.mp4`;
|
||||
const generatedVideoPath = await generateVideo(videoPrompt, generatedImagePath, videoFileName);
|
||||
const generatedVideoPath = await generateVideo(
|
||||
videoPrompt,
|
||||
generatedImagePath,
|
||||
videoFileName,
|
||||
{ width: 720, height: 1280 }
|
||||
);
|
||||
logger.debug(`Generated video from prompt, saved to: ${generatedVideoPath}`);
|
||||
} catch (error) {
|
||||
logger.error(`Failed to generate video for ${generatedImagePath}:`, error);
|
||||
@ -69,19 +92,20 @@ async function generateVideoFromImagePath(keyword: string, generatedImagePath: s
|
||||
|
||||
(async () => {
|
||||
const keywords = [
|
||||
"beautiful woman portrait",
|
||||
"handsome man candid",
|
||||
"interesting street photography",
|
||||
"stunning landscape",
|
||||
"vibrant city nightlife",
|
||||
"elegant fashion model",
|
||||
"fantasy landscape",
|
||||
"RPG character art",
|
||||
"high fashion model",
|
||||
"city nightscape",
|
||||
"fireworks display",
|
||||
"nebula space art",
|
||||
"3D abstract render"
|
||||
"beautiful fantasy scene",
|
||||
"AI art",
|
||||
"beautiful scifi scene",
|
||||
"illumunate scene",
|
||||
"night aesthetic",
|
||||
"stars aesthetic",
|
||||
"letro woman",
|
||||
"magic aesthetic",
|
||||
"fire aesthetic",
|
||||
"high fashion outfits",
|
||||
"led fashion",
|
||||
"halloween",
|
||||
"horror aethstetic",
|
||||
"1890s fashion women"
|
||||
];
|
||||
|
||||
while (1) {
|
||||
|
||||
Reference in New Issue
Block a user