-
Notifications
You must be signed in to change notification settings - Fork 963
Live API v2 #9215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dl/live
Are you sure you want to change the base?
Live API v2 #9215
Conversation
|
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1Affected Products
Test Logs |
@@ -323,5 +323,9 @@ describe('Live', function () { | |||
}); | |||
*/ | |||
}); | |||
|
|||
describe('startAudioConversation', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there supposed to be something here?
/** A flag to indicate if the conversation has been stopped. */ | ||
private isStopped = false; | ||
/** A resolver function for the `stopPromise`. */ | ||
private stopResolver!: () => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to use a Deferred
? I think this is the deferred pattern. Here's a usage: https://github.com/firebase/firebase-js-sdk/blob/realtime-for-web/packages/analytics/src/index.test.ts#L132 I don't know that you gain a lot except that it reads clearly that you're doing the deferred pattern, and it is a bit bulkier than you need (you don't need wrapCallback or reject). Maybe you can just refactor this so you put both stopPromise and stopResolver into a deferred object like:
private stopDeferred: { promise: Promise<void>; resolve: () => void } = {
resolve: () => {},
promise: new Promise(resolve => {
this.stopDeferred.resolve = resolve;
})
};
And then you just refer to this.stopDeferred.resolve() and this.stopDeferred.promise everywhere you reference them. That way it's clear this is a Deferred and they belong to each other.
Adds
startAudioConversation
, a new helper function for creating real-time voice conversations with the model.The existing
LiveSession
API is low-level and requires a lot of boilerplate to manage microphone audio and playback. This helper handles all that complexity, making it much easier for developers to add voice features to their apps.Sample