Class: AssemblyaiCompletionWorker
- Inherits:
-
Object
- Object
- AssemblyaiCompletionWorker
- Includes:
- Sidekiq::Worker
- Defined in:
- app/workers/assemblyai_completion_worker.rb
Overview
Worker to process completed AssemblyAI transcriptions.
Triggered by webhook after AssemblyAI finishes transcribing.
This worker:
- Fetches the completed transcript from AssemblyAI
- Formats and saves the transcript with speaker diarization
- Runs LeMUR analysis (summary, action items, etc.)
- Generates content embeddings for semantic search
Instance Method Summary collapse
Instance Method Details
#perform(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/workers/assemblyai_completion_worker.rb', line 23 def perform( = {}) = .symbolize_keys call_record_id = [:call_record_id] transcript_id = [:transcript_id] unless call_record_id && transcript_id Rails.logger.error '[AssemblyaiCompletionWorker] Missing call_record_id or transcript_id' return end call_record = CallRecord.find_by(id: call_record_id) unless call_record Rails.logger.error "[AssemblyaiCompletionWorker] CallRecord #{call_record_id} not found" return end Rails.logger.info "[AssemblyaiCompletionWorker] Processing CallRecord #{call_record_id} with transcript #{transcript_id}" begin # Fetch the completed transcript from AssemblyAI assemblyai = AssemblyaiClient.instance result = assemblyai.get_transcription(transcript_id) if result['status'] != 'completed' Rails.logger.error "[AssemblyaiCompletionWorker] Transcript #{transcript_id} status: #{result['status']}" call_record.update!(transcription_state: :error) return end # Use the TranscriptionService to process the result service = CallRecordProcessing::TranscriptionService.new(call_record) service.process_completed_transcript(result) Rails.logger.info "[AssemblyaiCompletionWorker] Completed processing CallRecord #{call_record_id}" rescue StandardError => e call_record.update!(transcription_state: :error) raise # AppSignal captures error details automatically end end |