Class: OmniAI::Speak
- Inherits:
-
Object
- Object
- OmniAI::Speak
- Defined in:
- lib/omniai/speak.rb
Overview
An abstract class that provides a consistent interface for processing speak requests.
Usage:
class OmniAI::OpenAI::Speak < OmniAI::Speakw
module Model
WHISPER_1 = "whisper-1"
end
protected
# @return [Hash]
def payload
raise NotImplementedError, "#{self.class.name}#payload undefined"
end
# @return [String]
def path
raise NotImplementedError, "#{self.class.name}#path undefined"
end
end
client.transcribe(File.open("..."), model: "...", format: :json)
Defined Under Namespace
Modules: Format
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input, client:, model:, voice:, speed: nil, format: nil) ⇒ Speak
constructor
A new instance of Speak.
- #process! {|chunk| ... } ⇒ Tempfile
Constructor Details
#initialize(input, client:, model:, voice:, speed: nil, format: nil) ⇒ Speak
Returns a new instance of Speak.
71 72 73 74 75 76 77 78 |
# File 'lib/omniai/speak.rb', line 71 def initialize(input, client:, model:, voice:, speed: nil, format: nil) @input = input @client = client @model = model @voice = voice @speed = speed @format = format end |
Class Method Details
.process!(input, client:, model:, voice:, speed: nil, format: nil) {|chunk| ... } ⇒ Tempfile
55 56 57 |
# File 'lib/omniai/speak.rb', line 55 def self.process!(input, client:, model:, voice:, speed: nil, format: nil, &) new(input, client:, model:, voice:, speed:, format:).process!(&) end |
Instance Method Details
#process! {|chunk| ... } ⇒ Tempfile
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/omniai/speak.rb', line 85 def process!(&block) response = request! raise HTTPError, response.flush unless response.status.ok? if block stream!(response:, &block) else fetch!(response:) end end |