Skip to content

Commit 702e8a6

Browse files
committed
updated lite
1 parent ea2e5ed commit 702e8a6

File tree

1 file changed

+53
-8
lines changed

1 file changed

+53
-8
lines changed

klite.embd

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,6 +3040,7 @@ Current version indicated by LITEVER below.
30403040
const ALLTALK_ID = 1001;
30413041
const OAI_TTS_ID = 1002;
30423042
const KCPP_TTS_ID = 1003;
3043+
const POLLINATIONS_TTS_ID = 1004;
30433044
const HD_RES_PX = 768;
30443045
const VHD_RES_PX = 960;
30453046
const NO_HD_RES_PX = 512;
@@ -5166,7 +5167,7 @@ Current version indicated by LITEVER below.
51665167
let tmp = data.candidates[0].content.parts[x].text;
51675168
if(data.candidates[0].content.parts[x].thought)
51685169
{
5169-
tmp = `<think>${tmp}</think>\n`;
5170+
tmp = `<think>${tmp}</think>`;
51705171
}
51715172
synchro_polled_response += tmp;
51725173
}
@@ -5318,7 +5319,7 @@ Current version indicated by LITEVER below.
53185319
}
53195320
if(!event.data.candidates[0].content.parts[x].thought && gemini_was_thinking)
53205321
{
5321-
synchro_pending_stream = `<think>${synchro_pending_stream}</think>\n`;
5322+
synchro_pending_stream = `<think>${synchro_pending_stream}</think>`;
53225323
gemini_was_thinking = false;
53235324
}
53245325
synchro_pending_stream += event.data.candidates[0].content.parts[x].text;
@@ -11507,6 +11508,7 @@ Current version indicated by LITEVER below.
1150711508
ttshtml += "<option value=\"1001\">AllTalk API Server</option>";
1150811509
ttshtml += "<option value=\"1002\">OpenAI-Compat. API Server</option>";
1150911510
ttshtml += "<option value=\"1003\">KoboldCpp TTS API</option>";
11511+
ttshtml += "<option value=\"1004\">PollinationsAI TTS API</option>";
1151011512

