File size: 1,910 Bytes
fea9f64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import plotly.graph_objects as go
from typing import Dict

def create_emotion_plot(emotions: Dict[str, float]) -> str:
    """Create emotion distribution plot"""
    fig = go.Figure()
    
    # Add bar plot
    fig.add_trace(go.Bar(
        x=list(emotions.keys()),
        y=list(emotions.values()),
        marker_color='rgb(55, 83, 109)'
    ))
    
    # Update layout
    fig.update_layout(
        title='Emotion Distribution',
        xaxis_title='Emotion',
        yaxis_title='Score',
        yaxis_range=[0, 1],
        template='plotly_white',
        height=400
    )
    
    return fig.to_html(include_plotlyjs=True)

def create_pitch_plot(pitch_data: Dict) -> str:
    """Create pitch analysis plot"""
    fig = go.Figure()
    
    # Add box plot
    fig.add_trace(go.Box(
        y=[pitch_data['min'], pitch_data['mean'], pitch_data['max']],
        name='Pitch Distribution',
        boxpoints='all'
    ))
    
    # Update layout
    fig.update_layout(
        title='Pitch Analysis',
        yaxis_title='Frequency (Hz)',
        template='plotly_white',
        height=400
    )
    
    return fig.to_html(include_plotlyjs=True)

def create_energy_plot(energy_data: Dict) -> str:
    """Create energy analysis plot"""
    fig = go.Figure()
    
    # Add indicator
    fig.add_trace(go.Indicator(
        mode='gauge+number',
        value=energy_data['mean'],
        title={'text': 'Voice Energy Level'},
        gauge={
            'axis': {'range': [0, 1]},
            'bar': {'color': 'darkblue'},
            'steps': [
                {'range': [0, 0.3], 'color': 'lightgray'},
                {'range': [0.3, 0.7], 'color': 'gray'},
                {'range': [0.7, 1], 'color': 'darkgray'}
            ]
        }
    ))
    
    # Update layout
    fig.update_layout(
        height=300,
        template='plotly_white'
    )
    
    return fig.to_html(include_plotlyjs=True)