Feat(AI): Add in easier way to play audio for non streaming - #1501
Feat(AI): Add in easier way to play audio for non streaming#1501AustinBenoit wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for decoding audio/pcm and audio/l16 formats in Firebase AI responses. It adds Audio and AudioAsFloat properties to GenerateContentResponse, extracts the PCM-to-float conversion logic into a shared AudioHelpers utility, and updates LiveSessionResponse to use this helper while extending its MIME type support. The review feedback suggests defensive programming improvements, specifically adding null and empty checks in GenerateContentResponse to avoid NullReferenceExceptions, and adding a null check and an unchecked block in AudioHelpers to prevent potential null pointer and overflow exceptions.
| return parts | ||
| .OfType<ModelContent.InlineDataPart>() | ||
| .Where(part => part.MimeType.StartsWith("audio/pcm")) | ||
| .Where(part => part.MimeType != null && (part.MimeType.StartsWith("audio/pcm") || part.MimeType.StartsWith("audio/l16"))) |
There was a problem hiding this comment.
Do you think it would make sense to just check for "audio/"?
Description
Feat(AI): Add in easier way to play audio for non streaming
Testing
Ran this locally on 3.1 tts preview model.
Type of Change
Place an
xthe applicable box: