Files
AndyTranscribe/app/Http/Controllers/TranscribeController.php
T
ben bc6cb5efa4 Fix stuck transcriptions and make transcripts stoppable and searchable.
Raise queue retry_after above the job timeout, recover orphaned runs, allow stop/restart with any engine, and keep finished transcripts searchable in the recordings list.
2026-08-12 15:10:33 +02:00

43 lines
1.5 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Http\Requests\TranscribeRecordingRequest;
use App\Jobs\TranscribeRecording;
use App\Models\Recording;
use Illuminate\Http\RedirectResponse;
class TranscribeController extends Controller
{
/**
* Queue transcription for the recording with the chosen engine.
*
* Always allowed: stops any current run first, then starts the new engine.
*/
public function __invoke(TranscribeRecordingRequest $request, Recording $recording): RedirectResponse
{
if ($recording->isTranscribing() || $recording->hasActiveTranscriptionJob()) {
$recording->cancelTranscription(silent: true);
$recording->refresh();
}
$driver = $request->validated('driver');
$recording->update([
'transcription_driver' => $driver,
'ollama_url' => $driver === 'ollama' ? rtrim($request->validated('ollama_url'), '/') : null,
'transcription_status' => 'pending',
'transcription_progress' => 'Queued — waiting to start…',
'transcription_percent' => 5,
'transcription_started_at' => now(),
'transcription_error' => null,
// Keep the previous transcript until a new run succeeds.
'transcribed_at' => $recording->transcribed_at,
]);
TranscribeRecording::dispatch($recording->fresh());
return back()->with('success', 'Transcription started. Progress updates below.');
}
}