Class: CallRecordTranscriptionWorker
- Inherits:
-
Object
- Object
- CallRecordTranscriptionWorker
- Includes:
- Sidekiq::Worker
- Defined in:
- app/workers/call_record_transcription_worker.rb
Overview
Background worker for transcribing call recordings using AssemblyAI.
Processes individual call records and generates transcripts with speaker diarization.
Instance Method Summary collapse
Instance Method Details
#perform(options = {}) ⇒ Object
17 18 19 20 21 22 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 62 63 64 65 |
# File 'app/workers/call_record_transcription_worker.rb', line 17 def perform( = {}) = .symbolize_keys call_record_id = [:call_record_id] unless call_record_id Rails.logger.error '[CallRecordTranscriptionWorker] Missing call_record_id' return end call_record = CallRecord.find_by(id: call_record_id) unless call_record Rails.logger.error "[CallRecordTranscriptionWorker] CallRecord #{call_record_id} not found" return end Rails.logger.info "[CallRecordTranscriptionWorker] Processing CallRecord #{call_record_id}" # Run the transcription service service = CallRecordProcessing::TranscriptionService.new(call_record, force: [:force]) result = service.transcribe case result[:status] when :success Rails.logger.info "[CallRecordTranscriptionWorker] Success for CallRecord #{call_record_id}: #{result[:word_count]} words" # Queue AI summary generation CallRecordSummaryWorker.perform_async(call_record_id: call_record_id) # Queue embedding generation EmbeddingWorker.perform_async('CallRecord', call_record_id) when :skipped Rails.logger.info "[CallRecordTranscriptionWorker] Skipped CallRecord #{call_record_id}: #{result[:reason]}" when :error # Service caught the exception and returned error result (swallowed). # Must report explicitly since no exception will reach AppSignal. = "[CallRecordTranscriptionWorker] Error for CallRecord #{call_record_id}: #{result[:reason]} - #{result[:message]}" Rails.logger.error ErrorReporting.error( StandardError.new(), source: :background, call_record_id: call_record_id, reason: result[:reason] ) end # Note: Unexpected exceptions will propagate up and AppSignal's Sidekiq # integration will catch them automatically - no need for explicit reporting. end |