Message when launching transcription and no audio is detected
Browse files
whisperlivekit/audio_processor.py
CHANGED
|
@@ -453,31 +453,38 @@ class AudioProcessor:
|
|
| 453 |
await self.update_diarization(end_attributed_speaker, combined)
|
| 454 |
buffer_diarization = combined
|
| 455 |
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 459 |
"speaker": 1,
|
| 460 |
"text": "",
|
| 461 |
-
"beg": format_time(0),
|
| 462 |
-
"end": format_time(
|
| 463 |
"diff": 0
|
| 464 |
}]
|
| 465 |
|
| 466 |
response = {
|
| 467 |
-
"
|
|
|
|
| 468 |
"buffer_transcription": buffer_transcription,
|
| 469 |
"buffer_diarization": buffer_diarization,
|
| 470 |
"remaining_time_transcription": state["remaining_time_transcription"],
|
| 471 |
"remaining_time_diarization": state["remaining_time_diarization"]
|
| 472 |
}
|
| 473 |
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
|
| 478 |
-
if
|
|
|
|
| 479 |
yield response
|
| 480 |
-
self.last_response_content =
|
| 481 |
|
| 482 |
# Check for termination condition
|
| 483 |
if self.is_stopping:
|
|
|
|
| 453 |
await self.update_diarization(end_attributed_speaker, combined)
|
| 454 |
buffer_diarization = combined
|
| 455 |
|
| 456 |
+
response_status = "active_transcription"
|
| 457 |
+
final_lines_for_response = lines.copy()
|
| 458 |
+
|
| 459 |
+
if not tokens and not buffer_transcription and not buffer_diarization:
|
| 460 |
+
response_status = "no_audio_detected"
|
| 461 |
+
final_lines_for_response = []
|
| 462 |
+
elif response_status == "active_transcription" and not final_lines_for_response:
|
| 463 |
+
final_lines_for_response = [{
|
| 464 |
"speaker": 1,
|
| 465 |
"text": "",
|
| 466 |
+
"beg": format_time(state.get("end_buffer", 0)),
|
| 467 |
+
"end": format_time(state.get("end_buffer", 0)),
|
| 468 |
"diff": 0
|
| 469 |
}]
|
| 470 |
|
| 471 |
response = {
|
| 472 |
+
"status": response_status,
|
| 473 |
+
"lines": final_lines_for_response,
|
| 474 |
"buffer_transcription": buffer_transcription,
|
| 475 |
"buffer_diarization": buffer_diarization,
|
| 476 |
"remaining_time_transcription": state["remaining_time_transcription"],
|
| 477 |
"remaining_time_diarization": state["remaining_time_diarization"]
|
| 478 |
}
|
| 479 |
|
| 480 |
+
current_response_signature = f"{response_status} | " + \
|
| 481 |
+
' '.join([f"{line['speaker']} {line['text']}" for line in final_lines_for_response]) + \
|
| 482 |
+
f" | {buffer_transcription} | {buffer_diarization}"
|
| 483 |
|
| 484 |
+
if current_response_signature != self.last_response_content and \
|
| 485 |
+
(final_lines_for_response or buffer_transcription or buffer_diarization or response_status == "no_audio_detected"):
|
| 486 |
yield response
|
| 487 |
+
self.last_response_content = current_response_signature
|
| 488 |
|
| 489 |
# Check for termination condition
|
| 490 |
if self.is_stopping:
|
whisperlivekit/web/live_transcription.html
CHANGED
|
@@ -427,7 +427,8 @@
|
|
| 427 |
buffer_transcription = "",
|
| 428 |
buffer_diarization = "",
|
| 429 |
remaining_time_transcription = 0,
|
| 430 |
-
remaining_time_diarization = 0
|
|
|
|
| 431 |
} = data;
|
| 432 |
|
| 433 |
renderLinesWithBuffer(
|
|
@@ -436,13 +437,19 @@
|
|
| 436 |
buffer_transcription,
|
| 437 |
remaining_time_diarization,
|
| 438 |
remaining_time_transcription,
|
| 439 |
-
false
|
|
|
|
| 440 |
);
|
| 441 |
};
|
| 442 |
});
|
| 443 |
}
|
| 444 |
|
| 445 |
-
function renderLinesWithBuffer(lines, buffer_diarization, buffer_transcription, remaining_time_diarization, remaining_time_transcription, isFinalizing = false) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
const linesHtml = lines.map((item, idx) => {
|
| 447 |
let timeInfo = "";
|
| 448 |
if (item.beg !== undefined && item.end !== undefined) {
|
|
|
|
| 427 |
buffer_transcription = "",
|
| 428 |
buffer_diarization = "",
|
| 429 |
remaining_time_transcription = 0,
|
| 430 |
+
remaining_time_diarization = 0,
|
| 431 |
+
status = "active_transcription"
|
| 432 |
} = data;
|
| 433 |
|
| 434 |
renderLinesWithBuffer(
|
|
|
|
| 437 |
buffer_transcription,
|
| 438 |
remaining_time_diarization,
|
| 439 |
remaining_time_transcription,
|
| 440 |
+
false,
|
| 441 |
+
status
|
| 442 |
);
|
| 443 |
};
|
| 444 |
});
|
| 445 |
}
|
| 446 |
|
| 447 |
+
function renderLinesWithBuffer(lines, buffer_diarization, buffer_transcription, remaining_time_diarization, remaining_time_transcription, isFinalizing = false, current_status = "active_transcription") {
|
| 448 |
+
if (current_status === "no_audio_detected") {
|
| 449 |
+
linesTranscriptDiv.innerHTML = "<p style='text-align: center; color: #666; margin-top: 20px;'><em>No audio detected...</em></p>";
|
| 450 |
+
return;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
const linesHtml = lines.map((item, idx) => {
|
| 454 |
let timeInfo = "";
|
| 455 |
if (item.beg !== undefined && item.end !== undefined) {
|