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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Unreleased

- Added support for RTVI protocol 2.0.0. `BotOutputData` now includes new fields: `willBeSpoken`, `spokenStatus`, `spokenProgress`, and `segmentId`, enabling word-level TTS progress tracking. The `spoken` field is deprecated in favour of `willBeSpoken`.
- The client now logs a warning when the bot is running an older RTVI protocol version than the client.

# 1.1.0

- Update signature of `Transport.deserializeConnectParams()` to also take the startBot `APIRequest`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody
import java.util.UUID

internal const val RTVI_PROTOCOL_VERSION = "1.0.0"
internal const val RTVI_PROTOCOL_VERSION = "2.0.0"

/**
* A Pipecat client. Connects to an RTVI backend and handles bidirectional audio and video
Expand Down Expand Up @@ -97,6 +97,12 @@ open class PipecatClient<TransportType : Transport<ConnectParams>, ConnectParams

connection?.ready?.resolveOk(Unit)

val botMajor = data.version.split(".").firstOrNull()?.toIntOrNull() ?: 0
val clientMajor = RTVI_PROTOCOL_VERSION.split(".").firstOrNull()?.toIntOrNull() ?: 0
if (botMajor < clientMajor) {
Log.w(TAG, "Bot is running an older RTVI protocol version (${data.version}) than the client ($RTVI_PROTOCOL_VERSION). Some features may not be available.")
}

callbacks.onBotReady(data)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,52 @@ package ai.pipecat.client.types
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/** Protocol 2.0.0: Word-level TTS progress through a spoken segment. */
@Serializable
data class BotOutputProgressData(
@SerialName("accumulated_text")
val accumulatedText: String,
@SerialName("remaining_text")
val remainingText: String
)

/**
* Streaming bot output tokens/chunks.
*
* Example:
* {"text":"your","spoken":true,"aggregated_by":"word"}
* Example (Protocol 2.0.0):
* {"text":"your","aggregated_by":"word","will_be_spoken":true,"spoken_status":"in-progress","segment_id":1}
*/
@Serializable
data class BotOutputData(
val text: String,
val spoken: Boolean,
@SerialName("aggregated_by")
val aggregatedBy: String
)
val aggregatedBy: String,

/** Deprecated (Protocol 1.4.x). Use [willBeSpoken] instead. */
@Deprecated("Use willBeSpoken instead. This field will be removed in a future version.")
val spoken: Boolean? = null,

/** Protocol 2.0.0: Whether this text will be spoken by TTS. */
@SerialName("will_be_spoken")
val willBeSpoken: Boolean? = null,

/** Protocol 2.0.0: Current lifecycle stage of the spoken segment. */
@SerialName("spoken_status")
val spokenStatus: SpokenStatus? = null,

/** Protocol 2.0.0: Word-level progress through the spoken segment. */
@SerialName("spoken_progress")
val spokenProgress: BotOutputProgressData? = null,

/** Protocol 2.0.0: Correlates progress events for the same spoken segment. */
@SerialName("segment_id")
val segmentId: Int? = null
) {
/** Protocol 2.0.0: Lifecycle stage of a spoken segment. */
@Serializable
enum class SpokenStatus {
@SerialName("new") New,
@SerialName("in-progress") InProgress,
@SerialName("completed") Completed
}
}
Loading