patrickvonplaten commited on
Commit
f73dbf6
·
1 Parent(s): 1e4af7c
Files changed (1) hide show
  1. app.py +54 -12
app.py CHANGED
@@ -14,10 +14,24 @@ from huggingface_hub import Repository
14
  REFERENCE_NAME = "references"
15
  SUBMISSION_NAME = "submissions"
16
 
17
- REFERENCE_URL = os.path.join("https://huggingface.co/datasets/esc-bench", REFERENCE_NAME)
18
- SUBMISSION_URL = os.path.join("https://huggingface.co/datasets/esc-bench", SUBMISSION_NAME)
 
 
 
 
19
 
20
- TEST_SETS = ["librispeech-clean", "librispeech-other", "common-voice-9", "vox-populi", "ted-lium", "giga-speech", "spgi-speech", "earnings-22", "ami"]
 
 
 
 
 
 
 
 
 
 
21
  EXPECTED_TEST_FILES = [f + ".txt" for f in TEST_SETS]
22
  OPTIONAL_TEST_SETS = ["switch-board", "call-home", "chime-4"]
23
 
@@ -28,7 +42,9 @@ HF_TOKEN = os.environ.get("HF_TOKEN")
28
 
29
 
30
  def compute_wer(pred_file, ref_file):
31
- with open(pred_file, "r", encoding="utf-8") as pred, open(ref_file, "r", encoding="utf-8") as ref:
 
 
32
  pred_lines = [line.strip() for line in pred.readlines()]
33
  ref_lines = [line.strip() for line in ref.readlines()]
34
 
@@ -36,11 +52,19 @@ def compute_wer(pred_file, ref_file):
36
  return wer
37
 
38
 
39
- reference_repo = Repository(local_dir="references", clone_from=REFERENCE_URL, use_auth_token=HF_TOKEN)
40
- submission_repo = Repository(local_dir="submissions", clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN)
 
 
 
 
41
  submission_repo.git_pull()
42
 
43
- all_submissions = [folder for folder in os.listdir(SUBMISSION_NAME) if os.path.isdir(os.path.join(SUBMISSION_NAME, folder)) and folder != ".git"]
 
 
 
 
44
 
45
  all_results = read_csv(CSV_RESULTS_FILE)
46
  evaluated_submissions = all_results["name"].values.tolist()
@@ -55,7 +79,9 @@ if len(non_evaluated_submissions) > 0:
55
  submitted_files = [f for f in submitted_files if f in EXPECTED_TEST_FILES]
56
 
57
  if sorted(EXPECTED_TEST_FILES) != sorted(submitted_files):
58
- raise ValueError(f"{', '.join(submitted_files)} were submitted, but expected {', '.join(EXPECTED_TEST_FILES)}")
 
 
59
 
60
  for file in submitted_files:
61
  ref_file = os.path.join(REFERENCE_NAME, file)
@@ -76,7 +102,19 @@ if len(non_evaluated_submissions) > 0:
76
  commit_url = reference_repo.push_to_hub()
77
  print(commit_url)
78
 
79
- COLUMN_NAMES = {"librispeech-clean": "ls-clean", "librispeech-other": "ls-other", "common-voice-9": "cv9", "vox-populi": "vox", "ted-lium": "ted", "giga-speech": "giga", "spgi-speech": "spgi", "earnings-22": "e22", "ami": "ami", "chime-4": "chime", "switch-board": "swbd"}
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  table = all_results.round(4)
82
  table = table.rename(columns=COLUMN_NAMES)
@@ -110,7 +148,11 @@ st.markdown("To submit to ESC, please click on the instructions below ↓")
110
 
111
  st.markdown("TODO: Add instructions ...")
112
 
113
- uploaded_file = st.file_uploader("Choose a file")
 
 
 
 
114
 
115
- if st.button('Submit'):
116
- st.write('Computing scores ...')
 
14
  REFERENCE_NAME = "references"
15
  SUBMISSION_NAME = "submissions"
16
 
17
+ REFERENCE_URL = os.path.join(
18
+ "https://huggingface.co/datasets/esc-bench", REFERENCE_NAME
19
+ )
20
+ SUBMISSION_URL = os.path.join(
21
+ "https://huggingface.co/datasets/esc-bench", SUBMISSION_NAME
22
+ )
23
 
24
+ TEST_SETS = [
25
+ "librispeech-clean",
26
+ "librispeech-other",
27
+ "common-voice-9",
28
+ "vox-populi",
29
+ "ted-lium",
30
+ "giga-speech",
31
+ "spgi-speech",
32
+ "earnings-22",
33
+ "ami",
34
+ ]
35
  EXPECTED_TEST_FILES = [f + ".txt" for f in TEST_SETS]
36
  OPTIONAL_TEST_SETS = ["switch-board", "call-home", "chime-4"]
37
 
 
42
 
43
 
44
  def compute_wer(pred_file, ref_file):
45
+ with open(pred_file, "r", encoding="utf-8") as pred, open(
46
+ ref_file, "r", encoding="utf-8"
47
+ ) as ref:
48
  pred_lines = [line.strip() for line in pred.readlines()]
49
  ref_lines = [line.strip() for line in ref.readlines()]
50
 
 
52
  return wer
53
 
54
 
55
+ reference_repo = Repository(
56
+ local_dir="references", clone_from=REFERENCE_URL, use_auth_token=HF_TOKEN
57
+ )
58
+ submission_repo = Repository(
59
+ local_dir="submissions", clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN
60
+ )
61
  submission_repo.git_pull()
62
 
63
+ all_submissions = [
64
+ folder
65
+ for folder in os.listdir(SUBMISSION_NAME)
66
+ if os.path.isdir(os.path.join(SUBMISSION_NAME, folder)) and folder != ".git"
67
+ ]
68
 
69
  all_results = read_csv(CSV_RESULTS_FILE)
70
  evaluated_submissions = all_results["name"].values.tolist()
 
79
  submitted_files = [f for f in submitted_files if f in EXPECTED_TEST_FILES]
80
 
81
  if sorted(EXPECTED_TEST_FILES) != sorted(submitted_files):
82
+ raise ValueError(
83
+ f"{', '.join(submitted_files)} were submitted, but expected {', '.join(EXPECTED_TEST_FILES)}"
84
+ )
85
 
86
  for file in submitted_files:
87
  ref_file = os.path.join(REFERENCE_NAME, file)
 
102
  commit_url = reference_repo.push_to_hub()
103
  print(commit_url)
104
 
105
+ COLUMN_NAMES = {
106
+ "librispeech-clean": "ls-clean",
107
+ "librispeech-other": "ls-other",
108
+ "common-voice-9": "cv9",
109
+ "vox-populi": "vox",
110
+ "ted-lium": "ted",
111
+ "giga-speech": "giga",
112
+ "spgi-speech": "spgi",
113
+ "earnings-22": "e22",
114
+ "ami": "ami",
115
+ "chime-4": "chime",
116
+ "switch-board": "swbd",
117
+ }
118
 
119
  table = all_results.round(4)
120
  table = table.rename(columns=COLUMN_NAMES)
 
148
 
149
  st.markdown("TODO: Add instructions ...")
150
 
151
+ # Using the "with" syntax
152
+ with st.form(key="my_form"):
153
+ text_input = st.text_input(label="Name")
154
+ uploaded_file = st.file_uploader("Choose a zip file")
155
+ submit_button = st.form_submit_button(label="Submit")
156
 
157
+ if submit_button:
158
+ st.write("Computing scores ...")