The Pipecat Android SDK provides a Kotlin implementation for building voice and multimodal AI applications on Android. It handles:

  • Real-time audio streaming
  • Bot communication and state management
  • Media device handling
  • Configuration management
  • Event handling

Installation

Add the dependencies to your build.gradle file:

// Core SDK
implementation "ai.pipecat:client:0.3.0"

// Daily transport implementation
implementation "ai.pipecat:daily-transport:0.3.0"

Example

Here’s a simple example using Daily as the transport layer:

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