Skip to content

Commit

Permalink
Suppress logging of 'Heard:' while listening for question
Browse files Browse the repository at this point in the history
  • Loading branch information
codenamev committed Dec 19, 2024
1 parent 610c58c commit c6f642e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/podcast_buddy/co_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def wait_for_question_start
PodcastBuddy.logger.debug("Input received...") if input.include?("\n")
if input.include?("\n")
@listening_for_question_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) if @listening_for_question_at.nil?
@listener.suppress_what_you_hear!
@question_buffer = ""
end
rescue Timeout::Error
Expand Down Expand Up @@ -88,6 +89,7 @@ def wait_for_question_end
else
PodcastBuddy.logger.info "End of question signal. Generating answer..."
@listening_for_question_at = nil
@listener.announce_what_you_hear!
answer_question(@question_buffer).wait
break
end
Expand Down
13 changes: 11 additions & 2 deletions lib/podcast_buddy/listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def initialize(transcriber:, whisper_command: PodcastBuddy.whisper_command, whis
@whisper_logger = whisper_logger || PodcastBuddy.whisper_logger
@transcription_signal = PodSignal.new
@listening_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
@announce_hearing = true
end

# Start the listening process
Expand Down Expand Up @@ -51,6 +52,14 @@ def subscribe(&block)
@transcription_signal.subscribe(&block)
end

def announce_what_you_hear!
@announce_hearing = true
end

def suppress_what_you_hear!
@announce_hearing = false
end

private

# Process a single transcription line
Expand All @@ -59,10 +68,10 @@ def process_transcription(line)
text = @transcriber.process(line)
return if text.empty?

PodcastBuddy.logger.info "Heard: #{text}"
PodcastBuddy.logger.info "Heard: #{text}" if @announce_hearing
PodcastBuddy.update_transcript(text)
@transcription_queue << text
@transcription_signal.trigger({ text: text, started_at: @listening_start })
@transcription_signal.trigger({text: text, started_at: @listening_start})
text
end
end
Expand Down

0 comments on commit c6f642e

Please sign in to comment.