File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -216,10 +216,13 @@ class _Decoder:
216216
217217 @classmethod
218218 def from_mime_type (cls , mime_type : str ) -> Self | None :
219- """Returns whether the mime type matches ."""
219+ """Returns the decoder matching the mime type, or None ."""
220220 mime_type = mime_type .lower ()
221+ # Strip parameters from mime type.
222+ # e.g. 'audio/pcm;rate=24000' -> 'audio/pcm'
223+ base_mime_type = mime_type .split (';' )[0 ].strip ()
221224 for subcls in cls .__subclasses__ ():
222- if mime_type in subcls .MIME_TYPES :
225+ if mime_type in subcls .MIME_TYPES or base_mime_type in subcls . MIME_TYPES :
223226 return subcls ()
224227
225228 return None
@@ -274,8 +277,7 @@ def decode(self, data: gemini_example_pb2.Audio) -> bytes:
274277 wav_file .setsampwidth (array .dtype .itemsize )
275278 wav_file .setframerate (data .sample_rate )
276279 wav_file .writeframes (array .tobytes ())
277-
278- return f .getvalue ()
280+ return f .getvalue ()
279281
280282
281283def _validate_pcm_int_16 (data : np .ndarray ) -> None :
You can’t perform that action at this time.
0 commit comments