Skip to content

.wav files not working in OpenAI because of audio/x-wav instead of audio/wav mimeType #981

@barryvdh

Description

@barryvdh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions