Stream Whisper verbose metadata live without overflowing Reverb.
Persist accumulated verbose_json on the recording and broadcast only transcript/whisper deltas so the show page can render language, segments, word timestamps, and confidence while a run is in progress.
This commit is contained in:
@@ -67,17 +67,16 @@ class TranscribeRecording implements ShouldQueue
|
||||
'transcription_status' => 'processing',
|
||||
'transcription_started_at' => $this->recording->transcription_started_at ?? now(),
|
||||
'transcription_error' => null,
|
||||
'transcription_verbose' => null,
|
||||
])->save();
|
||||
|
||||
$this->runStartedAt ??= $this->recording->transcription_started_at?->toIso8601String();
|
||||
|
||||
$this->reportIfOwned('Preparing audio file…', 15);
|
||||
|
||||
try {
|
||||
$text = $transcription->transcribe(
|
||||
$this->recording,
|
||||
function (string $message, int $percent, ?string $partialTranscript = null): void {
|
||||
$this->reportIfOwned($message, $percent, $partialTranscript);
|
||||
function (string $message, int $percent, ?string $partialTranscript = null, ?array $whisper = null): void {
|
||||
$this->reportIfOwned($message, $percent, $partialTranscript, $whisper);
|
||||
},
|
||||
fn (): bool => Recording::query()->find($this->recording->id)
|
||||
?->ownsTranscriptionRun($this->runStartedAt) ?? false,
|
||||
@@ -135,11 +134,6 @@ class TranscribeRecording implements ShouldQueue
|
||||
{
|
||||
$this->recording->refresh();
|
||||
|
||||
if ($this->recording->ownsTranscriptionRun($this->runStartedAt)) {
|
||||
$this->reportIfOwned('Saving transcript…', 90);
|
||||
$this->recording->refresh();
|
||||
}
|
||||
|
||||
if ($this->recording->ownsTranscriptionRun($this->runStartedAt)) {
|
||||
$this->recording->markTranscriptionComplete($text);
|
||||
|
||||
@@ -172,12 +166,12 @@ class TranscribeRecording implements ShouldQueue
|
||||
return false;
|
||||
}
|
||||
|
||||
private function reportIfOwned(string $message, int $percent, ?string $partialTranscript = null): void
|
||||
private function reportIfOwned(string $message, int $percent, ?string $partialTranscript = null, ?array $whisper = null): void
|
||||
{
|
||||
if (! $this->recording->ownsTranscriptionRun($this->runStartedAt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->recording->reportProgress($message, $percent, partialTranscript: $partialTranscript);
|
||||
$this->recording->reportProgress($message, $percent, partialTranscript: $partialTranscript, whisperDelta: $whisper);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user