The Pipecat Android SDK provides a Kotlin implementation for building voice and multimodal AI applications on Android. It handles:
- Real-time audio and video streaming
- Bot communication and state management
- Media device handling
- Configuration management
- Event handling
Installation
Add the dependency for your chosen transport to your build.gradle
file. For example, to use the Daily transport:
implementation "ai.pipecat:daily-transport:0.3.3"
Example
Here’s a simple example using Daily as the transport layer. Note that the clientConfig
is optional and depends
on what is required by the bot backend.
val clientConfig = listOf(
ServiceConfig(
service = "llm",
options = listOf(
Option("model", "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo"),
Option("messages", Value.Array(
Value.Object(
"role" to Value.Str("system"),
"content" to Value.Str("You are a helpful assistant.")
)
))
)
),
ServiceConfig(
service = "tts",
options = listOf(
Option("voice", "79a125e8-cd45-4c13-8a67-188112f4dd22")
)
)
)
val callbacks = object : RTVIEventCallbacks() {
override fun onBackendError(message: String) {
Log.e(TAG, "Error from backend: $message")
}
}
val options = RTVIClientOptions(
services = listOf(ServiceRegistration("llm", "together"), ServiceRegistration("tts", "cartesia")),
params = RTVIClientParams(baseUrl = "<your API url>", config = clientConfig)
)
val client = RTVIClient(DailyTransport.Factory(context), callbacks, options)
client.connect().await() // Using Coroutines
// Or using callbacks:
// client.start().withCallback { /* handle completion */ }
Documentation