Sha256: ca040573e4f3de01855f37aa7af756ad783c90d4c37563400712739ee7173b8b

Contents?: true

Size: 550 Bytes

Versions: 3

Compression:

Stored size: 550 Bytes

Contents

class SlackSmartBot
  module AI
    module OpenAI
      def self.whisper_transcribe(open_ai_client, model, file)
        require "openai"
        user = Thread.current[:user]
        response = open_ai_client.transcribe(
          parameters: {
            model: model, # Required.
            file: File.open(file, "rb"),
          },
        )
        if !response.body.json(:message).empty?
          return false, response.body.json(:message)
        else
          return true, response.body.json(:text)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-smart-bot-1.14.2 lib/slack/smart-bot/ai/open_ai/whisper_transcribe.rb
slack-smart-bot-1.14.1 lib/slack/smart-bot/ai/open_ai/whisper_transcribe.rb
slack-smart-bot-1.14.0 lib/slack/smart-bot/ai/open_ai/whisper_transcribe.rb