From b2fcdf4323ca6c9416a99ea9056a4ea5b918dd4a Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 2 Apr 2026 14:39:15 +0200 Subject: [PATCH 1/3] Normalize mimeType for audio.wav Normalizes legacy formats to audio/wav --- src/ValueObjects/Media/Media.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ValueObjects/Media/Media.php b/src/ValueObjects/Media/Media.php index 90c4bd096..e315fcf8d 100644 --- a/src/ValueObjects/Media/Media.php +++ b/src/ValueObjects/Media/Media.php @@ -249,14 +249,15 @@ public function base64(): ?string public function mimeType(): ?string { - if ($this->mimeType) { - return $this->mimeType; - } - - if ($content = $this->rawContent()) { + if ($this->mimeType === null && $content = $this->rawContent()) { $this->mimeType = (new finfo(FILEINFO_MIME_TYPE))->buffer($content) ?: null; } + $this->mimeType = match (strtolower($this->mimeType)) { + 'audio/x-wav', 'audio/wave', 'audio/x-pn-wav', 'audio/vnd.wave' => 'audio/wav', + default => $this->mimeType, + }; + return $this->mimeType; } From b819dc69b526a6262dbcaf1b6d8c81d11ed5713a Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 2 Apr 2026 14:43:20 +0200 Subject: [PATCH 2/3] Fix mime type from 'audio/x-wav' to 'audio/wav' --- tests/Providers/Gemini/GeminiMediaTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Providers/Gemini/GeminiMediaTest.php b/tests/Providers/Gemini/GeminiMediaTest.php index fe1cab83d..f47edfcd2 100644 --- a/tests/Providers/Gemini/GeminiMediaTest.php +++ b/tests/Providers/Gemini/GeminiMediaTest.php @@ -153,7 +153,7 @@ function (Request $request): bool { 'text' => 'Transcribe this audio', ]) ->and($message[1]['inline_data'])->toHaveKeys(['mime_type', 'data']) - ->and($message[1]['inline_data']['mime_type'])->toBe('audio/x-wav') + ->and($message[1]['inline_data']['mime_type'])->toBe('audio/wav') ->and($message[1]['inline_data']['data'])->toBe( base64_encode(file_get_contents('tests/Fixtures/sample-audio.wav')) ); @@ -171,7 +171,7 @@ function (Request $request): bool { $audioUrl => Http::response( file_get_contents('tests/Fixtures/sample-audio.wav'), 200, - ['Content-Type' => 'audio/x-wav'] + ['Content-Type' => 'audio/wav'] ), ]); @@ -197,7 +197,7 @@ function (Request $request): bool { 'text' => 'What is in this audio', ]) ->and($message[1]['inline_data'])->toHaveKeys(['mime_type', 'data']) - ->and($message[1]['inline_data']['mime_type'])->toBe('audio/x-wav') + ->and($message[1]['inline_data']['mime_type'])->toBe('audio/wav') ->and($message[1]['inline_data']['data'])->toBe( base64_encode(file_get_contents('tests/Fixtures/sample-audio.wav')) ); From dc20d12f71a5cc9940da860527a120a8f6953b1b Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 2 Apr 2026 14:44:11 +0200 Subject: [PATCH 3/3] Refactor mimeType matching to remove strtolower --- src/ValueObjects/Media/Media.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ValueObjects/Media/Media.php b/src/ValueObjects/Media/Media.php index e315fcf8d..fe1628c3d 100644 --- a/src/ValueObjects/Media/Media.php +++ b/src/ValueObjects/Media/Media.php @@ -253,7 +253,7 @@ public function mimeType(): ?string $this->mimeType = (new finfo(FILEINFO_MIME_TYPE))->buffer($content) ?: null; } - $this->mimeType = match (strtolower($this->mimeType)) { + $this->mimeType = match ($this->mimeType) { 'audio/x-wav', 'audio/wave', 'audio/x-pn-wav', 'audio/vnd.wave' => 'audio/wav', default => $this->mimeType, };