Stream Whisper segments so the UI can show live transcript text.
Consume faster-whisper SSE instead of blocking on one JSON response, persist growing text and progress over Reverb, and drop the fake percent heartbeat.
This commit is contained in:
@@ -76,9 +76,11 @@ class TranscribeRecording implements ShouldQueue
|
||||
try {
|
||||
$text = $transcription->transcribe(
|
||||
$this->recording,
|
||||
function (string $message, int $percent): void {
|
||||
$this->reportIfOwned($message, $percent);
|
||||
function (string $message, int $percent, ?string $partialTranscript = null): void {
|
||||
$this->reportIfOwned($message, $percent, $partialTranscript);
|
||||
},
|
||||
fn (): bool => Recording::query()->find($this->recording->id)
|
||||
?->ownsTranscriptionRun($this->runStartedAt) ?? false,
|
||||
);
|
||||
|
||||
if (! $this->claimSuccessfulTranscript($text)) {
|
||||
@@ -170,12 +172,12 @@ class TranscribeRecording implements ShouldQueue
|
||||
return false;
|
||||
}
|
||||
|
||||
private function reportIfOwned(string $message, int $percent): void
|
||||
private function reportIfOwned(string $message, int $percent, ?string $partialTranscript = null): void
|
||||
{
|
||||
if (! $this->recording->ownsTranscriptionRun($this->runStartedAt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->recording->reportProgress($message, $percent);
|
||||
$this->recording->reportProgress($message, $percent, partialTranscript: $partialTranscript);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user