Browse documentation

HumAIn Android SDK

Integrate a HumAIn into a native Android app, phone, tablet or TV. The fourth integration mode alongside Quick Embed, Express Backend and React Frontend.

Overview

The fourth integration mode, alongside Quick Embed, Express Backend and React Frontend. Those three are an iframe; Android has no iframe that survives a TV remote, so this is a native library that speaks the same backend directly.

Works on phones, tablets and Android TV. minSdk 24.

Contact TensorGo

What you need from TensorGo before you can build and deploy. Five items, all one line each.

  • Package registry URL — the Maven repository the SDK is published to.
  • Registry token, read-only, one per integrator — and which kind, since the header differs: a gldt- deploy token uses Deploy-Token, a glpat- personal access token uses Private-Token. The wrong one is a bare 401 that says nothing about the header.
  • Artifact version to depend on, e.g. 0.1.0.
  • Host for each environment you are targeting. Only the host differs between them; the rest of the base URL does not.
  • Room id, per HumAIn. This is the credential for the session API — there is no separate API key — so read Security below before deciding where it lives in your app.

What you can and cannot change

The short version: you own the interface, TensorGo owns the HumAIn.

Yours

The SDK is headless. It ships exactly one composable — SlidesView, and that is optional — so there are no screens, no theme, no colours and no layout to work around. What it hands you is a conversation:

videoTrack: StateFlow<VideoTrack?>attach to any renderer, any size or shape
state: StateFlow<PlayerState>Idle · Checking · Starting · Connecting · Live · Ended · Error
events: SharedFlow<HumainEvent>her replies, user transcripts, speaking state, slide changes, end
currentSlide / pptUrlrender the deck yourself, or ignore it
start() · sendText() · interrupt() · setMicMuted() · end()drive it however your UI wants

So you build the whole interface: full-screen kiosk, a corner bubble, a tab in an existing app, a TV lean-back layout. You decide when a session starts, what the loading state looks like, whether there is a transcript at all, how push-to-talk behaves, and what happens when it ends.

This is more control than the iframe modes give you. Quick Embed renders TensorGo's player and you size the frame; here nothing is rendered for you.

Not yours

The HumAIn itself is configured in the TensorGo dashboard, not through the SDK: its prompt and personality, voice and speech provider, knowledge base, avatar, slide deck, wake and stop phrases, and which languages it accepts. The SDK picks a language, and even that is validated against the allowed list server-side.

Session capacity — how many conversations can run at once — is an account-level limit. /session/availability/by-room/ reports the remaining headroom, and start() fails cleanly when the pool is full rather than launching into an error.

What you need from TensorGo

A configured HumAIn and its room id, a credential for the package registry, and the account that owns the session capacity — see the checklist at the top.

About the API key

The Android SDK never sends an API key. There is no auth header anywhere in it. The session API authenticates on the room id alone — which is why the room id must come from your backend and never be compiled into an APK. See Security below; the key shown in the dashboard is the HumAIn owner's, and its runtime effect is a kill switch: deactivate it and that HumAIn stops answering.

1. Add the dependency

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        // livekit-android pulls audioswitch, which is published only here.
        maven {
            url = uri("https://jitpack.io")
            content { includeGroup("com.github.davidliu") }
        }
        maven {
            url = uri("<the registry URL you were given>")
            credentials(HttpHeaderCredentials::class) {
                // Deploy-Token for a `gldt-` token, Private-Token for a personal
                // access token. The wrong one returns a bare 401 that says
                // nothing about the header.
                name = "Deploy-Token"
                value = "<your read-only token>"
            }
            authentication { create<HttpHeaderAuthentication>("header") }
        }
    }
}
// app/build.gradle.kts
dependencies {
    implementation("com.tensorgo.humain:player:0.1.0")
}

2. Permissions

The library declares what it needs, including RECORD_AUDIO and the <queries> entry that lets Android bind to a speech service. Your app only has to request the runtime permission:

ActivityCompat.requestPermissions(
    this, arrayOf(Manifest.permission.RECORD_AUDIO), REQUEST_MIC,
)

