Skip to main content

Overview

The Synheart Emotion Kotlin SDK provides real-time emotion inference from biosignals for native Android applications.

Installation

Add to build.gradle.kts:
dependencies {
    implementation("ai.synheart:emotion:0.1.0")
}

Requirements

  • Android API 21+
  • Kotlin 1.8+

Quick Start

Basic Usage

import ai.synheart.emotion.*

val config = EmotionConfig()
val engine = EmotionEngine.fromPretrained(config)

engine.push(
    hr = 72.0,
    rrIntervalsMs = listOf(850.0, 820.0, 830.0, 845.0, 825.0),
    timestamp = Date()
)

val results = engine.consumeReady()
results.forEach { result ->
    println("Emotion: ${result.emotion} (${result.confidence})")
}

Real-Time with Coroutines

lifecycleScope.launch {
    val emotionEngine = EmotionEngine.fromPretrained()

    // Stream from wearable
    synheartWear.streamHR(interval = 5000L).collect { metrics ->
        emotionEngine.push(
            hr = metrics.getMetric(MetricType.HR) ?: 0.0,
            rrIntervalsMs = metrics.rrIntervals,
            timestamp = Date()
        )

        val results = emotionEngine.consumeReady()
        results.forEach { result ->
            updateUI(result)
        }
    }
}

API Reference

EmotionEngine

Methods:
MethodDescriptionReturns
fromPretrained(config)Load pretrained modelEmotionEngine
push(hr, rrIntervalsMs, timestamp)Push biosignal dataUnit
consumeReady()Get ready resultsList<EmotionResult>

EmotionConfig

Parameters:
ParameterTypeDefault
windowDurationLong60000L (ms)
stepDurationLong5000L (ms)

EmotionResult

Properties:
PropertyTypeDescription
emotionEmotionDetected emotion
confidenceDoubleConfidence (0-1)
timestampDateWhen inferred

Resources

For comprehensive documentation, see the full README on GitHub.
Author: Israel Goytom