()
| 21 | } |
| 22 | |
| 23 | function buildRequestBody() { |
| 24 | const model = document.getElementById('sound-model').value; |
| 25 | const body = { model_id: model }; |
| 26 | const isSimple = document.getElementById('mode-simple').checked; |
| 27 | |
| 28 | if (isSimple) { |
| 29 | const text = document.getElementById('text').value.trim(); |
| 30 | if (text) body.text = text; |
| 31 | body.instrumental = document.getElementById('instrumental').checked; |
| 32 | const vocal = document.getElementById('vocal_language').value.trim(); |
| 33 | if (vocal) body.vocal_language = vocal; |
| 34 | } else { |
| 35 | // Advanced mode: do NOT send 'text' field - it triggers simple mode in backend |
| 36 | // Only send caption, lyrics, and other advanced fields |
| 37 | const caption = document.getElementById('caption').value.trim(); |
| 38 | if (caption) body.caption = caption; |
| 39 | const lyrics = document.getElementById('lyrics').value.trim(); |
| 40 | if (lyrics) body.lyrics = lyrics; |
| 41 | body.think = document.getElementById('think').checked; |
| 42 | const bpm = document.getElementById('bpm').value.trim(); |
| 43 | if (bpm) body.bpm = parseInt(bpm, 10); |
| 44 | const duration = document.getElementById('duration_seconds').value.trim(); |
| 45 | if (duration) body.duration_seconds = parseFloat(duration); |
| 46 | const keyscale = document.getElementById('keyscale').value.trim(); |
| 47 | if (keyscale) body.keyscale = keyscale; |
| 48 | const language = document.getElementById('language').value.trim(); |
| 49 | if (language) body.language = language; |
| 50 | const timesignature = document.getElementById('timesignature').value.trim(); |
| 51 | if (timesignature) body.timesignature = timesignature; |
| 52 | } |
| 53 | return body; |
| 54 | } |
| 55 | |
| 56 | async function generateSound(event) { |
| 57 | event.preventDefault(); |
no test coverage detected