Ask before starting a session. A session checks the device up front and refuses to launch a container it cannot talk to — that is deliberate, because failing early costs nothing while failing late has already spent one of your concurrent-session slots. To run deliberately without a microphone, say so:

HumainConfig(baseUrl = …, features = Features(voice = false))

3. Start a session

val player = HumainPlayer(
    context,
    HumainConfig(baseUrl = "https://<your-host>/meeting-service/meeting-service"),
) { yourBackend.fetchHumainRoomId() }        // see Security

lifecycleScope.launch {
    launch { player.state.collect { /* Idle, Starting, Connecting, Live, Ended, Error */ } }
    launch { player.videoTrack.collect { /* attach to a renderer */ } }
    launch {
        player.events.collect { event ->
            when (event) {
                is HumainEvent.AvatarText     -> Unit   // her reply, one sentence at a time
                is HumainEvent.UserTranscript -> Unit   // what the user said
                is HumainEvent.AvatarSpeaking -> Unit   // her audio is playing
                is HumainEvent.SlideChanged   -> Unit   // deck moved
                is HumainEvent.Ended          -> finish()
                is HumainEvent.Error          -> Unit
                else -> Unit
            }
        }
    }
    player.start()
}

start() returns once the media subscription is up. She is not visible yet — the avatar container takes up to three minutes to boot, and state reaches Live only when her first video frame arrives.

One HumainPlayer is one session. It is not reusable; end() is terminal.

4. Show her

AndroidView(
    factory = { ctx ->
        TextureViewRenderer(ctx).also { view ->
            player.initVideoRenderer(view)      // before attaching the track
            track.addRenderer(view)
        }
    },
    onRelease = { view ->
        track.removeRenderer(view)
        view.release()
    },
)

onRelease matters: a renderer left attached to the track after its view is gone stops the live one drawing too.

5. Talking to her

Three routes, all ending at the same place, so use one at a time:

RouteWhen
Microphone → STT containerAutomatic when the device has a microphone the app can read. Continuous, allows barge-in.
player.sendText(text)Typed input, or your own speech recognition.
SpeechRecognizer → sendTextAndroid TV with only a remote. See TvSpeech.

Running two together sends every turn twice. player.usesMicrophoneLeg says whether the SDK is already capturing.

player.setMicMuted(true) before start() opens the microphone muted, which is what a push-to-talk UI wants.

6. Ending

player.end()      // returns immediately

Releases the device at once and reaps the containers in the background. Call close() from your lifecycle's teardown — leaking a session keeps a GPU container running and holds a concurrency slot until the server reaps it.

Android TV

<uses-feature android:name="android.software.leanback" android:required="true" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  • Use LEANBACK_LAUNCHER, or the TV home screen will not list your app.
  • Every control needs a visible focus state. Focus is the entire navigation model.
  • Keep controls ~48dp from the edges; panels overscan.
  • A TV remote's microphone is usually not available to third-party apps — it is bonded to the device assistant. A USB microphone works and is the better answer: the SDK then captures directly and you get barge-in. Without one, drive SpeechRecognizer and send the text.
  • The SDK detects an attached USB microphone even though the box declares it has none, and tags its audio as media rather than voice-call so it reaches HDMI.

Security — read this before shipping

The room id is the entire credential. There is no key, token or signature on the session API: whoever holds a room id can start sessions against your GPU budget until the concurrency cap, and can mint a viewer token to watch other people's calls on that room.

So HumainPlayer takes a suspending provider, not a string. A constant compiled into an APK is a published secret — apktool recovers it in seconds, and obfuscation does not help because it goes over the wire anyway.

HumainPlayer(context, config) {
    api.startHumainSession().roomId       // your backend, authenticated as the user
}

Your backend holds the X-Humain-Api-Key and returns a short-lived room id. That is the Express Backend integration mode, consumed by Kotlin instead of React.

For kiosks and TVs, where there is no user to authenticate, use device enrolment: a one-time pairing code exchanged for a device token in the Keystore, swapped for a room id per session. Revocable per device, which a baked-in id is not.