@@ -95,7 +95,8 @@ internal constructor(
9595 */
9696 @RequiresPermission(RECORD_AUDIO )
9797 public suspend fun startAudioConversation (
98- functionCallHandler : ((FunctionCallPart ) -> FunctionResponsePart )? = null
98+ functionCallHandler : ((FunctionCallPart ) -> FunctionResponsePart )? = null,
99+ enableInterruptions : Boolean? = null,
99100 ) {
100101
101102 val context = firebaseApp.applicationContext
@@ -120,7 +121,7 @@ internal constructor(
120121
121122 recordUserAudio()
122123 processModelResponses(functionCallHandler)
123- listenForModelPlayback()
124+ listenForModelPlayback(enableInterruptions )
124125 }
125126 }
126127
@@ -375,22 +376,26 @@ internal constructor(
375376 *
376377 * Launched asynchronously on [scope].
377378 */
378- private fun listenForModelPlayback () {
379+ private fun listenForModelPlayback (enableInterruptions : Boolean? = null ) {
379380 scope.launch {
380381 while (isActive) {
381382 val playbackData = playBackQueue.poll()
382383 if (playbackData == null ) {
383384 // The model playback queue is complete, so we can continue recording
384385 // TODO(b/408223520): Conditionally resume when param is added
385- audioHelper?.resumeRecording()
386+ if (enableInterruptions != true ) {
387+ audioHelper?.resumeRecording()
388+ }
386389 yield ()
387390 } else {
388391 /* *
389392 * We pause the recording while the model is speaking to avoid interrupting it because of
390393 * no echo cancellation
391394 */
392395 // TODO(b/408223520): Conditionally pause when param is added
393- audioHelper?.pauseRecording()
396+ if (enableInterruptions != true ) {
397+ audioHelper?.pauseRecording()
398+ }
394399
395400 audioHelper?.playAudio(playbackData)
396401 }
0 commit comments