Drop cloud and Ollama engine choices so audio stays on-machine via Docker Whisper, and tighten orphan detection plus UI around a single local flow.
41 lines
1.3 KiB
PHP
41 lines
1.3 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 local faster-whisper transcription for the recording.
|
|
*
|
|
* Always allowed: stops any current run first, then starts a new one.
|
|
*/
|
|
public function __invoke(TranscribeRecordingRequest $request, Recording $recording): RedirectResponse
|
|
{
|
|
if ($recording->isTranscribing() || $recording->hasActiveTranscriptionJob()) {
|
|
$recording->cancelTranscription(silent: true);
|
|
$recording->refresh();
|
|
}
|
|
|
|
$recording->update([
|
|
'transcription_driver' => 'local',
|
|
'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.');
|
|
}
|
|
}
|