Class: OxAiWorkers::Models::OpenaiWhisper
- Inherits:
-
Object
- Object
- OxAiWorkers::Models::OpenaiWhisper
- Defined in:
- lib/oxaiworkers/models/openai_whisper.rb
Instance Method Summary collapse
-
#initialize(uri_base: nil, api_key: nil, model: 'whisper-1') ⇒ OpenaiWhisper
constructor
A new instance of OpenaiWhisper.
- #transcribe(binary:, language: nil) ⇒ Object
Constructor Details
#initialize(uri_base: nil, api_key: nil, model: 'whisper-1') ⇒ OpenaiWhisper
Returns a new instance of OpenaiWhisper.
6 7 8 9 10 11 |
# File 'lib/oxaiworkers/models/openai_whisper.rb', line 6 def initialize(uri_base: nil, api_key: nil, model: 'whisper-1') @api_key = api_key || OxAiWorkers.configuration.access_token_openai @uri_base = uri_base @client = OpenAI::Client.new(access_token: @api_key, uri_base:) @model = model end |
Instance Method Details
#transcribe(binary:, language: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/oxaiworkers/models/openai_whisper.rb', line 13 def transcribe(binary:, language: nil) response = @client.audio.transcribe( parameters: { model: @model, file: binary, language: } ) response['text'] end |