74 lines
2.4 KiB
JavaScript
74 lines
2.4 KiB
JavaScript
exports.generatePicturePrompt = (project = {}) => {
|
|
const { title = "", lyrics: lyricsRaw, musicConfig = {} } = project || {};
|
|
|
|
const {
|
|
genres = [],
|
|
tempo = "",
|
|
voice = "",
|
|
instruments = [],
|
|
mood = "",
|
|
} = musicConfig || {};
|
|
|
|
// Normalise les paroles en tableau de sections { type, lyrics }
|
|
const lyricsSections = Array.isArray(lyricsRaw)
|
|
? lyricsRaw
|
|
: [
|
|
lyricsRaw?.couplet
|
|
? { type: "couplet", lyrics: lyricsRaw.couplet }
|
|
: null,
|
|
lyricsRaw?.refrain
|
|
? { type: "refrain", lyrics: lyricsRaw.refrain }
|
|
: null,
|
|
].filter(Boolean);
|
|
|
|
// Échantillon pour l'ambiance (courtes bribes pour inspirer la direction créative)
|
|
const lyricsSample = (lyricsSections || [])
|
|
.map((s) => (s?.lyrics || "").split("\n").slice(0, 2).join(" "))
|
|
.filter(Boolean)
|
|
.slice(0, 6)
|
|
.join(" | ");
|
|
|
|
// Etiquettes d'ambiance
|
|
const tags = [];
|
|
if (Array.isArray(genres) && genres.length)
|
|
tags.push(`Genres: ${genres.join(", ")}`);
|
|
if (tempo) tags.push(`Tempo: ${tempo}`);
|
|
if (Array.isArray(instruments) && instruments.length)
|
|
tags.push(`Instruments: ${instruments.join(", ")}`);
|
|
if (voice) tags.push(`Vocal: ${voice}`);
|
|
if (mood) tags.push(`Mood: ${mood}`);
|
|
|
|
// Guidance palette selon tempo (simple heuristique)
|
|
const paletteHint =
|
|
tempo && /\b(rapid|fast|vite|agité|upbeat|energ)/i.test(String(tempo))
|
|
? "Palette vive et contrastée (magenta, cyan, jaune, bleu électrique)"
|
|
: "Palette harmonieuse et douce (bleu nuit, violet, corail, or pâle)";
|
|
|
|
const tagsLine = tags.join(" ; ") || "Non spécifié";
|
|
const lyricsLine = lyricsSample || "Pas d'extraits fournis";
|
|
|
|
const prompt = `
|
|
<BRIEF>
|
|
<OBJECTIF>Créer une pochette lumineuse.</OBJECTIF>
|
|
<TITRE>${title || "Sans titre"}</TITRE>
|
|
<STYLE_MUSICAL>${tagsLine}</STYLE_MUSICAL>
|
|
<EXTRAITS_PAROLES>${lyricsLine}</EXTRAITS_PAROLES>
|
|
</BRIEF>
|
|
|
|
<CONTEXTES_VISUELS>
|
|
<FORMAT>Image carrée 1024x1024 pixels.</FORMAT>
|
|
<STYLE>Abstrait, graphique, formes géométriques et dégradés.</STYLE>
|
|
<COMPOSITION>Remplis toute la surface sans laisser de bordures ou zones vides.</COMPOSITION>
|
|
</CONTEXTES_VISUELS>
|
|
|
|
<CONTRAINTES>
|
|
<INTERDIT>Texte ou typographie.</INTERDIT>
|
|
<INTERDIT>Personnes ou visages.</INTERDIT>
|
|
<INTERDIT>Fond blanc ou bordures.</INTERDIT>
|
|
<INTERDIT>Autre logo ou filigrane que celui prévu en bas à droite.</INTERDIT>
|
|
</CONTRAINTES>
|
|
`.trim();
|
|
|
|
return prompt;
|
|
};
|