fpessanha commited on
Commit
a02f3a0
·
1 Parent(s): d81bc46

Update app.py

Browse files
annotations.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ sample_id,sentence,emotion,comments
2
+ 007-0023,I was mostly hanging out in East Village in the clubs.,Angry,
app.py CHANGED
@@ -42,14 +42,18 @@ def save_annotation(emotions, comments):
42
 
43
  annotations.to_csv("annotations.csv", index=False) # Save to a CSV file
44
  #return f"Saved annotations for example {idx + 1}"
 
45
  def next_example(emotions, comments):
46
- """Move to the next example."""
47
- save_annotation(emotions, comments)
 
 
 
48
 
49
- if current_index["index"] < len(file_list) - 1:
50
- current_index["index"] += 1
51
- return load_example(current_index["index"])
52
- return "End of examples", None, 0, 0, 0, 0, ''
53
 
54
 
55
  def previous_example(emotion, comments):
@@ -60,31 +64,23 @@ def previous_example(emotion, comments):
60
  return load_example(current_index["index"])
61
  return load_example(current_index["index"])
62
 
63
-
64
  # Gradio Interface
65
- audio_path = 'test.mp4'
66
-
67
 
 
68
  with (gr.Blocks() as demo):
69
-
 
 
70
  with gr.Row():
71
  audio_player = gr.Audio(value=audio_path, label="Audio", type="filepath", interactive=False)
72
 
 
73
  with gr.Row():
74
  with gr.Accordion(label="Click to see the sentence", open=False):
75
  sentence_text = gr.Textbox(label="Sentence", interactive=False)
76
 
77
- with gr.Row():
78
- slider = gr.Slider(
79
- minimum=-100,
80
- maximum=100,
81
- step=1,
82
- label="Sentiment Slider",
83
- info="Slide to the left for negative sentiment, to the right for positive sentiment",
84
- show_label=True,
85
- elem_classes=["sentiment-slider"]
86
- )
87
-
88
  emotions = gr.Radio(["Joy", "Sad", "Angry", "Neutral"], label="Predominant Emotion")
89
 
90
  confidence = gr.Slider(label="Confidence (%)", minimum=0, maximum=100, step=10)
@@ -92,10 +88,10 @@ with (gr.Blocks() as demo):
92
  # Instructions for emotion annotation
93
  with gr.Sidebar():
94
  gr.Textbox()
95
- gr.Button()
96
 
 
 
97
  with gr.Row():
98
- save_button = gr.Button("Save Annotation")
99
  next_button = gr.Button("Next Example")
100
  previous_button = gr.Button("Previous Example")
101
 
@@ -105,10 +101,6 @@ with (gr.Blocks() as demo):
105
  current_index["index"]
106
  )
107
 
108
- save_button.click(
109
- save_annotation,
110
- inputs=[emotions, comments]
111
- )
112
  next_button.click(
113
  next_example,
114
  inputs=[emotions, comments],
 
42
 
43
  annotations.to_csv("annotations.csv", index=False) # Save to a CSV file
44
  #return f"Saved annotations for example {idx + 1}"
45
+
46
  def next_example(emotions, comments):
47
+ if emotions == '':
48
+ raise gr.Error("Please fill out the emotion section")
49
+ else:
50
+ """Move to the next example."""
51
+ save_annotation(emotions, comments)
52
 
53
+ if current_index["index"] < len(file_list) - 1:
54
+ current_index["index"] += 1
55
+ return load_example(current_index["index"])
56
+ #return "End of examples", None, 0, 0, 0, 0, ''
57
 
58
 
59
  def previous_example(emotion, comments):
 
64
  return load_example(current_index["index"])
65
  return load_example(current_index["index"])
66
 
 
67
  # Gradio Interface
 
 
68
 
69
+ audio_path = 'test.mp3'
70
  with (gr.Blocks() as demo):
71
+
72
+
73
+ # Row with audio player
74
  with gr.Row():
75
  audio_player = gr.Audio(value=audio_path, label="Audio", type="filepath", interactive=False)
76
 
77
+ # Hidden row with corresponding sentence
78
  with gr.Row():
79
  with gr.Accordion(label="Click to see the sentence", open=False):
80
  sentence_text = gr.Textbox(label="Sentence", interactive=False)
81
 
82
+ # Row for emotion annotation and confidence
83
+ with gr.Row():
 
 
 
 
 
 
 
 
 
84
  emotions = gr.Radio(["Joy", "Sad", "Angry", "Neutral"], label="Predominant Emotion")
85
 
86
  confidence = gr.Slider(label="Confidence (%)", minimum=0, maximum=100, step=10)
 
88
  # Instructions for emotion annotation
89
  with gr.Sidebar():
90
  gr.Textbox()
 
91
 
92
+
93
+ # Next and Previous Buttons
94
  with gr.Row():
 
95
  next_button = gr.Button("Next Example")
96
  previous_button = gr.Button("Previous Example")
97
 
 
101
  current_index["index"]
102
  )
103
 
 
 
 
 
104
  next_button.click(
105
  next_example,
106
  inputs=[emotions, comments],
files_to_annotate_padded_smaller_emotion_set/combined_annotations.xlsx CHANGED
Binary files a/files_to_annotate_padded_smaller_emotion_set/combined_annotations.xlsx and b/files_to_annotate_padded_smaller_emotion_set/combined_annotations.xlsx differ