add time duration ; display when no speaker is detected
Browse files
src/web/live_transcription.html
CHANGED
@@ -179,8 +179,9 @@
|
|
179 |
The server might send:
|
180 |
{
|
181 |
"lines": [
|
182 |
-
{"speaker": 0, "text": "Hello."},
|
183 |
-
{"speaker":
|
|
|
184 |
...
|
185 |
],
|
186 |
"buffer": "..."
|
@@ -198,14 +199,27 @@
|
|
198 |
linesTranscriptDiv.innerHTML = "";
|
199 |
return;
|
200 |
}
|
201 |
-
// Build the HTML
|
202 |
-
// The buffer is appended to the last line if it's non-empty
|
203 |
const linesHtml = lines.map((item, idx) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
let textContent = item.text;
|
205 |
if (idx === lines.length - 1 && buffer) {
|
206 |
textContent += `<span class="buffer">${buffer}</span>`;
|
207 |
}
|
208 |
-
|
|
|
|
|
|
|
209 |
}).join("");
|
210 |
|
211 |
linesTranscriptDiv.innerHTML = linesHtml;
|
|
|
179 |
The server might send:
|
180 |
{
|
181 |
"lines": [
|
182 |
+
{"speaker": 0, "text": "Hello.", "beg": "00:00", "end": "00:01"},
|
183 |
+
{"speaker": -2, "text": "Hi, no speaker here.", "beg": "00:01", "end": "00:02"},
|
184 |
+
{"speaker": -1, "text": "...", "beg": "00:02", "end": "00:03" },
|
185 |
...
|
186 |
],
|
187 |
"buffer": "..."
|
|
|
199 |
linesTranscriptDiv.innerHTML = "";
|
200 |
return;
|
201 |
}
|
|
|
|
|
202 |
const linesHtml = lines.map((item, idx) => {
|
203 |
+
let speakerLabel = "";
|
204 |
+
if (item.speaker === -2) {
|
205 |
+
speakerLabel = "No speaker";
|
206 |
+
} else if (item.speaker !== -1) {
|
207 |
+
speakerLabel = `Speaker ${item.speaker}`;
|
208 |
+
}
|
209 |
+
|
210 |
+
let timeInfo = "";
|
211 |
+
if (item.beg !== undefined && item.end !== undefined) {
|
212 |
+
timeInfo = ` [${item.beg}, ${item.end}]`;
|
213 |
+
}
|
214 |
+
|
215 |
let textContent = item.text;
|
216 |
if (idx === lines.length - 1 && buffer) {
|
217 |
textContent += `<span class="buffer">${buffer}</span>`;
|
218 |
}
|
219 |
+
|
220 |
+
return speakerLabel
|
221 |
+
? `<p><strong>${speakerLabel}${timeInfo}</strong> ${textContent}</p>`
|
222 |
+
: `<p>${textContent}</p>`;
|
223 |
}).join("");
|
224 |
|
225 |
linesTranscriptDiv.innerHTML = linesHtml;
|