Class: Ollama::Handlers::Say

Inherits:
Object
  • Object
show all
Includes:
Concern
Defined in:
lib/ollama/handlers/say.rb

Instance Attribute Summary collapse

Attributes included from Concern

#output, #result

Instance Method Summary collapse

Methods included from Concern

#to_proc

Constructor Details

#initialize(output: nil, voice: 'Samantha', interactive: nil) ⇒ Say

Returns a new instance of Say.



6
7
8
9
10
11
12
13
14
# File 'lib/ollama/handlers/say.rb', line 6

def initialize(output: nil, voice: 'Samantha', interactive: nil)
  @voice       = voice
  @interactive = interactive
  super(output:)
  unless output
    @output = open_output
    @output_pid = @output.pid
  end
end

Instance Attribute Details

#interactiveObject (readonly)

Returns the value of attribute interactive.



18
19
20
# File 'lib/ollama/handlers/say.rb', line 18

def interactive
  @interactive
end

#voiceObject (readonly)

Returns the value of attribute voice.



16
17
18
# File 'lib/ollama/handlers/say.rb', line 16

def voice
  @voice
end

Instance Method Details

#call(response) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ollama/handlers/say.rb', line 20

def call(response)
  if @output.closed?
    wait_output_pid
    @output     = open_output
    @output_pid = @output.pid
  end
  if content = response.response || response.message&.content
    @output.print content
  end
  response.done and @output.close
  self
end