-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
Hello,
According to the documentation for OpenAI::Resources::Audio::Transcriptions#create, the file parameter accepts StringIO. However, I'm unable to get this to work (similarly, it says it also accepts a String, but I can't get that to work either).
Here's an example:
require "openai"
file = File.open(ARGV[0])
stringio = StringIO.new(File.binread(ARGV[0]), "rb")
client = OpenAI::Client.new
transcription = client.audio.transcriptions.create(model: "gpt-4o-transcribe", file: stringio)
puts transcription.textIt works OK for the file object, but not the stringio object, which raises the following error:
{:url=>"https://api.openai.com/v1/audio/transcriptions", :status=>400, :body=>{:error=>{:message=>"Unsupported file format", :type=>"invalid_request_error", :param=>"file", :code=>"unsupported_value"}}} (OpenAI::Errors::BadRequestError)
Am I missing something or should this work?
The file I'm using is the wav sample here: https://www.kaggle.com/datasets/pavanelisetty/sample-audio-files-for-speech-recognition
Thank you
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels