Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio Transcribe Errors of 'Text' type #314

Open
klueless-io opened this issue Aug 21, 2023 · 0 comments
Open

Audio Transcribe Errors of 'Text' type #314

klueless-io opened this issue Aug 21, 2023 · 0 comments

Comments

@klueless-io
Copy link

Describe the bug
I am seeing an issue in the Audio Transcribe routine for response_format type of 'text'.

Code works for: srt, json, verbose_json, srt and vtt
Does not work for: text

describe '#transcriptions' do
      # https://platform.openai.com/docs/api-reference/audio/createTranscription

      let(:file) { 'spec/sample_files/audio/01-introduction.mp3' }
      let(:model) { 'whisper-1' }
      # let(:response_format) { %w[json text srt verbose_json vtt].sample }
      let(:response_format) { 'text' }
      let(:parameters) { { file:  File.open(file, "rb"), model: model, response_format: response_format } }

      it 'transcribes audio' do
        L.kv 'Response Format', response_format
        puts 1
        response = client.audio.transcribe(parameters: parameters)
        puts 'does not reach this for text'
        puts response
        # L.json(response)
      rescue StandardError => e
        L.error e.message
      end
    end

image

I believe the error is coming from to_json

 def json_post(path:, parameters:)
      to_json(conn.post(uri(path: path)) do |req|
        if parameters[:stream].respond_to?(:call)
          req.options.on_data = to_json_stream(user_proc: parameters[:stream])
          parameters[:stream] = true # Necessary to tell OpenAI to stream.
        elsif parameters[:stream]
          raise ArgumentError, "The stream parameter must be a Proc or have a #call method"
        end

        req.headers = headers
        req.body = parameters.to_json
      end&.body)
    end

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant