From c6f642ed0ae826c4e0669696cb7d70e7a74aee0b Mon Sep 17 00:00:00 2001 From: Valentino Stoll Date: Thu, 19 Dec 2024 09:57:55 -0500 Subject: [PATCH] Suppress logging of 'Heard:' while listening for question --- lib/podcast_buddy/co_host.rb | 2 ++ lib/podcast_buddy/listener.rb | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/podcast_buddy/co_host.rb b/lib/podcast_buddy/co_host.rb index c2b26bf..d15e006 100644 --- a/lib/podcast_buddy/co_host.rb +++ b/lib/podcast_buddy/co_host.rb @@ -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 @@ -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 diff --git a/lib/podcast_buddy/listener.rb b/lib/podcast_buddy/listener.rb index f9178c0..21e83e2 100644 --- a/lib/podcast_buddy/listener.rb +++ b/lib/podcast_buddy/listener.rb @@ -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 @@ -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 @@ -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