YOLO
modified: uncloseai.js
This commit is contained in:
parent
ada3297b59
commit
89d12da47a
1 changed files with 48 additions and 4 deletions
52
uncloseai.js
52
uncloseai.js
|
|
@ -81,8 +81,8 @@ function extractWebpageContent() {
|
|||
// Function to read text using TTS
|
||||
async function speakText(text, voice = 'alloy', rate = 0.9) {
|
||||
try {
|
||||
// Preprocess the text using Hermes to get spoken tokens
|
||||
const spokenText = await processContentWithHermes(text);
|
||||
// Preprocess the text using the new function to get spoken tokens
|
||||
const spokenText = await extractSpokenTokens(text);
|
||||
|
||||
const response = await fetch(TTS_API_URL, {
|
||||
method: 'POST',
|
||||
|
|
@ -112,7 +112,7 @@ async function speakText(text, voice = 'alloy', rate = 0.9) {
|
|||
}
|
||||
}
|
||||
|
||||
// New function to process content using Hermes
|
||||
// process page content using Hermes
|
||||
async function processContentWithHermes(content) {
|
||||
const payload = {
|
||||
model: MODEL,
|
||||
|
|
@ -155,7 +155,7 @@ Ready? Breath and then return a stream of tokens to be used in a TTS system.
|
|||
max_tokens: 13000
|
||||
};
|
||||
|
||||
console.log("Sending payload to Hermes:", JSON.stringify(payload, null, 2));
|
||||
console.log("Sending payload to Hermes for spoken tokens:", JSON.stringify(payload, null, 2));
|
||||
|
||||
try {
|
||||
const response = await fetch(API_URL, {
|
||||
|
|
@ -181,6 +181,50 @@ Ready? Breath and then return a stream of tokens to be used in a TTS system.
|
|||
}
|
||||
}
|
||||
|
||||
// New function to extract spoken tokens without altering content
|
||||
async function extractSpokenTokens(content) {
|
||||
const payload = {
|
||||
model: MODEL,
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content: `Extract the spoken tokens from the content without altering or summarizing it. Ensure that the spoken tokens match the content displayed on the screen. Skip any embedded advertisements.`
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: content
|
||||
}
|
||||
],
|
||||
temperature: 0,
|
||||
max_tokens: 13000
|
||||
};
|
||||
|
||||
console.log("Sending payload to Hermes for spoken tokens:", JSON.stringify(payload, null, 2));
|
||||
|
||||
try {
|
||||
const response = await fetch(API_URL, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${API_KEY}`
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error(`HTTP error! status: ${response.status}`, errorText);
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data.choices[0].message.content;
|
||||
} catch (error) {
|
||||
console.error('Error in extractSpokenTokens:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to generate a title for TTS
|
||||
async function generateTitleForTTS(text) {
|
||||
const response = await fetch(API_URL, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue