diff --git a/firebase-ai/gradle.properties b/firebase-ai/gradle.properties index a61baee5a19..15e226a5aac 100644 --- a/firebase-ai/gradle.properties +++ b/firebase-ai/gradle.properties @@ -12,5 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -version=17.4.0 +version=99.9.9 latestReleasedVersion=17.3.0 diff --git a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/AudioHelper.kt b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/AudioHelper.kt index 08e90fc8538..edeb7c332f7 100644 --- a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/AudioHelper.kt +++ b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/AudioHelper.kt @@ -162,7 +162,7 @@ internal class AudioHelper( fun build(): AudioHelper { val playbackTrack = AudioTrack( - AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION).build(), + AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_MEDIA).setContentType(AudioAttributes.CONTENT_TYPE_SPEECH).build(), AudioFormat.Builder() .setSampleRate(24000) .setChannelMask(AudioFormat.CHANNEL_OUT_MONO) diff --git a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/LiveSession.kt b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/LiveSession.kt index c703cd959c3..f9507f5e8d3 100644 --- a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/LiveSession.kt +++ b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/LiveSession.kt @@ -37,6 +37,7 @@ import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.atomic.AtomicBoolean import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancel import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED import kotlinx.coroutines.flow.Flow @@ -270,6 +271,7 @@ internal constructor( Json.encodeToString( BidiGenerateContentRealtimeInputSetup(mediaChunks.map { (it.toInternal()) }).toInternal() ) + println("Sending $jsonString") session.send(Frame.Text(jsonString)) } } @@ -372,6 +374,7 @@ internal constructor( if (it.interrupted) { playBackQueue.clear() } else { + println("Sending audio parts") val audioParts = it.content?.parts?.filterIsInstance().orEmpty() for (part in audioParts) { playBackQueue.add(part.inlineData) @@ -387,7 +390,7 @@ internal constructor( } } } - .launchIn(scope) + .launchIn(CoroutineScope(Dispatchers.IO)) } /** @@ -398,7 +401,7 @@ internal constructor( * Launched asynchronously on [scope]. */ private fun listenForModelPlayback(enableInterruptions: Boolean = false) { - scope.launch { + CoroutineScope(Dispatchers.IO).launch { while (isActive) { val playbackData = playBackQueue.poll() if (playbackData == null) { @@ -414,7 +417,7 @@ internal constructor( * no echo cancellation */ // TODO(b/408223520): Conditionally pause when param is added - if (enableInterruptions != true) { + if (!enableInterruptions) { audioHelper?.pauseRecording() } audioHelper?.playAudio(playbackData)