Spaces:
Runtime error
Runtime error
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) |