Skip to content

Commit 47b3e41

Browse files
committed
update
1 parent ffc6344 commit 47b3e41

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

firebase-ai/src/main/kotlin/com/google/firebase/ai/common/util/android.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ internal fun AudioRecord.readAsFlow() = flow {
3838

3939
while (true) {
4040
if (recordingState != AudioRecord.RECORDSTATE_RECORDING) {
41+
// delay uses a different scheduler in the backend, so it's "stickier" in its enforcement when
42+
// compared to yield.
4143
delay(0)
4244
continue
4345
}
4446
val bytesRead = read(buffer, 0, buffer.size)
4547
if (bytesRead > 0) {
4648
emit(buffer.copyOf(bytesRead))
4749
}
50+
// delay uses a different scheduler in the backend, so it's "stickier" in its enforcement when
51+
// compared to yield.
4852
delay(0)
4953
}
5054
}

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/LiveSession.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ internal constructor(
155155
* function call. The [FunctionResponsePart] that the callback function returns will be
156156
* automatically sent to the model.
157157
*
158+
* @param transcriptHandler A callback function that is invoked whenever the model receives a
159+
* transcript. The first [Transcription] object is the input transcription, and the second is the
160+
* output transcription.
161+
*
158162
* @param enableInterruptions If enabled, allows the user to speak over or interrupt the model's
159163
* ongoing reply.
160164
*
@@ -250,6 +254,8 @@ internal constructor(
250254
)
251255
}
252256
?.let { emit(it.toPublic()) }
257+
// delay uses a different scheduler in the backend, so it's "stickier" in its
258+
// enforcement when compared to yield.
253259
delay(0)
254260
}
255261
}
@@ -427,6 +433,8 @@ internal constructor(
427433
?.accumulateUntil(MIN_BUFFER_SIZE)
428434
?.onEach {
429435
sendAudioRealtime(InlineData(it, "audio/pcm"))
436+
// delay uses a different scheduler in the backend, so it's "stickier" in its enforcement
437+
// when compared to yield.
430438
delay(0)
431439
}
432440
?.catch { throw FirebaseAIException.from(it) }
@@ -515,6 +523,8 @@ internal constructor(
515523
if (!enableInterruptions) {
516524
audioHelper?.resumeRecording()
517525
}
526+
// delay uses a different scheduler in the backend, so it's "stickier" in its enforcement
527+
// when compared to yield.
518528
delay(0)
519529
} else {
520530
/**

0 commit comments

Comments
 (0)