Skip to content

Commit 50691ee

Browse files
committed
test
1 parent bf0a543 commit 50691ee

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

firebase-ai/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
version=17.4.0
15+
version=99.9.9
1616
latestReleasedVersion=17.3.0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ internal class AudioHelper(
162162
fun build(): AudioHelper {
163163
val playbackTrack =
164164
AudioTrack(
165-
AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION).build(),
165+
AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_MEDIA).setContentType(AudioAttributes.CONTENT_TYPE_SPEECH).build(),
166166
AudioFormat.Builder()
167167
.setSampleRate(24000)
168168
.setChannelMask(AudioFormat.CHANNEL_OUT_MONO)

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import java.util.concurrent.ConcurrentLinkedQueue
3737
import java.util.concurrent.atomic.AtomicBoolean
3838
import kotlin.coroutines.CoroutineContext
3939
import kotlinx.coroutines.CoroutineScope
40+
import kotlinx.coroutines.Dispatchers
4041
import kotlinx.coroutines.cancel
4142
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
4243
import kotlinx.coroutines.flow.Flow
@@ -270,6 +271,7 @@ internal constructor(
270271
Json.encodeToString(
271272
BidiGenerateContentRealtimeInputSetup(mediaChunks.map { (it.toInternal()) }).toInternal()
272273
)
274+
println("Sending $jsonString")
273275
session.send(Frame.Text(jsonString))
274276
}
275277
}
@@ -372,6 +374,7 @@ internal constructor(
372374
if (it.interrupted) {
373375
playBackQueue.clear()
374376
} else {
377+
println("Sending audio parts")
375378
val audioParts = it.content?.parts?.filterIsInstance<InlineDataPart>().orEmpty()
376379
for (part in audioParts) {
377380
playBackQueue.add(part.inlineData)
@@ -387,7 +390,7 @@ internal constructor(
387390
}
388391
}
389392
}
390-
.launchIn(scope)
393+
.launchIn(CoroutineScope(Dispatchers.IO))
391394
}
392395

393396
/**
@@ -398,7 +401,7 @@ internal constructor(
398401
* Launched asynchronously on [scope].
399402
*/
400403
private fun listenForModelPlayback(enableInterruptions: Boolean = false) {
401-
scope.launch {
404+
CoroutineScope(Dispatchers.IO).launch {
402405
while (isActive) {
403406
val playbackData = playBackQueue.poll()
404407
if (playbackData == null) {
@@ -414,9 +417,10 @@ internal constructor(
414417
* no echo cancellation
415418
*/
416419
// TODO(b/408223520): Conditionally pause when param is added
417-
if (enableInterruptions != true) {
420+
if (!enableInterruptions) {
418421
audioHelper?.pauseRecording()
419422
}
423+
println("Playing audio")
420424
audioHelper?.playAudio(playbackData)
421425
}
422426
}

0 commit comments

Comments
 (0)