Enable SheetSage2 audio remix in YuE2 UI

This commit is contained in:
Mikei386
2026-09-10 22:56:24 +02:00
parent af25425aee
commit 5c34afa7fa
3 changed files with 121 additions and 1 deletions
@@ -81,3 +81,87 @@ replace_once(
'''<span class="label">Lyrics <em>section tags on their own line</em></span>''',
'''<span class="label">Lyrics <em>section tags on their own line · leave empty for a true instrumental</em></span>''',
)
# The backend already ships a complete SheetSage2 upload endpoint but hides it
# from the published console. Surface it beside the existing take-to-take
# remix controls so uploaded songs can seed a new melody/arrangement.
replace_once(
index_html,
''' <p class="row-hint" id="coverStatus"></p>
</div>
</details>
''',
''' <p class="row-hint" id="coverStatus"></p>
<h4>Remix an uploaded recording</h4>
<p class="hint">SheetSage2 listens to an uploaded song and writes an editable melody
and chord score for YuE2. This is structural transcription, not a sample or a copy of
the original sound. After analysis, choose a new style and generate normally.</p>
<div class="field-row">
<label class="field grow">
<span class="label">Source audio</span>
<input id="coverAudio" type="file" accept=".wav,.flac,.mp3,.m4a,.ogg,.opus,.aac,audio/*" />
</label>
<div class="field reset-cell">
<button type="button" class="btn ghost" id="coverFromAudio">Analyse uploaded melody</button>
</div>
</div>
<label class="check"><input type="checkbox" id="coverAudioMelodyOnly" checked />
<span>Keep the melody, but let the new style rebuild the harmony</span></label>
<p class="row-hint" id="coverAudioStatus">Checking SheetSage2…</p>
</div>
</details>
''',
)
replace_once(
app_js,
''' $("coverStatus").textContent = takes.length
? takes.length + " takes carry a score you can remix."
: "Make a song in Full plan or Melody only mode first; Direct mode keeps no score.";
}).catch(function () {});
''',
''' $("coverStatus").textContent = takes.length
? takes.length + " takes carry a score you can remix."
: "Make a song in Full plan or Melody only mode first; Direct mode keeps no score.";
var sheetsage = data.sheetsage || {};
$("coverFromAudio").disabled = !sheetsage.available;
$("coverAudioStatus").textContent = sheetsage.available
? "SheetSage2 is ready. Analysis temporarily parks YuE2 because both use the GPU."
: "SheetSage2 is not installed yet; uploaded-audio remix is unavailable.";
}).catch(function (error) {
$("coverFromAudio").disabled = true;
$("coverAudioStatus").textContent = error.message;
});
''',
)
replace_once(
app_js,
''' /* -------------------------------------------------------------- compose */
''',
''' $("coverFromAudio").addEventListener("click", function () {
var file = $("coverAudio").files[0];
if (!file) return toast("Choose an audio file first", "bad");
var button = $("coverFromAudio");
var body = new FormData();
body.append("file", file, file.name);
body.append("melody_only", $("coverAudioMelodyOnly").checked ? "true" : "false");
button.disabled = true;
button.textContent = "Analysing…";
$("coverAudioStatus").textContent = "Listening to “" + file.name + "”… this can take several minutes.";
api("/api/cover/from-audio", { method: "POST", body: body }).then(function (data) {
applyCoverScore(data.abc, "Melody analysed from “" + data.source + "” in " + data.seconds + " s. Choose the new style and generate.");
$("coverAudioStatus").textContent = "Analysis complete in " + data.seconds + " s. The editable score is loaded below.";
}).catch(function (error) {
$("coverAudioStatus").textContent = error.message;
toast(error.message, "bad");
}).then(function () {
button.textContent = "Analyse uploaded melody";
refreshCover();
});
});
/* -------------------------------------------------------------- compose */
''',
)