Skip to content

Feat(AI): Add in easier way to play audio for non streaming - #1501

Open
AustinBenoit wants to merge 5 commits into
mainfrom
feature/audio-as-float-non-live
Open

Feat(AI): Add in easier way to play audio for non streaming#1501
AustinBenoit wants to merge 5 commits into
mainfrom
feature/audio-as-float-non-live

Conversation

@AustinBenoit

Copy link
Copy Markdown
Contributor

Description

Provide details of the change, and generalize the change in the PR title above.

Feat(AI): Add in easier way to play audio for non streaming


Testing

Describe how you've tested these changes.

Ran this locally on 3.1 tts preview model.


Type of Change

Place an x the applicable box:

  • [ X Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

@AustinBenoit
AustinBenoit requested a review from a-maurice August 10, 2026 19:36

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread firebaseai/src/GenerateContentResponse.cs
Comment thread firebaseai/src/Internal/AudioHelpers.cs
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")))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would make sense to just check for "audio/"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants