From 702e8a63df00299a48f5a6789b31340291bec5a9 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sat, 10 May 2025 00:23:24 +0800 Subject: [PATCH] updated lite --- klite.embd | 61 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/klite.embd b/klite.embd index 96ab2b85d..9bd54e664 100644 --- a/klite.embd +++ b/klite.embd @@ -3040,6 +3040,7 @@ Current version indicated by LITEVER below. const ALLTALK_ID = 1001; const OAI_TTS_ID = 1002; const KCPP_TTS_ID = 1003; + const POLLINATIONS_TTS_ID = 1004; const HD_RES_PX = 768; const VHD_RES_PX = 960; const NO_HD_RES_PX = 512; @@ -5166,7 +5167,7 @@ Current version indicated by LITEVER below. let tmp = data.candidates[0].content.parts[x].text; if(data.candidates[0].content.parts[x].thought) { - tmp = `${tmp}\n`; + tmp = `${tmp}`; } synchro_polled_response += tmp; } @@ -5318,7 +5319,7 @@ Current version indicated by LITEVER below. } if(!event.data.candidates[0].content.parts[x].thought && gemini_was_thinking) { - synchro_pending_stream = `${synchro_pending_stream}\n`; + synchro_pending_stream = `${synchro_pending_stream}`; gemini_was_thinking = false; } synchro_pending_stream += event.data.candidates[0].content.parts[x].text; @@ -11507,6 +11508,7 @@ Current version indicated by LITEVER below. ttshtml += ""; ttshtml += ""; ttshtml += ""; + ttshtml += ""; if ('speechSynthesis' in window) { let voices = window.speechSynthesis.getVoices(); @@ -13016,12 +13018,12 @@ Current version indicated by LITEVER below. if(matches.length > 0) { let matchiter = 0; - inputtxt = inputtxt.replace(/%ExpandBtn%/g, function (m) { + inputtxt = inputtxt.replace(/%ExpandBtn%(?:\n{0,2})?/g, function (m) { let curr = matches[matchiter]; - let expandedhtml = ``; + let expandedhtml = `
`; if(!curr || curr.trim()=="") { - expandedhtml = ``; + expandedhtml = `
`; } ++matchiter; return expandedhtml; @@ -13504,7 +13506,7 @@ Current version indicated by LITEVER below. let ssval = document.getElementById("ttsselect").value; let speakprompt = "Enter phrase to speak."; - if(ssval==XTTS_ID || ssval==ALLTALK_ID || ssval==OAI_TTS_ID || ssval==KCPP_TTS_ID) + if(ssval==XTTS_ID || ssval==ALLTALK_ID || ssval==OAI_TTS_ID || ssval==KCPP_TTS_ID || ssval==POLLINATIONS_TTS_ID) { speakprompt = `Enter phrase to speak.
Download as .wav file
`; } @@ -13688,11 +13690,12 @@ Current version indicated by LITEVER below. } } - if(ssval==XTTS_ID || ssval==ALLTALK_ID || ssval==OAI_TTS_ID || ssval==KCPP_TTS_ID) //xtts api server + if(ssval==XTTS_ID || ssval==ALLTALK_ID || ssval==OAI_TTS_ID || ssval==KCPP_TTS_ID || ssval==POLLINATIONS_TTS_ID) //xtts api server { let is_xtts = (ssval==XTTS_ID); let is_oai_tts = (ssval==OAI_TTS_ID); let is_kcpp_tts = (ssval==KCPP_TTS_ID); + let is_pollinations_tts = (ssval==POLLINATIONS_TTS_ID); const audioContext = new (window.AudioContext || window.webkitAudioContext)(); let audiofile_ref = null; @@ -13762,6 +13765,48 @@ Current version indicated by LITEVER below. console.log("XTTS Speak Error: " + error); }); } + else if(is_pollinations_tts) + { + const pollinations_params = new URLSearchParams({ + model:"openai-audio", + voice:"nova", + private: true, + referrer: "KoboldAiLite" + }); + const speechprompt = `Please narrate the following text:\n\n${text}`; + + let gen_endpoint = `${pollinations_text_endpoint}/${encodeURIComponent(speechprompt)}?${pollinations_params.toString()}`; + + fetch(gen_endpoint, { + method: 'GET', + }) + .then(response => response.arrayBuffer()) + .then(data => { + audiofile_ref = data.slice(0); + return audioContext.decodeAudioData(data); + }) + .then(decodedData => { + if(do_download) + { + tts_download(audiofile_ref); + } + const playSound = audioContext.createBufferSource(); + playSound.buffer = decodedData; + playSound.connect(audioContext.destination); + xtts_is_playing = true; + update_submit_button(false); + playSound.start(audioContext.currentTime); + playSound.onended = function() { + setTimeout(() => { + xtts_is_playing = false; + update_submit_button(false); + console.log("Audio finished playing"); + },300); + }; + }).catch((error) => { + console.log("Pollinations Speak Error: " + error); + }); + } else if(xtts_is_connected) { if(is_xtts) @@ -15423,7 +15468,7 @@ Current version indicated by LITEVER below. } if(data.content[i].thinking) { - comp += `${data.content[i].thinking}\n\n`; //for claudev3 + comp += `${data.content[i].thinking}`; //for claudev3 } } if(comp!="")