1151111513
if ('speechSynthesis' in window) {
1151211514
let voices = window.speechSynthesis.getVoices();
@@ -13016,12 +13018,12 @@ Current version indicated by LITEVER below.
1301613018
if(matches.length > 0)
1301713019
{
1301813020
let matchiter = 0;
13019-
inputtxt = inputtxt.replace(/%ExpandBtn%/g, function (m) {
13021+
inputtxt = inputtxt.replace(/%ExpandBtn%(?:\n{0,2})?/g, function (m) {
1302013022
let curr = matches[matchiter];
13021-
let expandedhtml = `<span><button type="button" title="Show Thoughts" class="btn btn-primary" style="font-size:12px;padding:2px 2px;" onclick="toggle_hide_thinking(this)">Show Thoughts (${curr.length} characters)</button><span class="color_lightgreen hidden"><br>${escape_html(curr)}\n</span></span>`;
13023+
let expandedhtml = `<span><button type="button" title="Show Thoughts" class="btn btn-primary" style="font-size:12px;padding:2px 2px;" onclick="toggle_hide_thinking(this)">Show Thoughts (${curr.length} characters)</button><span class="color_lightgreen hidden"><br>${escape_html(curr)}</span><br></span>`;
1302213024
if(!curr || curr.trim()=="")
1302313025
{
13024-
expandedhtml = `<span><button type="button" title="No Thoughts" class="btn btn-primary" style="font-size:12px;padding:2px 2px;" onclick="">No Thoughts</button></span>`;
13026+
expandedhtml = `<span><button type="button" title="No Thoughts" class="btn btn-primary" style="font-size:12px;padding:2px 2px;" onclick="">No Thoughts</button><br></span>`;
1302513027
}
1302613028
++matchiter;
1302713029
return expandedhtml;
@@ -13504,7 +13506,7 @@ Current version indicated by LITEVER below.
1350413506
let ssval = document.getElementById("ttsselect").value;
1350513507
let speakprompt = "Enter phrase to speak.";
1350613508

13507-
if(ssval==XTTS_ID || ssval==ALLTALK_ID || ssval==OAI_TTS_ID || ssval==KCPP_TTS_ID)
13509+
if(ssval==XTTS_ID || ssval==ALLTALK_ID || ssval==OAI_TTS_ID || ssval==KCPP_TTS_ID || ssval==POLLINATIONS_TTS_ID)
1350813510
{
1350913511
speakprompt = `Enter phrase to speak.<br><div><input type="checkbox" id="downloadtts" title="Add Endpoint Version Number"><div class="box-label">Download as .wav file</div></div>`;
1351013512
}
@@ -13688,11 +13690,12 @@ Current version indicated by LITEVER below.
1368813690
}
1368913691
}
1369013692

13691-
if(ssval==XTTS_ID || ssval==ALLTALK_ID || ssval==OAI_TTS_ID || ssval==KCPP_TTS_ID) //xtts api server
13693+
if(ssval==XTTS_ID || ssval==ALLTALK_ID || ssval==OAI_TTS_ID || ssval==KCPP_TTS_ID || ssval==POLLINATIONS_TTS_ID) //xtts api server
1369213694
{
1369313695
let is_xtts = (ssval==XTTS_ID);
1369413696
let is_oai_tts = (ssval==OAI_TTS_ID);
1369513697
let is_kcpp_tts = (ssval==KCPP_TTS_ID);
13698+
let is_pollinations_tts = (ssval==POLLINATIONS_TTS_ID);
1369613699
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
1369713700
let audiofile_ref = null;
1369813701

@@ -13762,6 +13765,48 @@ Current version indicated by LITEVER below.
1376213765
console.log("XTTS Speak Error: " + error);
1376313766
});
1376413767
}
13768+
else if(is_pollinations_tts)
13769+
{
13770+
const pollinations_params = new URLSearchParams({
13771+
model:"openai-audio",
13772+
voice:"nova",
13773+
private: true,
13774+
referrer: "KoboldAiLite"
13775+
});
13776+
const speechprompt = `Please narrate the following text:\n\n${text}`;
13777+
13778+
let gen_endpoint = `${pollinations_text_endpoint}/${encodeURIComponent(speechprompt)}?${pollinations_params.toString()}`;
13779+
13780+
fetch(gen_endpoint, {
13781+
method: 'GET',
13782+
})
13783+
.then(response => response.arrayBuffer())
13784+
.then(data => {
13785+
audiofile_ref = data.slice(0);
13786+
return audioContext.decodeAudioData(data);
13787+
})
13788+
.then(decodedData => {
13789+
if(do_download)
13790+
{
13791+
tts_download(audiofile_ref);
13792+
}
13793+
const playSound = audioContext.createBufferSource();
13794+
playSound.buffer = decodedData;
13795+
playSound.connect(audioContext.destination);
13796+
xtts_is_playing = true;
13797+
update_submit_button(false);
13798+
playSound.start(audioContext.currentTime);
13799+
playSound.onended = function() {
13800+
setTimeout(() => {
13801+
xtts_is_playing = false;
13802+
update_submit_button(false);
13803+
console.log("Audio finished playing");
13804+
},300);
13805+
};
13806+
}).catch((error) => {
13807+
console.log("Pollinations Speak Error: " + error);
13808+
});
13809+
}
1376513810
else if(xtts_is_connected)
1376613811
{
1376713812
if(is_xtts)
@@ -15423,7 +15468,7 @@ Current version indicated by LITEVER below.
1542315468
}
1542415469
if(data.content[i].thinking)
1542515470
{
15426-
comp += `<think>${data.content[i].thinking}</think>\n\n`; //for claudev3
15471+
comp += `<think>${data.content[i].thinking}</think>`; //for claudev3
1542715472
}
1542815473
}
1542915474
if(comp!="")

0 commit comments

Comments
 (0)