From 24ab1c1451ea60849582d8d72a7c7777c15fb527 Mon Sep 17 00:00:00 2001
From: Concedo <39025047+LostRuins@users.noreply.github.com>
Date: Wed, 25 Mar 2026 00:21:54 +0800
Subject: [PATCH] upgrade musicui to do tts, show musicui for tts models (+1
squashed commits)
Squashed commits:
[975630b15] upgrade musicui to do tts
---
embd_res/kcpp_musicui.embd | 178 ++++++++++++++++++++++++++++++++++++-
koboldcpp.py | 6 +-
2 files changed, 177 insertions(+), 7 deletions(-)
diff --git a/embd_res/kcpp_musicui.embd b/embd_res/kcpp_musicui.embd
index e131acd08..ec9216dc7 100644
--- a/embd_res/kcpp_musicui.embd
+++ b/embd_res/kcpp_musicui.embd
@@ -3,7 +3,7 @@
-KoboldCpp Music Generation
+KoboldCpp Music and Audio Generation
@@ -166,11 +188,16 @@ input[type="checkbox"] {
-KoboldCpp Music Generation UI
+KoboldCpp Music and Audio Generation
+
+ 🎵 Music
+ 🗣 TTS
+
+
Song Setup
Caption Rewrite Caption
@@ -254,6 +281,43 @@ input[type="checkbox"] {
Click 'Plan' first to generate lyrics, BPM and duration. Edit as needed.
When satisfied, click 'Generate' to make the music
+
+
+
+
TTS Generation
+
+
Text
+
+
+
+
+
+ Instruction (optional)
+
+
+
+
+ API Base URL (optional)
+
+
+
+
+ Generate Speech
+ Clear
+
+
+
+
+ Generate speech clips and store them in your library.
+
+
+
@@ -281,10 +345,115 @@ let currentPage=1;
let totalItems=0;
let currentController=null;
+let currentTab = "music";
+
+function switchTab(tab){
+ currentTab = tab;
+
+ document.getElementById("musicTab").classList.toggle("hidden", tab !== "music");
+ document.getElementById("ttsTab").classList.toggle("hidden", tab !== "tts");
+
+ document.getElementById("tab_music").classList.toggle("primary", tab==="music");
+ document.getElementById("tab_tts").classList.toggle("primary", tab==="tts");
+
+ loadLibrary(); // refresh view if needed later
+}
+
+async function fetchVoices(){
+ try{
+ const base = document.getElementById("tts_baseUrl").value.trim();
+ const url = (base ? base.replace(/\/$/,"") : "") + "/speakers_list";
+
+ const res = await fetch(url);
+ if(!res.ok) throw new Error();
+
+ const voices = await res.json();
+ populateVoiceList(voices);
+
+ showMessage("Voices loaded.");
+ }catch(e){
+ populateVoiceList(["kobo"]);
+ showMessage("âš Failed to fetch voices. Using fallback.");
+ }
+}
+
+function populateVoiceList(list){
+ const select = document.getElementById("tts_voice");
+ select.innerHTML = "";
+ list.forEach(v=>{
+ const opt=document.createElement("option");
+ opt.value=v;
+ opt.textContent=v;
+ select.appendChild(opt);
+ });
+}
+
+async function generateTTS(){
+ try{
+ currentController=new AbortController();
+ setLoading(true);
+
+ const base = document.getElementById("tts_baseUrl").value.trim();
+ const url = (base ? base.replace(/\/$/,"") : "") + "/v1/audio/speech";
+
+ const payload = {
+ input: document.getElementById("tts_input").value,
+ voice: document.getElementById("tts_voice").value
+ };
+
+ const instruction = document.getElementById("tts_instruction").value;
+ if(instruction) payload.instruction = instruction;
+
+ const res = await fetch(url,{
+ method:"POST",
+ headers:{"Content-Type":"application/json"},
+ body:JSON.stringify(payload),
+ signal:currentController.signal
+ });
+
+ if(!res.ok) throw new Error();
+
+ const audioBlob = await res.blob();
+
+ const tx=db.transaction(STORE,"readwrite");
+ tx.objectStore(STORE).add({
+ title: payload.input.slice(0,30),
+ date:new Date().toISOString(),
+ params:payload,
+ audio:audioBlob,
+ type:"tts"
+ });
+
+ tx.oncomplete=()=>{
+ currentPage=1;
+ loadLibrary();
+ showMessage("TTS generated!");
+ };
+
+ }catch(e){
+ if(e.name!=="AbortError")
+ showMessage("âš Failed to generate TTS.");
+ }finally{
+ currentController=null;
+ setLoading(false);
+ }
+}
+
+function clearTTS(){
+ document.getElementById("tts_input").value="";
+ document.getElementById("tts_instruction").value="";
+}
+
+//end of tts part
+
function setLoading(isLoading){
document.getElementById("normalActions").style.display = isLoading ? "none" : "flex";
+ document.getElementById("ttsActions").style.display = isLoading ? "none" : "flex";
+
+ // shared controls
document.getElementById("abortBtn").classList.toggle("hidden", !isLoading);
document.getElementById("inlineSpinner").classList.toggle("hidden", !isLoading);
+ document.getElementById("inlineSpinner2").classList.toggle("hidden", !isLoading);
}
function abortRequest(){
@@ -511,7 +680,7 @@ function loadLibrary(){
let ismp3 = (item.params?(item.params.use_mp3?true:false):false);
let savfmt = (ismp3?".mp3":".wav");
div.innerHTML=`
- ${item.title}
+ ${item.type==="tts" ? "🗣 " : "🎵 "}${item.title}
${new Date(item.date).toLocaleString()}
@@ -577,6 +746,7 @@ function importPlan(event){
}
initDB().then(loadLibrary);
+fetchVoices();