update frontend for new variables
This commit is contained in:
parent
247582fb33
commit
72ce8d0e3f
1 changed files with 100 additions and 40 deletions
|
|
@ -15,17 +15,22 @@
|
||||||
#recordButton {
|
#recordButton {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
height: 80px;
|
height: 80px;
|
||||||
font-size: 36px;
|
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
box-shadow: 0 0px 10px rgba(0, 0, 0, 0.2);
|
|
||||||
transition: background-color 0.3s ease, transform 0.2s ease;
|
transition: background-color 0.3s ease, transform 0.2s ease;
|
||||||
|
border: 1px solid rgb(252, 230, 229);
|
||||||
|
border-bottom: 5px solid rgb(252, 230, 229);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#recordButton.recording {
|
#recordButton.recording {
|
||||||
background-color: #ff4d4d;
|
background-color: rgba(255, 130, 123, 0.032);
|
||||||
|
border: 1px solid rgb(240, 198, 195);
|
||||||
|
border-bottom: 5px solid rgb(240, 198, 195);
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,6 +38,29 @@
|
||||||
transform: scale(0.95);
|
transform: scale(0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shape-container {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shape {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
background-color: rgb(209, 61, 53);
|
||||||
|
border-radius: 50%;
|
||||||
|
transition: border-radius 0.3s ease, background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#recordButton.recording .shape {
|
||||||
|
border-radius: 10px;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#status {
|
#status {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
@ -60,7 +88,8 @@
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
background-color: #f9f9f9;
|
background-color: #ffffff;
|
||||||
|
max-height: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#websocketInput {
|
#websocketInput {
|
||||||
|
|
@ -94,12 +123,33 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#speaker {
|
#speaker {
|
||||||
background-color: #ff4d4d27;
|
background-color: rgb(252, 230, 229);
|
||||||
border-radius: 8px 8px 8px 0px;
|
border-radius: 8px 8px 8px 0px;
|
||||||
padding: 2px 10px;
|
padding: 2px 10px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
}
|
}
|
||||||
|
.label_diarization {
|
||||||
|
background-color: #ffffff66;
|
||||||
|
border-radius: 8px 8px 8px 8px;
|
||||||
|
padding: 2px 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
border-bottom: 3px solid rgb(155, 84, 84);
|
||||||
|
color: rgb(155, 84, 84)
|
||||||
|
}
|
||||||
|
|
||||||
|
.label_transcription {
|
||||||
|
background-color: #ffffff66;
|
||||||
|
border-radius: 8px 8px 8px 8px;
|
||||||
|
padding: 2px 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
border-bottom: 3px solid #8825255c;
|
||||||
|
color: #8825255c
|
||||||
|
}
|
||||||
|
|
||||||
#timeInfo {
|
#timeInfo {
|
||||||
color: #666;
|
color: #666;
|
||||||
|
|
@ -110,28 +160,35 @@
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
/* margin-left: 10px; */
|
/* margin-left: 10px; */
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
border-left: 2px solid #ff4d4d27;
|
border-left: 3px solid rgb(252, 230, 229);
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
margin-top: 1px;
|
margin-top: 1px;
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
|
border-radius: 0px 0px 0px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buffer {
|
.buffer_diarization {
|
||||||
color: rgb(180, 180, 180);
|
color: rgb(155, 84, 84);
|
||||||
font-style: italic;
|
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.buffer_transcription {
|
||||||
|
color: #8825255c;
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.spinner {
|
.spinner {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 8px;
|
width: 8px;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
border: 2px solid rgba(0, 0, 0, 0.2);
|
border: 2px solid #8825255c;
|
||||||
border-top: 2px solid #333;
|
border-top: 2px solid #882525e5;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
animation: spin 0.6s linear infinite;
|
animation: spin 0.6s linear infinite;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
|
|
@ -155,6 +212,7 @@
|
||||||
padding: 2px 10px;
|
padding: 2px 10px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
@ -162,7 +220,11 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="settings-container">
|
<div class="settings-container">
|
||||||
<button id="recordButton">🎙️</button>
|
<button id="recordButton">
|
||||||
|
<div class="shape-container">
|
||||||
|
<div class="shape"></div>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
<div class="settings">
|
<div class="settings">
|
||||||
<div>
|
<div>
|
||||||
<label for="chunkSelector">Chunk size (ms):</label>
|
<label for="chunkSelector">Chunk size (ms):</label>
|
||||||
|
|
@ -248,34 +310,27 @@
|
||||||
// Handle messages from server
|
// Handle messages from server
|
||||||
websocket.onmessage = (event) => {
|
websocket.onmessage = (event) => {
|
||||||
const data = JSON.parse(event.data);
|
const data = JSON.parse(event.data);
|
||||||
/*
|
|
||||||
The server might send:
|
const {
|
||||||
{
|
lines = [],
|
||||||
"lines": [
|
buffer_transcription = "",
|
||||||
{"speaker": 0, "text": "Hello.", "beg": "00:00", "end": "00:01"},
|
buffer_diarization = "",
|
||||||
{"speaker": -2, "text": "Hi, no speaker here.", "beg": "00:01", "end": "00:02"},
|
remaining_time_transcription = 0,
|
||||||
{"speaker": -1, "text": "...", "beg": "00:02", "end": "00:03" },
|
remaining_time_diarization = 0
|
||||||
...
|
} = data;
|
||||||
],
|
|
||||||
"buffer": "..."
|
renderLinesWithBuffer(
|
||||||
}
|
lines,
|
||||||
*/
|
buffer_diarization,
|
||||||
const { lines = [], buffer = "" } = data;
|
buffer_transcription,
|
||||||
renderLinesWithBuffer(lines, buffer);
|
remaining_time_diarization,
|
||||||
|
remaining_time_transcription
|
||||||
|
);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderLinesWithBuffer(lines, buffer) {
|
function renderLinesWithBuffer(lines, buffer_diarization, buffer_transcription, remaining_time_diarization, remaining_time_transcription) {
|
||||||
if (!Array.isArray(lines) || lines.length === 0) {
|
|
||||||
if (buffer) {
|
|
||||||
linesTranscriptDiv.innerHTML = `<span class="buffer">${buffer}</span>`;
|
|
||||||
} else {
|
|
||||||
linesTranscriptDiv.innerHTML = "";
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const linesHtml = lines.map((item, idx) => {
|
const linesHtml = lines.map((item, idx) => {
|
||||||
let timeInfo = "";
|
let timeInfo = "";
|
||||||
if (item.beg !== undefined && item.end !== undefined) {
|
if (item.beg !== undefined && item.end !== undefined) {
|
||||||
|
|
@ -286,7 +341,7 @@
|
||||||
if (item.speaker === -2) {
|
if (item.speaker === -2) {
|
||||||
speakerLabel = `<span class="silence">Silence<span id='timeInfo'>${timeInfo}</span></span>`;
|
speakerLabel = `<span class="silence">Silence<span id='timeInfo'>${timeInfo}</span></span>`;
|
||||||
} else if (item.speaker == 0) {
|
} else if (item.speaker == 0) {
|
||||||
speakerLabel = `<span class='loading'><span class="spinner"></span><span id='timeInfo'>${item.diff} second(s) of audio are undergoing diarization</span></span>`;
|
speakerLabel = `<span class='loading'><span class="spinner"></span><span id='timeInfo'>${remaining_time_diarization} second(s) of audio are undergoing diarization</span></span>`;
|
||||||
} else if (item.speaker == -1) {
|
} else if (item.speaker == -1) {
|
||||||
speakerLabel = `<span id="speaker"><span id='timeInfo'>${timeInfo}</span>`;
|
speakerLabel = `<span id="speaker"><span id='timeInfo'>${timeInfo}</span>`;
|
||||||
} else if (item.speaker !== -1) {
|
} else if (item.speaker !== -1) {
|
||||||
|
|
@ -294,8 +349,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let textContent = item.text;
|
let textContent = item.text;
|
||||||
if (idx === lines.length - 1 && buffer) {
|
if (idx === lines.length - 1 && buffer_diarization) {
|
||||||
textContent += `<span class="buffer">${buffer}</span>`;
|
speakerLabel += `<span class="label_diarization"><span class="spinner"></span>Diarization lag<span id='timeInfo'>${remaining_time_diarization}s</span></span>`
|
||||||
|
textContent += `<span class="buffer_diarization">${buffer_diarization}</span>`;
|
||||||
|
}
|
||||||
|
if (idx === lines.length - 1 && buffer_transcription) {
|
||||||
|
speakerLabel += `<span class="label_transcription"><span class="spinner"></span>Transcription lag <span id='timeInfo'>${remaining_time_transcription}s</span></span>`
|
||||||
|
textContent += `<span class="buffer_transcription">${buffer_transcription}</span>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return textContent
|
return textContent
|
||||||
|
|
@ -336,7 +396,7 @@
|
||||||
websocket = null;
|
websocket = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleRecording() {
|
async function toggleRecording() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue