Hiyve Components - v1.0.0
    Preparing search index...

    Interface MoodAnalysisProviderProps

    Props for the MoodAnalysisProvider component.

    The provider supports three callback props for receiving mood updates:

    • onMoodChange - Real-time mood updates for any participant
    • onReady - Called when analyzer is initialized
    • onError - Called when errors occur
    <MoodAnalysisProvider
    enabled={true}
    onMoodChange={(userId, state) => {
    console.log(`${userId}: ${state.emotion}`);
    }}
    onReady={() => setIsReady(true)}
    onError={(err) => setError(err)}
    >
    {children}
    </MoodAnalysisProvider>
    interface MoodAnalysisProviderProps {
        analyzerType?: AnalyzerType;
        children: ReactNode;
        enabled?: boolean;
        onError?: (error: Error) => void;
        onMoodChange?: (userId: string, moodState: MoodAnalysisMoodState) => void;
        onReady?: () => void;
        options?: AnalyzerOptions;
    }
    Index

    Properties

    analyzerType?: AnalyzerType

    Type 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 performance
    'human'
    
    children: ReactNode

    Child components to render.

    enabled?: boolean

    Whether mood analysis is enabled. When false, no analysis is performed and resources are released.

    false
    
    onError?: (error: Error) => void

    Callback fired when an error occurs during initialization or analysis.

    Errors can occur during:

    • Model loading (network issues, unsupported browser)
    • Video processing (WebGL issues, memory constraints)
    <MoodAnalysisProvider
    enabled={true}
    onError={(error) => {
    console.error('Mood analysis error:', error);
    setMoodEnabled(false);
    showNotification('Mood analysis unavailable');
    }}
    >
    {children}
    </MoodAnalysisProvider>
    onMoodChange?: (userId: string, moodState: MoodAnalysisMoodState) => void

    Callback 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 ID
    • moodState - The complete mood state including emotion, confidence, engagement, and timing information
    const 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>
    onReady?: () => void

    Callback fired when the analyzer is fully initialized and ready.

    Use this to know when mood analysis is available and processing. This is called after the analyzer loads its models and is ready to process video frames.

    <MoodAnalysisProvider
    enabled={true}
    onReady={() => {
    console.log('Mood analysis ready!');
    setMoodReady(true);
    }}
    >
    {children}
    </MoodAnalysisProvider>
    options?: AnalyzerOptions

    Configuration options for the analyzer.