main
Some checks failed
Backend Deploy 🚀 / build-and-deploy (push) Has been cancelled

This commit is contained in:
Harun CAN
2026-03-30 00:21:32 +03:00
parent 85c35c73e8
commit acb103657b
29 changed files with 11473 additions and 13081 deletions

View File

@@ -546,4 +546,44 @@ export class VideoAiService {
return parsed;
}
/**
* Tekil sahne yeniden üretimi — sınırlı bağlam ile sadece 1 sahne üretir.
*/
async generateSingleScene(contextPrompt: string): Promise<{
narrationText: string;
visualPrompt: string;
subtitleText: string;
durationSeconds: number;
}> {
if (!this.genAI) {
throw new InternalServerErrorException('AI servisi etkin değil — Google API Key gerekli.');
}
try {
const response = await this.genAI.models.generateContent({
model: this.modelName,
contents: contextPrompt,
config: {
responseMimeType: 'application/json',
temperature: 0.8,
maxOutputTokens: 1024,
},
});
const rawText = response.text || '';
const cleaned = rawText.replace(/```json\n?/g, '').replace(/```\n?/g, '').trim();
const parsed = JSON.parse(cleaned);
return {
narrationText: parsed.narrationText || 'Yeniden üretilen sahne.',
visualPrompt: parsed.visualPrompt || 'Cinematic establishing shot.',
subtitleText: parsed.subtitleText || parsed.narrationText || '',
durationSeconds: parsed.durationSeconds || 5,
};
} catch (error) {
this.logger.error(`Tekil sahne üretim hatası: ${error}`);
throw new InternalServerErrorException('Sahne yeniden üretilemedi.');
}
}
}