Class: MeetingBuddy::Transcriber

Inherits:
Object
  • Object
show all
Defined in:
lib/meeting_buddy/transcriber.rb

Overview

Manages the transcript of the meeting

Defined Under Namespace

Classes: Line

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTranscriber

Returns a new instance of Transcriber.



11
12
13
14
# File 'lib/meeting_buddy/transcriber.rb', line 11

def initialize
  @full_transcript = ""
  @last_timestamp = 0
end

Instance Attribute Details

#full_transcriptString (readonly)

Returns full transcript of the meeting.

Returns:

  • (String)

    full transcript of the meeting



7
8
9
# File 'lib/meeting_buddy/transcriber.rb', line 7

def full_transcript
  @full_transcript
end

Instance Method Details

#latest(limit = 200) ⇒ String

Get the latest portion of the transcript

Parameters:

  • limit (Integer) (defaults to: 200)

    number of characters to return

Returns:

  • (String)

    latest portion of the transcript



32
33
34
# File 'lib/meeting_buddy/transcriber.rb', line 32

def latest(limit = 200)
  @full_transcript[[@full_transcript.length - limit, 0].max, limit] || raise(ArgumentError, "negative limit")
end

#process(line) ⇒ String

Process new transcription text

Parameters:

  • line (String)

    raw transcription line from whisper

Returns:

  • (String)

    cleaned transcription text



19
20
21
22
23
24
25
26
27
# File 'lib/meeting_buddy/transcriber.rb', line 19

def process(line)
  timestamp, text = parse_line(line)
  return Line.new(text: "", timestamp: Time.now) if text.empty?

  @full_transcript += text
  @last_timestamp = timestamp

  Line.new(text: format_transcription(text), timestamp: @last_timestamp)
end