main idea is now working :)

Using openai for tts and groq for ollama fast inference
This commit is contained in:
Dobromir Popov
2024-06-12 10:05:09 +03:00
parent 8bafcd9dbe
commit 4627f16284
6 changed files with 308 additions and 20 deletions

View File

@ -183,7 +183,7 @@
break;
case "text":
case "transcriptionResult":
transcription.innerHTML += "\r\n" + json.text;
transcription.innerHTML += "<br />" + json.text;
let latency = Date.now() - serverTime;
if (autosend.checked) {
// const arr = event.data.split(/[(\)]/);
@ -197,6 +197,13 @@
//transcription.innerHTML = event.data;
}
break;
case 'audio':
const audioBuffer = Uint8Array.from(atob(json.audio), char => char.charCodeAt(0));
const audioBlob = new Blob([audioBuffer], { type: 'audio/mp3' });
const audioUrl = URL.createObjectURL(audioBlob);
const audio = new Audio(audioUrl);
audio.play();
break;
case "userList":
users = json.users;
@ -235,14 +242,14 @@
}
function userJoin(sessionId, username, language) {
socket.send(JSON.stringify({ type: 'join', username , language}));
socket.send(JSON.stringify({ type: 'join', username, language }));
document.cookie = `sessionId=${sessionId}; path=/;`;
document.cookie = `username=${username}; path=/;`;
showClearSessionOption();
}
function clearSession() {
document.cookie = "sessionId=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
@ -303,7 +310,7 @@
users.forEach(user => {
const option = document.createElement('option');
option.value = user.sessionId;
option.innerText = "["+user.language+"] " +user.username;
option.innerText = "[" + user.language + "] " + user.username;
if (user.username === username) {
option.innerText += " (me)";
}