From 1e07043a6e7c17fa83ce45a9bac9073499ef79a6 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sun, 15 Dec 2024 15:29:02 +0800 Subject: [PATCH] clean and rename old clblast files in preparation for merge --- Makefile | 2 +- ggml/src/ggml-cpu/ggml-cpu.c | 2 +- klite.embd | 299 ++++++++++++++---- .../ggml_v3b-opencl.cpp | 223 +------------ ggml-opencl.h => otherarch/ggml_v3b-opencl.h | 13 - src/llama.cpp | 2 +- 6 files changed, 247 insertions(+), 294 deletions(-) rename ggml-opencl.cpp => otherarch/ggml_v3b-opencl.cpp (90%) rename ggml-opencl.h => otherarch/ggml_v3b-opencl.h (70%) diff --git a/Makefile b/Makefile index c2a769784..591b7947c 100644 --- a/Makefile +++ b/Makefile @@ -578,7 +578,7 @@ ggml_v1_failsafe.o: otherarch/ggml_v1.c otherarch/ggml_v1.h $(CC) $(FASTCFLAGS) $(NONECFLAGS) -c $< -o $@ #opencl -ggml-opencl.o: ggml-opencl.cpp ggml-opencl.h +ggml-opencl.o: otherarch/ggml_v3b-opencl.cpp otherarch/ggml_v3b-opencl.h $(CXX) $(CXXFLAGS) $(CLBLAST_FLAGS) -c $< -o $@ ggml_v2-opencl.o: otherarch/ggml_v2-opencl.cpp otherarch/ggml_v2-opencl.h $(CXX) $(CXXFLAGS) $(CLBLAST_FLAGS) -c $< -o $@ diff --git a/ggml/src/ggml-cpu/ggml-cpu.c b/ggml/src/ggml-cpu/ggml-cpu.c index 401a2140c..259bbf1fc 100644 --- a/ggml/src/ggml-cpu/ggml-cpu.c +++ b/ggml/src/ggml-cpu/ggml-cpu.c @@ -87,7 +87,7 @@ #include #endif #if defined(GGML_USE_CLBLAST) // allow usage of CLBlast alongside Accelerate functions -#include "ggml-opencl.h" +#include "ggml_v3b-opencl.h" #endif // floating point type used to accumulate sums diff --git a/klite.embd b/klite.embd index 819328b67..c7d9dea27 100644 --- a/klite.embd +++ b/klite.embd @@ -4125,7 +4125,9 @@ Current version indicated by LITEVER below. const xtts_gen_endpoint = "/tts_to_audio/"; const xtts_voices_endpoint = "/speakers_list"; const alltalk_gen_endpoint = "/api/tts-generate"; + const alltalk_stream_endpoint = "/api/tts-generate-streaming"; const alltalk_voices_endpoint = "/api/voices"; + const alltalk_rvc_voices_endpoint = "/api/rvcvoices"; //support for quick news updates const horde_news_endpoint = "https://hordenews.concedo.workers.dev" @@ -4181,7 +4183,7 @@ Current version indicated by LITEVER below. var current_wi = []; //each item stores a wi object. var wi_insertlocation = 0; //after memory var wi_searchdepth = 0; //search everything - var generateimagesinterval = 700; //if generated images is enabled, it will trigger after every 700 new characters in context. + var generateimagesinterval = 750; //if generated images is enabled, it will trigger after every 700 new characters in context. var nextgeneratedimagemilestone = generateimagesinterval; //used to keep track of when to generate the next image var image_db = {}; //stores a dictionary of pending images var interrogation_db = {}; @@ -5052,7 +5054,11 @@ Current version indicated by LITEVER below. const foundChub = urlParams.get('chub'); const foundPyg = urlParams.get('pyg'); const foundAicc = urlParams.get('aicc'); - const foundQuery = urlParams.get('query'); + let foundQuery = urlParams.get('query'); + if (!foundQuery || foundQuery == "") + { + foundQuery = urlParams.get('q'); + } if (foundStory && foundStory != "") { if (localsettings.persist_session && !safe_to_overwrite()) { @@ -8054,9 +8060,18 @@ Current version indicated by LITEVER below. let style = (elem.trusted ? "style=\"color:#dd77ff;\"" : ""); let brokenstyle = (elem.maintenance_mode ? "style=\"color:#ee4444;\"" : ""); let workerNameHtml = escapeHtml(elem.name.substring(0, 40)); + let clickinfo = ""; if(elem.info && elem.info!="") { - workerNameHtml = ""+workerNameHtml+""; + clickinfo += escapeHtml(replaceAll(elem.info,"\'","\\\'")); + } + if(elem.threads>1) + { + clickinfo += (clickinfo==""?"":"

