synheart_emotion 0.2.0
synheart_emotion: ^0.2.0 copied to clipboard
On-device emotion inference from biosignals (HR/RR) for Flutter applications. Infers momentary emotions (Amused, Calm, Stressed) from heart rate and RR intervals using WESAD-trained machine learning models.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased] #
Planned #
- Enhanced model variants and configurations
- Additional emotion classes
- Performance optimizations
- Expanded platform support
0.2.0 - 2024-11-07 #
Breaking Changes #
- Removed
LinearSvmModelclass: TheLinearSvmModelclass andmodel_linear_svm.dartfile have been removed. The package now focuses exclusively on ONNX models. - Removed
json_linear_model.dartexport: The dead export forjson_linear_model.darthas been removed (file was missing). - Package structure change: Moved
lib/directory from repository root tosdks/flutter/lib/to follow proper Flutter package conventions.
Migration Guide #
If you were using LinearSvmModel, migrate to OnnxEmotionModel:
// Old (0.1.0)
import 'package:synheart_emotion/synheart_emotion.dart';
final model = LinearSvmModel.fromArrays(
modelId: 'wesad_emotion_v1_0',
version: '1.0',
labels: ['Amused', 'Calm', 'Stressed'],
featureNames: ['hr_mean', 'sdnn', 'rmssd'],
weights: [...],
biases: [...],
mu: {...},
sigma: {...},
);
final engine = EmotionEngine.fromPretrained(
config,
model: model,
);
// New (0.2.0)
import 'package:synheart_emotion/synheart_emotion.dart';
final model = await OnnxEmotionModel.loadFromAsset(
modelAssetPath: 'assets/ml/extratrees_wrist_all_v1_0.onnx',
metaAssetPath: 'assets/ml/extratrees_wrist_all_v1_0.meta.json',
);
final engine = EmotionEngine.fromPretrained(
config,
model: model,
);
Fixed #
- Fixed Flutter package structure:
lib/directory is now properly located insdks/flutter/lib/wherepubspec.yamlis located, enabling proper pub.dev publishing.
Changed #
- Package now exclusively uses ONNX models for emotion inference.
- Improved package structure alignment with Flutter package conventions.
0.1.0 - 2025-01-30 #
This release includes synchronized versions across all platforms. All SDKs are at version 0.1.0.
Added #
Multi-Platform SDK Support
-
Flutter/Dart SDK: Primary SDK for Flutter applications
- Published to pub.dev as
synheart_emotion - Full API parity with all features
- Asset-based model loading support
- Published to pub.dev as
-
Python SDK: Cross-platform Python package
- Published to PyPI as
synheart-emotion - Installable via
pip install synheart-emotion - Complete feature implementation with NumPy/Pandas
- Published to PyPI as
-
Android SDK: Kotlin library for Android applications
- Published to Maven Central as
ai.synheart:emotion - Minimum SDK 21 (Android 5.0+)
- Coroutines support for async operations
- Published to Maven Central as
-
iOS SDK: Swift package for iOS/macOS/watchOS/tvOS
- Available via Swift Package Manager
- Published to CocoaPods as
SynheartEmotion - Supports iOS 13.0+, macOS 10.15+, watchOS 6.0+, tvOS 13.0+
Core Features
- Core emotion inference engine with sliding window buffering
- Support for three emotion states: Amused, Calm, Stressed
- Feature extraction from heart rate and RR intervals (HR mean, SDNN, RMSSD)
- Real WESAD-trained Linear SVM model with 78% accuracy
- One-vs-rest classification with softmax probability output
- Configurable inference parameters (window size, step size, min RR count)
- Real-time streaming API via
EmotionStream(Flutter) - JSON model loader for loading trained models from assets
- Comprehensive test suite with unit tests and performance benchmarks
- Example applications for each platform
- Complete documentation (RFC-E1.1, MODEL_CARD, README, CONTRIBUTING)
Publishing Infrastructure
- GitHub Actions workflows for automated publishing:
- Flutter → pub.dev (OIDC trusted publishing)
- Python → PyPI (OIDC trusted publishing)
- Android → Maven Central (with GPG signing)
- iOS → Swift Package Manager + CocoaPods
- Automated CI/CD pipeline with tests and validation
- Version management across all SDKs
- Publishing documentation and guides
Changed #
- Repository structure: Restructured into monorepo with separate SDKs and examples directories
- Model weights: Replaced placeholder weights with real WESAD-trained parameters
- Model ID: Updated from
svm_linear_wrist_sdnn_v1_0_PLACEHOLDERtowesad_emotion_v1_0 - Model version: Updated from
1.0-demoto1.0 - Normalization parameters: Updated to WESAD dataset statistics
- Documentation: Updated README to reflect multi-platform SDKs, publishing setup, and real model usage
Architectural Decisions #
- No built-in storage: Library focuses on emotion inference only
- Users can implement their own storage using preferred methods
- Reduces dependencies and security concerns
- Provides flexibility for different storage requirements
- Privacy-first: All processing happens on-device, no network calls
- Minimal dependencies: Only requires Flutter SDK
- Asset-based models: Support for loading JSON models from Flutter assets
- SWIP SDK compatibility: Follows SWIP SDK model format and architecture patterns
Security Notes #
- ✅ Real trained model: Default SVM weights are trained on WESAD dataset
- Production ready: Model achieves 78% accuracy on validation data
- Data storage: Not included - implement your own secure storage as needed
Model Performance #
- Dataset: WESAD (15 subjects, 1200 windows)
- Accuracy: 78% on 3-class emotion recognition
- Balanced Accuracy: 76%
- F1-Score: 75%
- Features: HR mean, SDNN, RMSSD
- Classes: Amused, Calm, Stressed
Known Limitations #
- Limited to three emotion classes (Amused, Calm, Stressed)
- Requires minimum 30 RR intervals (configurable) for inference
- JSON model loading requires platform-specific asset bundling
- Android: Manual staging repository release required after publishing workflow
Dependencies #
Flutter SDK
- Flutter >=3.10.0
- Dart SDK >=3.0.0 <4.0.0
- No external package dependencies (beyond Flutter SDK)
Python SDK
- Python >=3.8
- NumPy >=1.21.0
- Pandas >=1.3.0
- Optional: scikit-learn, joblib, xgboost (for ML features)
Android SDK
- Android API 21+ (Android 5.0 Lollipop)
- Kotlin 1.8+
- AndroidX Core KTX
- Kotlin Coroutines
iOS SDK
- iOS 13.0+ / macOS 10.15+ / watchOS 6.0+ / tvOS 13.0+
- Swift 5.0+
- No external dependencies
Performance #
- HR mean calculation: 0.008ms average
- SDNN calculation: 0.007ms average
- RMSSD calculation: 0.002ms average
- Full feature extraction: 0.006ms average
- Model inference: 0.008ms average
- Full inference cycle: 0.010ms average
- All metrics well under <5ms target latency (measured on mid-range devices)
Installation #
Flutter
dependencies:
synheart_emotion: ^0.1.0
Python
pip install synheart-emotion
Android
dependencies {
implementation("ai.synheart:emotion:0.1.0")
}
iOS
Swift Package Manager:
dependencies: [
.package(url: "https://github.com/synheart-ai/synheart-emotion.git", from: "0.1.0")
]
CocoaPods:
pod 'SynheartEmotion', '~> 0.1.0'
Publishing Information #
- Flutter: Published to pub.dev
- Python: Published to PyPI
- Android: Published to Maven Central
- iOS: Available via Swift Package Manager and CocoaPods
Acknowledgments #
- WESAD dataset for training data
- All contributors and testers