Class: MeetingBuddy::Listener
- Inherits:
-
Object
- Object
- MeetingBuddy::Listener
- Defined in:
- lib/meeting_buddy/listener.rb
Instance Method Summary collapse
- #announce_what_you_hear! ⇒ Object
-
#initialize(transcriber:, signal:) ⇒ Listener
constructor
A new instance of Listener.
- #start ⇒ Object
-
#stop ⇒ Object
Stop the listening process.
- #suppress_what_you_hear! ⇒ Object
Constructor Details
#initialize(transcriber:, signal:) ⇒ Listener
Returns a new instance of Listener.
7 8 9 10 11 12 13 |
# File 'lib/meeting_buddy/listener.rb', line 7 def initialize(transcriber:, signal:) @transcriber = transcriber @signal = signal @shutdown = false @announce_hearing = true @whisper_logger = MeetingBuddy.whisper_logger end |
Instance Method Details
#announce_what_you_hear! ⇒ Object
52 53 54 |
# File 'lib/meeting_buddy/listener.rb', line 52 def announce_what_you_hear! @announce_hearing = true end |
#start ⇒ Object
15 16 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 |
# File 'lib/meeting_buddy/listener.rb', line 15 def start Sync do |parent| Open3.popen3(MeetingBuddy.config.whisper_command) do |_stdin, stdout, stderr, _thread| error_task = parent.async do log_errors(stderr) rescue IOError => e MeetingBuddy.logger.debug "Error stream closed: #{e.}" end output_task = parent.async do log_output(stdout) rescue IOError => e MeetingBuddy.config.logger.debug "Output stream closed: #{e.}" end MeetingBuddy.logger.info "Listening..." while (line = stdout.gets) break if @shutdown MeetingBuddy.logger.debug("Shutdown: process_audio_stream...") and break if @shutdown begin process_transcription(line) rescue IOError => e MeetingBuddy.config.logger.debug "Main output stream closed: #{e.}" end end error_task.wait output_task.wait end end end |
#stop ⇒ Object
Stop the listening process
48 49 50 |
# File 'lib/meeting_buddy/listener.rb', line 48 def stop @shutdown = true end |
#suppress_what_you_hear! ⇒ Object
56 57 58 |
# File 'lib/meeting_buddy/listener.rb', line 56 def suppress_what_you_hear! @announce_hearing = false end |