") + "Threads: " + elem.threads; + } + if(clickinfo!="") + { + workerNameHtml = ""+workerNameHtml+""; } let allmdls = ""; for (let n = 0; n < elem.models.length; ++n) { @@ -11653,7 +11668,7 @@ Current version indicated by LITEVER below. function do_auto_gen_image(truncated_context) { var tclen = truncated_context.length; - var sentence = truncated_context.substring(tclen - 380, tclen); + var sentence = truncated_context.substring(tclen - 400, tclen); sentence = start_trim_to_sentence(sentence); sentence = end_trim_to_sentence(sentence,true); if (sentence.length > 0) { @@ -11827,6 +11842,28 @@ Current version indicated by LITEVER below. //alltalk mode data = data.voices; } + else if(data && !data.length && data.constructor == Object) + { + //hybrid new xtts mantella + let newdata = []; + for(key in data) + { + let lang = data[key]; + if(lang && lang.speakers && lang.speakers.length>0) + { + for(let i=0;i 0) + { + data = newdata; + } + } + + let dropdown = document.getElementById("xtts_voices"); let selectionhtml = ``; for (var i = 0; i < data.length; ++i) { @@ -11864,46 +11901,92 @@ Current version indicated by LITEVER below. { document.getElementById("xtts_container").classList.add("hidden"); document.getElementById("oai_tts_container").classList.add("hidden"); - if(document.getElementById("ttsselect").value==XTTS_ID || document.getElementById("ttsselect").value==ALLTALK_ID) - { + document.getElementById("alltalk_specific_controls").classList.add("hidden"); + + const selectedTTS = document.getElementById("ttsselect").value; + + if(selectedTTS == XTTS_ID || selectedTTS == ALLTALK_ID) { document.getElementById("xtts_container").classList.remove("hidden"); - fetch_xtts_voices(true, document.getElementById("ttsselect").value==XTTS_ID); + + if(selectedTTS == ALLTALK_ID) { + document.getElementById("alltalk_specific_controls").classList.remove("hidden"); + fetch_rvc_voices(); + adjust_alltalk_controls(); + } + fetch_xtts_voices(true, selectedTTS == XTTS_ID); } - else if(document.getElementById("ttsselect").value==OAI_TTS_ID) - { + else if(selectedTTS == OAI_TTS_ID) { document.getElementById("oai_tts_container").classList.remove("hidden"); } } - function set_xtts_url() + + // Fetch RVC voices for AllTalk + function fetch_rvc_voices() { + if(!xtts_is_connected) //prevent it from constantly fetching, will only fetch once before connecting + { + fetch(localsettings.saved_alltalk_url + alltalk_rvc_voices_endpoint) + .then(response => response.json()) + .then(data => { + console.log("RVC voices response:", data); // Debug log + const rvcSelect = document.getElementById("alltalk_rvc_voice"); + rvcSelect.innerHTML = ''; + if (data.status === "success" && Array.isArray(data.rvcvoices)) { // Changed from data.voices to data.rvcvoices + data.rvcvoices.forEach(voice => { // Changed from data.voices to data.rvcvoices + if (voice !== "Disabled") { + const option = document.createElement("option"); + option.value = voice; + option.textContent = voice.split("\\").pop().replace(".pth", ""); + rvcSelect.appendChild(option); + } + }); + } + }) + .catch(error => { + console.log("Error fetching RVC voices:", error); + }); + } + } + + //single callback to update alltalk controls on any alltalk UI event. + function adjust_alltalk_controls() { + const pitchSlider = document.getElementById("alltalk_rvc_pitch"); + const pitchValue = document.getElementById("alltalk_rvc_pitch_value"); + pitchValue.textContent = pitchSlider.value; + const streamingMode = (document.getElementById("alltalk_streaming").checked ? true : false); + const rvcSelect = document.getElementById("alltalk_rvc_voice"); + const rvcPitch = document.getElementById("alltalk_rvc_pitch"); + rvcSelect.disabled = streamingMode; + rvcPitch.disabled = streamingMode; + } + + // Update set_xtts_url to use the new fetch_rvc_voices function + function set_xtts_url() { let is_xtts = (document.getElementById("ttsselect").value==XTTS_ID); let epname = (is_xtts?"XTTS":"AllTalk"); inputBox("Enter "+epname+" API Server URL.",epname+" API Server URL",(is_xtts?localsettings.saved_xtts_url:localsettings.saved_alltalk_url),"Input "+epname+" API Server URL", ()=>{ let userinput = getInputBoxValue(); userinput = userinput.trim(); - if(userinput!="" && userinput.slice(-1)=="/") - { + if(userinput!="" && userinput.slice(-1)=="/") { userinput = userinput.slice(0, -1); } - if(userinput=="") - { + if(userinput=="") { userinput = (is_xtts?default_xtts_base:default_alltalk_base); } if (userinput != null && userinput!="") { - if(is_xtts) - { - localsettings.saved_xtts_url = userinput.trim(); - } - else - { - localsettings.saved_alltalk_url = userinput.trim(); - } - xtts_is_connected = false; + if(is_xtts) { + localsettings.saved_xtts_url = userinput.trim(); + } else { + localsettings.saved_alltalk_url = userinput.trim(); + // Fetch RVC voices with new URL + fetch_rvc_voices(); + } fetch_xtts_voices(false, is_xtts); } },false); } + function tts_speak(text, speech_synth_override=null) { if(!text || text=="" || text.trim()=="") @@ -12019,35 +12102,18 @@ Current version indicated by LITEVER below. },300); }; }).catch((error) => { + xtts_is_playing = false; + update_submit_button(false); console.log("XTTS Speak Error: " + error); }); } else { //alltalk - const formData = new FormData(); - formData.append("text_input", text); // max 2000 chars - formData.append("text_filtering", "none"); // (none|standard|html) - formData.append("character_voice_gen", document.getElementById("xtts_voices").value); - formData.append("narrator_enabled", false); - formData.append("narrator_voice_gen", document.getElementById("xtts_voices").value); - formData.append("text_not_inside", "character"); // character or narrator, determines which to use - formData.append("language", document.getElementById("xtts_lang").value.trim().toLowerCase()); - formData.append("output_file_name", "audiofile"); // NOTE: file name only, with no extension and no dashes! - formData.append("output_file_timestamp", true); - formData.append("autoplay", false); //to play in browser - formData.append("autoplay_volume", 1.0); // (0.1..2.0) - formData.append("streaming", true); // unknown why + const isStreaming = (document.getElementById("alltalk_streaming").checked ? true : false); - fetch(localsettings.saved_alltalk_url + alltalk_gen_endpoint, { - method: 'POST', - body: formData, // send payload as FormData - }) - .then(response => response.arrayBuffer()) - .then(data => { - return audioContext.decodeAudioData(data); - }) - .then(decodedData => { + let playDecodedAllTalkData = function(decodedData) + { const playSound = audioContext.createBufferSource(); playSound.buffer = decodedData; playSound.connect(audioContext.destination); @@ -12061,9 +12127,109 @@ Current version indicated by LITEVER below. console.log("Audio finished playing"); },300); }; - }).catch((error) => { - console.log("AllTalk Speak Error: " + error); - }); + } + + if (isStreaming) { + // Create a URLSearchParams object for streaming + const params = new URLSearchParams({ + text: text, + voice: document.getElementById("xtts_voices").value, + language: document.getElementById("xtts_lang").value.trim().toLowerCase(), + output_file: "klite_stream_output.wav", + }); + + // Create streaming URL, but right now it's as good as sync + const streamingUrl = `${localsettings.saved_alltalk_url}${alltalk_stream_endpoint}?${params.toString()}`; + fetch(streamingUrl) + .then(response => response.arrayBuffer()) + .then(data => { + return audioContext.decodeAudioData(data); + }) + .then(decodedData => { + playDecodedAllTalkData(decodedData); + }) + .catch((error) => { + console.log("AllTalk v2 Speak Error:", data); + xtts_is_playing = false; + update_submit_button(false); + }); + + } else { + // Standard mode using FormData + const formData = new FormData(); + formData.append("text_input", text); + formData.append("text_filtering", "none"); + formData.append("character_voice_gen", document.getElementById("xtts_voices").value); + formData.append("narrator_enabled", false); + formData.append("narrator_voice_gen", document.getElementById("xtts_voices").value); + formData.append("text_not_inside", "character"); + formData.append("language", document.getElementById("xtts_lang").value.trim().toLowerCase()); + formData.append("output_file_name", "audiofile"); + formData.append("output_file_timestamp", true); + formData.append("autoplay", false); + formData.append("autoplay_volume", 1.0); + formData.append("rvccharacter_voice_gen", document.getElementById("alltalk_rvc_voice").value); + formData.append("rvccharacter_pitch", document.getElementById("alltalk_rvc_pitch").value); + formData.append("rvcnarrator_voice_gen", document.getElementById("alltalk_rvc_voice").value); + formData.append("rvcnarrator_pitch", document.getElementById("alltalk_rvc_pitch").value); + + fetch(localsettings.saved_alltalk_url + alltalk_gen_endpoint, { + method: 'POST', + body: formData, // send payload as FormData + }).then(response => { + //content type can be JSON (alltalk v2) or raw audio (v1) + const contentType = response.headers.get("Content-Type"); + //alltalk v2 json + if (contentType && contentType.toLowerCase().includes("application/json")) + { + return response.json().then(data => { + if (data && data.output_file_url && data.status === "generate-success") + { + const audioUrl = `${localsettings.saved_alltalk_url}${data.output_file_url}`; + fetch(audioUrl) + .then(response => response.arrayBuffer()) + .then(data => { + return audioContext.decodeAudioData(data); + }) + .then(decodedData => { + playDecodedAllTalkData(decodedData); + }) + .catch((error) => { + console.log("AllTalk v2 Speak Error:", data); + xtts_is_playing = false; + update_submit_button(false); + }); + } else { + console.log("AllTalk Generation Error:", data); + xtts_is_playing = false; + update_submit_button(false); + } + }) + .catch((error) => { + console.log("AllTalk Request Error:", error); + xtts_is_playing = false; + update_submit_button(false); + }); + } + else //alltalk v1 audio + { + return response.arrayBuffer().then(data => { + return audioContext.decodeAudioData(data); + }) + .then(decodedData => { + playDecodedAllTalkData(decodedData); + }).catch((error) => { + console.log("AllTalk v1 Speak Error: " + error); + xtts_is_playing = false; + update_submit_button(false); + }); + } + }).catch((error) => { + console.log("AllTalk Non-Stream Req Error: " + error); + xtts_is_playing = false; + update_submit_button(false); + }); + } } } } @@ -15880,7 +16046,7 @@ Current version indicated by LITEVER below. whorun = "
You're using the Cohere API"; } else { - whorun = `
There are ${selected_models.reduce((s, a) => s + a.count, 0)} volunteer(s) running selected models with a total queue length of ${selected_models.reduce((s, a) => s + a.queued, 0)} tokens`; + whorun = `
Horde Volunteer(s) are running ${selected_models.reduce((s, a) => s + a.count, 0)} threads for selected models with a total queue length of ${selected_models.reduce((s, a) => s + a.queued, 0)} tokens`; } let nowmode = (localsettings.opmode==1?"Story Mode":(localsettings.opmode==2?"Adventure Mode":(localsettings.opmode==3?"Chat Mode":"Instruct Mode"))); let selmodelstr = ""; @@ -19562,13 +19728,34 @@ Current version indicated by LITEVER below.