diff --git a/functions/src/music.js b/functions/src/music.js index 03a892a..f977663 100644 --- a/functions/src/music.js +++ b/functions/src/music.js @@ -451,7 +451,7 @@ const mergeMusicUrls = async (projectRef, newUrls) => { let existing = [] try { existing = sanitizeMusicUrls((await projectRef.get())?.data()?.musicUrls) - } catch (e) {} + } catch (e) { } const final = [...new Set([...existing, ...sanitized])] await projectRef.set( { @@ -486,9 +486,19 @@ exports.generateMusic = onCall(async ({ data = {} }) => { // Normalisation input Voix (peut être array, string ou objet selon ta spec) let voiceData = [] - if (Array.isArray(voice)) voiceData = voice - else if (typeof voice === 'object' && voice !== null) voiceData = Object.values(voice).flat() - else if (typeof voice === 'string') voiceData = [voice] + if (Array.isArray(voice)) { + voiceData = voice + .map((v) => { + if (typeof v === 'object' && v !== null && v.value) return v.value + if (typeof v === 'string') return v + return '' + }) + .filter(Boolean) + } else if (typeof voice === 'object' && voice !== null) { + voiceData = Object.values(voice).flat() + } else if (typeof voice === 'string') { + voiceData = [voice] + } // 1. Construction du STYLE MUSICAL (Tags) const optimizedStyle = buildSunoStyle({ @@ -552,7 +562,7 @@ exports.generateMusic = onCall(async ({ data = {} }) => { console.error('❌ Erreur generateMusic:', error) try { await markProjectMusicFailure(data?.projectId, error) - } catch (e) {} + } catch (e) { } const status = error?.response?.status || 'INTERNAL_ERROR' const message = error?.response?.data?.msg || error?.message || 'Erreur Suno'