OptionalanalyzerType of sentiment analyzer to use.
'human' - Human.js based, fastest (5-10x), handles 30+ streams'mediapipe' - MediaPipe based, fast (3-5x), handles 20-30 streams'faceapi' - face-api.js based, baseline performanceChild components to render.
OptionalenabledWhether mood analysis is enabled. When false, no analysis is performed and resources are released.
OptionalonCallback fired when an error occurs during initialization or analysis.
OptionalonCallback fired when any participant's mood state changes.
This is the recommended way to receive real-time mood updates. Called every time the analyzer detects a mood change for any participant.
The callback receives:
userId - The participant's user IDmoodState - The complete mood state including emotion, confidence,
engagement, and timing informationconst handleMoodChange = (userId: string, moodState: MoodState) => {
// Log mood changes
console.log(`${userId}: ${moodState.emotion} (${moodState.confidence.toFixed(2)})`);
// Track engagement
if (moodState.engagement < 0.3) {
console.log(`${userId} appears distracted`);
}
// Send to analytics
analytics.track('mood_change', {
userId,
emotion: moodState.emotion,
confidence: moodState.confidence,
engagement: moodState.engagement,
timestamp: moodState.timestamp,
});
// Update external state
setParticipantMoods(prev => ({
...prev,
[userId]: moodState.emotion
}));
};
<MoodAnalysisProvider onMoodChange={handleMoodChange}>
{children}
</MoodAnalysisProvider>
OptionalonCallback fired when the analyzer is fully initialized and ready.
OptionaloptionsConfiguration options for the analyzer.
Props for the MoodAnalysisProvider component.
Remarks
The provider supports three callback props for receiving mood updates:
onMoodChange- Real-time mood updates for any participantonReady- Called when analyzer is initializedonError- Called when errors occurExample