When I try to transcribe a .wav file with OpenAI, I get:
OpenAI Error [400]: invalid_request_error - Audio file might be corrupted or unsupported
If I override the mimeType to audio/wav, it works correctly.
$response = Prism::audio()
->using('openai', 'gpt-4o-transcribe')
->withInput(Audio::fromLocalPath(path: '/path/to/file.wav', mimeType: 'audio/wav'))
->asText();
This is because the Media.php detect it like this:
if (! $mimeType && ! ($mimeType = File::mimeType($path))) {
throw new InvalidArgumentException("Could not determine mime type for {$path}");
}
which returns audio/x-wav.
I'm not sure what the difference is, but I do see that OpenAI doesn't accept x-wav. I don't know if we should override the Media mimeType, or the OpenAI provider handling of this.
As said, override the mimeType works, but I think more people will run into this
When I try to transcribe a .wav file with OpenAI, I get:
If I override the mimeType to
audio/wav, it works correctly.This is because the Media.php detect it like this:
which returns
audio/x-wav.I'm not sure what the difference is, but I do see that OpenAI doesn't accept x-wav. I don't know if we should override the Media mimeType, or the OpenAI provider handling of this.
As said, override the mimeType works, but I think more people will run into this