Spaces:
Runtime error
Runtime error
import plotly.graph_objects as go | |
def add_emoji(emotions_list): | |
for s in range(len(emotions_list)): | |
if emotions_list[s]=="surprise": emotions_list[s]="surprise π²" | |
elif emotions_list[s]=="joy": emotions_list[s]="joy π" | |
elif emotions_list[s]=="anger": emotions_list[s]="anger π€¬" | |
elif emotions_list[s]=="neutral": emotions_list[s]="neutral π" | |
elif emotions_list[s]=="disgust": emotions_list[s]="disgust π€’" | |
elif emotions_list[s]=="fear": emotions_list[s]="fear π¨" | |
elif emotions_list[s]=="sadness": emotions_list[s]="sadness π" | |
else: print(s) | |
return emotions_list | |
def spider_chart(dictionary): | |
fig = go.Figure(data=go.Scatterpolar( | |
r=[round(v*100,2) for v in dictionary.values()], | |
theta= add_emoji([k for k in dictionary.keys()]), | |
fill='toself')) | |
fig.update_layout( | |
polar=dict( | |
radialaxis=dict( | |
visible=True | |
), | |
), | |
showlegend=False, | |
width = 400, height = 400, | |
title = "Audio Sentiment Analysis", title_x=0.5) | |
return fig |