Class: Ollama::Handlers::Say

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

Instance Attribute Summary

Attributes included from Concern

#output, #result

Instance Method Summary collapse

Methods included from Concern

#to_proc

Constructor Details

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

Returns a new instance of Say.



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

def initialize(output: nil, voice: 'Samantha')
  output ||= IO.popen(Shellwords.join([ 'say', '-v', voice ]), 'w')
  super(output:)
  @output.sync = true
end

Instance Method Details

#call(response) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/ollama/handlers/say.rb', line 12

def call(response)
  if content = response.response || response.message&.content
    @output.print content
  end
  response.done and @output.close
  self
end