|
25 | 25 | from .models.instrumented import InstrumentationSettings |
26 | 26 |
|
27 | 27 |
|
28 | | -AudioMediaType: TypeAlias = Literal['audio/wav', 'audio/mpeg'] |
| 28 | +AudioMediaType: TypeAlias = Literal['audio/wav', 'audio/mpeg', 'audio/ogg', 'audio/flac', 'audio/aiff', 'audio/aac'] |
29 | 29 | ImageMediaType: TypeAlias = Literal['image/jpeg', 'image/png', 'image/gif', 'image/webp'] |
30 | 30 | DocumentMediaType: TypeAlias = Literal[ |
31 | 31 | 'application/pdf', |
|
48 | 48 | 'video/3gpp', |
49 | 49 | ] |
50 | 50 |
|
51 | | -AudioFormat: TypeAlias = Literal['wav', 'mp3'] |
| 51 | +AudioFormat: TypeAlias = Literal['wav', 'mp3', 'oga', 'flac', 'aiff', 'aac'] |
52 | 52 | ImageFormat: TypeAlias = Literal['jpeg', 'png', 'gif', 'webp'] |
53 | 53 | DocumentFormat: TypeAlias = Literal['csv', 'doc', 'docx', 'html', 'md', 'pdf', 'txt', 'xls', 'xlsx'] |
54 | 54 | VideoFormat: TypeAlias = Literal['mkv', 'mov', 'mp4', 'webm', 'flv', 'mpeg', 'mpg', 'wmv', 'three_gp'] |
@@ -182,13 +182,25 @@ class AudioUrl(FileUrl): |
182 | 182 |
|
183 | 183 | @property |
184 | 184 | def media_type(self) -> AudioMediaType: |
185 | | - """Return the media type of the audio file, based on the url.""" |
| 185 | + """Return the media type of the audio file, based on the url. |
| 186 | +
|
| 187 | + References: |
| 188 | + - Gemini: https://ai.google.dev/gemini-api/docs/audio#supported-formats |
| 189 | + """ |
186 | 190 | if self.url.endswith('.mp3'): |
187 | 191 | return 'audio/mpeg' |
188 | | - elif self.url.endswith('.wav'): |
| 192 | + if self.url.endswith('.wav'): |
189 | 193 | return 'audio/wav' |
190 | | - else: |
191 | | - raise ValueError(f'Unknown audio file extension: {self.url}') |
| 194 | + if self.url.endswith('.flac'): |
| 195 | + return 'audio/flac' |
| 196 | + if self.url.endswith('.oga'): |
| 197 | + return 'audio/ogg' |
| 198 | + if self.url.endswith('.aiff'): |
| 199 | + return 'audio/aiff' |
| 200 | + if self.url.endswith('.aac'): |
| 201 | + return 'audio/aac' |
| 202 | + |
| 203 | + raise ValueError(f'Unknown audio file extension: {self.url}') |
192 | 204 |
|
193 | 205 | @property |
194 | 206 | def format(self) -> AudioFormat: |
@@ -358,6 +370,10 @@ class ToolReturn: |
358 | 370 | _audio_format_lookup: dict[str, AudioFormat] = { |
359 | 371 | 'audio/mpeg': 'mp3', |
360 | 372 | 'audio/wav': 'wav', |
| 373 | + 'audio/flac': 'flac', |
| 374 | + 'audio/ogg': 'oga', |
| 375 | + 'audio/aiff': 'aiff', |
| 376 | + 'audio/aac': 'aac', |
361 | 377 | } |
362 | 378 | _image_format_lookup: dict[str, ImageFormat] = { |
363 | 379 | 'image/jpeg': 'jpeg', |
|
0 commit comments