fpessanha commited on
Commit
dd966ce
·
1 Parent(s): 7b09113

Fix: Persistent storage update

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -267,7 +267,7 @@ def load_example(index):
267
  "comments": ''}
268
  )
269
  print(previous_annotation)
270
- return (sentence, audio_path, previous_annotation['emotion'], previous_annotation['confidence'], current_index['index'] + 1, previous_annotation["comments"])
271
 
272
 
273
  def save_annotation(emotions, confidence, comments, participant_id, ann_completed):
@@ -291,6 +291,7 @@ def save_annotation(emotions, confidence, comments, participant_id, ann_complete
291
 
292
  def next_example(emotions, confidence, comments, participant_id, ann_completed):
293
  """Move to the next example."""
 
294
  if emotions == "Blank":
295
  gr.Warning("Please fill out the emotion section. 'Blank' is not a valid emotion.")
296
  else:
@@ -298,16 +299,17 @@ def next_example(emotions, confidence, comments, participant_id, ann_completed):
298
  ann_completed = save_annotation(emotions, confidence, comments, participant_id, ann_completed)
299
  if current_index["index"] < len(file_list) - 1:
300
  current_index["index"] += 1
301
- return ann_completed, *load_example(current_index["index"])
302
 
303
  def previous_example(emotion, confidence, comments, participant_id, ann_completed):
304
  """Move to the previous example."""
 
305
  if emotion.value != "Blank":
306
  ann_completed = save_annotation(emotion, confidence, comments, participant_id, ann_completed)
307
  if current_index["index"] > 0:
308
  current_index["index"] -= 1
309
- return ann_completed, *load_example(current_index["index"])
310
- return ann_completed, *load_example(current_index["index"])
311
 
312
  def deactivate_participant_id(participant_id, lets_go):
313
  participant_id = gr.Textbox(label='What is your participant ID?', value = participant_id, interactive = False)
@@ -402,14 +404,14 @@ with (gr.Blocks(theme=gr.themes.Soft(), css = css) as demo):
402
  previous_button.click(
403
  previous_example,
404
  inputs=[emotions, confidence, comments, participant_id, ann_completed],
405
- outputs=[ ann_completed, sentence_text, audio_player, emotions, confidence, ann_completed, comments],
406
  )
407
 
408
  # Go to the next example
409
  next_button.click(
410
  next_example,
411
  inputs=[emotions, confidence, comments, participant_id, ann_completed],
412
- outputs=[ann_completed, sentence_text, audio_player, emotions, confidence, ann_completed, comments],
413
  ).then(None, [], [ann_completed, total], js = js_progress_bar)
414
 
415
 
 
267
  "comments": ''}
268
  )
269
  print(previous_annotation)
270
+ return (sentence, audio_path, previous_annotation['emotion'], previous_annotation['confidence'], current_index['index'], previous_annotation["comments"])
271
 
272
 
273
  def save_annotation(emotions, confidence, comments, participant_id, ann_completed):
 
291
 
292
  def next_example(emotions, confidence, comments, participant_id, ann_completed):
293
  """Move to the next example."""
294
+ global current_index
295
  if emotions == "Blank":
296
  gr.Warning("Please fill out the emotion section. 'Blank' is not a valid emotion.")
297
  else:
 
299
  ann_completed = save_annotation(emotions, confidence, comments, participant_id, ann_completed)
300
  if current_index["index"] < len(file_list) - 1:
301
  current_index["index"] += 1
302
+ return load_example(current_index["index"])
303
 
304
  def previous_example(emotion, confidence, comments, participant_id, ann_completed):
305
  """Move to the previous example."""
306
+ global current_index
307
  if emotion.value != "Blank":
308
  ann_completed = save_annotation(emotion, confidence, comments, participant_id, ann_completed)
309
  if current_index["index"] > 0:
310
  current_index["index"] -= 1
311
+ return load_example(current_index["index"])
312
+ return load_example(current_index["index"])
313
 
314
  def deactivate_participant_id(participant_id, lets_go):
315
  participant_id = gr.Textbox(label='What is your participant ID?', value = participant_id, interactive = False)
 
404
  previous_button.click(
405
  previous_example,
406
  inputs=[emotions, confidence, comments, participant_id, ann_completed],
407
+ outputs=[sentence_text, audio_player, emotions, confidence, ann_completed, comments],
408
  )
409
 
410
  # Go to the next example
411
  next_button.click(
412
  next_example,
413
  inputs=[emotions, confidence, comments, participant_id, ann_completed],
414
+ outputs=[sentence_text, audio_player, emotions, confidence, ann_completed, comments],
415
  ).then(None, [], [ann_completed, total], js = js_progress_bar)
416
 
417