Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ internal class AudioHelper {
audioRecord.startRecording()

return flow {
val buffer = ByteArray(bufferSize)
while (!stopRecording) {
val buffer = ByteArray(bufferSize)
val bytesRead = audioRecord.read(buffer, 0, buffer.size)
if (bytesRead > 0) {
emit(buffer.copyOf(bytesRead))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,22 +276,6 @@ internal constructor(
continue
}
try {
val functionContent = Json.decodeFromString<ToolCallSetup.Internal>(receivedJson)
emit(
LiveContentResponse(
null,
LiveContentResponse.Status.NORMAL,
functionContent.toolCall.functionCalls.map {
FunctionCallPart(it.name, it.args.orEmpty().mapValues { x -> x.value ?: JsonNull })
}
)
)
continue
} catch (e: Exception) {
Log.w(TAG, "Failed to decode function calling: ${e.message}")
}
try {

val serverContent = Json.decodeFromString<ServerContentSetup.Internal>(receivedJson)
val data = serverContent.serverContent.modelTurn.toPublic()
if (outputModalities.contains(ContentModality.AUDIO)) {
Expand All @@ -304,8 +288,24 @@ internal constructor(
emit(LiveContentResponse(data, LiveContentResponse.Status.NORMAL, null))
}
}
continue
} catch (e: Exception) {
Log.i(TAG, "Failed to decode server content: ${e.message}")
}
try {
val functionContent = Json.decodeFromString<ToolCallSetup.Internal>(receivedJson)
emit(
LiveContentResponse(
null,
LiveContentResponse.Status.NORMAL,
functionContent.toolCall.functionCalls.map {
FunctionCallPart(it.name, it.args.orEmpty().mapValues { x -> x.value ?: JsonNull })
}
)
)
continue
} catch (e: Exception) {
Log.w(TAG, "Failed to decode server content: ${e.message}")
Log.w(TAG, "Failed to decode function calling: ${e.message}")
}
}
}
Expand Down
Loading