optz the data loading
Browse files
README.md
CHANGED
@@ -11,4 +11,34 @@ license: mit
|
|
11 |
short_description: Generative Error Correction (GER) Task Baseline, WER
|
12 |
---
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
11 |
short_description: Generative Error Correction (GER) Task Baseline, WER
|
12 |
---
|
13 |
|
14 |
+
# Post-ASR Text Correction WER Leaderboard
|
15 |
+
|
16 |
+
This application displays a baseline Word Error Rate (WER) leaderboard for the test data in the [GenSEC-LLM/SLT-Task1-Post-ASR-Text-Correction](https://huggingface.co/datasets/GenSEC-LLM/SLT-Task1-Post-ASR-Text-Correction) dataset.
|
17 |
+
|
18 |
+
## Dataset Sources
|
19 |
+
|
20 |
+
The leaderboard shows WER metrics for multiple speech recognition sources as columns:
|
21 |
+
- CHiME4
|
22 |
+
- CORAAL
|
23 |
+
- CommonVoice
|
24 |
+
- LRS2
|
25 |
+
- LibriSpeech (Clean and Other)
|
26 |
+
- SwitchBoard
|
27 |
+
- Tedlium-3
|
28 |
+
- OVERALL (aggregate across all sources)
|
29 |
+
|
30 |
+
## Metrics
|
31 |
+
|
32 |
+
The leaderboard displays as rows:
|
33 |
+
- **Count**: Number of examples in the test set for each source
|
34 |
+
- **No LM Baseline**: Word Error Rate between the reference transcription and 1-best ASR output without language model correction
|
35 |
+
|
36 |
+
## Baseline Calculation
|
37 |
+
|
38 |
+
Word Error Rate is calculated between:
|
39 |
+
- Reference transcription ("transcription" field)
|
40 |
+
- 1-best ASR output ("input1" field or first item from "hypothesis" when input1 is unavailable)
|
41 |
+
|
42 |
+
Lower WER values indicate better transcription accuracy.
|
43 |
+
|
44 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -194,6 +194,10 @@ def get_wer_metrics(dataset):
|
|
194 |
for i, ex in enumerate(dataset):
|
195 |
try:
|
196 |
source = ex.get("source", "unknown")
|
|
|
|
|
|
|
|
|
197 |
if source not in examples_by_source:
|
198 |
examples_by_source[source] = []
|
199 |
examples_by_source[source].append(ex)
|
@@ -206,7 +210,7 @@ def get_wer_metrics(dataset):
|
|
206 |
print(f"Found sources: {all_sources}")
|
207 |
|
208 |
# Calculate metrics for each source
|
209 |
-
|
210 |
for source in all_sources:
|
211 |
try:
|
212 |
examples = examples_by_source.get(source, [])
|
@@ -218,43 +222,50 @@ def get_wer_metrics(dataset):
|
|
218 |
else:
|
219 |
wer = np.nan
|
220 |
|
221 |
-
|
222 |
-
"Source": source,
|
223 |
"Count": count,
|
224 |
-
"
|
225 |
-
}
|
226 |
except Exception as e:
|
227 |
print(f"Error processing source {source}: {str(e)}")
|
228 |
-
|
229 |
-
"Source": source,
|
230 |
"Count": 0,
|
231 |
-
"
|
232 |
-
}
|
233 |
|
234 |
-
# Calculate overall metrics with a sample
|
235 |
try:
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
238 |
# Sample for calculation
|
239 |
sample_size = min(500, total_count)
|
240 |
-
sample_dataset =
|
241 |
overall_wer = calculate_wer(sample_dataset)
|
242 |
|
243 |
-
|
244 |
-
"Source": "OVERALL",
|
245 |
"Count": total_count,
|
246 |
-
"
|
247 |
-
}
|
248 |
except Exception as e:
|
249 |
print(f"Error calculating overall metrics: {str(e)}")
|
250 |
print(traceback.format_exc())
|
251 |
-
|
252 |
-
"
|
253 |
-
"
|
254 |
-
|
255 |
-
|
|
|
|
|
|
|
256 |
|
257 |
-
|
|
|
|
|
|
|
|
|
258 |
|
259 |
except Exception as e:
|
260 |
print(f"Error in get_wer_metrics: {str(e)}")
|
@@ -267,12 +278,17 @@ def format_dataframe(df):
|
|
267 |
# Use vectorized operations instead of apply
|
268 |
df = df.copy()
|
269 |
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
|
|
|
|
|
|
|
|
|
|
276 |
|
277 |
return df
|
278 |
|
@@ -295,7 +311,7 @@ def create_leaderboard():
|
|
295 |
# Create the Gradio interface
|
296 |
with gr.Blocks(title="ASR Text Correction Test Leaderboard") as demo:
|
297 |
gr.Markdown("# ASR Text Correction Baseline WER Leaderboard (Test Data)")
|
298 |
-
gr.Markdown("Word Error Rate (WER) metrics for
|
299 |
|
300 |
with gr.Row():
|
301 |
refresh_btn = gr.Button("Refresh Leaderboard")
|
|
|
194 |
for i, ex in enumerate(dataset):
|
195 |
try:
|
196 |
source = ex.get("source", "unknown")
|
197 |
+
# Skip all_et05_real as requested
|
198 |
+
if source == "all_et05_real":
|
199 |
+
continue
|
200 |
+
|
201 |
if source not in examples_by_source:
|
202 |
examples_by_source[source] = []
|
203 |
examples_by_source[source].append(ex)
|
|
|
210 |
print(f"Found sources: {all_sources}")
|
211 |
|
212 |
# Calculate metrics for each source
|
213 |
+
source_results = {}
|
214 |
for source in all_sources:
|
215 |
try:
|
216 |
examples = examples_by_source.get(source, [])
|
|
|
222 |
else:
|
223 |
wer = np.nan
|
224 |
|
225 |
+
source_results[source] = {
|
|
|
226 |
"Count": count,
|
227 |
+
"No LM Baseline": wer
|
228 |
+
}
|
229 |
except Exception as e:
|
230 |
print(f"Error processing source {source}: {str(e)}")
|
231 |
+
source_results[source] = {
|
|
|
232 |
"Count": 0,
|
233 |
+
"No LM Baseline": np.nan
|
234 |
+
}
|
235 |
|
236 |
+
# Calculate overall metrics with a sample but excluding all_et05_real
|
237 |
try:
|
238 |
+
# Create a filtered dataset without all_et05_real
|
239 |
+
filtered_dataset = [ex for ex in dataset if ex.get("source") != "all_et05_real"]
|
240 |
+
total_count = len(filtered_dataset)
|
241 |
+
print(f"\nCalculating overall WER with a sample of examples (excluding all_et05_real)")
|
242 |
+
|
243 |
# Sample for calculation
|
244 |
sample_size = min(500, total_count)
|
245 |
+
sample_dataset = filtered_dataset[:sample_size]
|
246 |
overall_wer = calculate_wer(sample_dataset)
|
247 |
|
248 |
+
source_results["OVERALL"] = {
|
|
|
249 |
"Count": total_count,
|
250 |
+
"No LM Baseline": overall_wer
|
251 |
+
}
|
252 |
except Exception as e:
|
253 |
print(f"Error calculating overall metrics: {str(e)}")
|
254 |
print(traceback.format_exc())
|
255 |
+
source_results["OVERALL"] = {
|
256 |
+
"Count": len(filtered_dataset),
|
257 |
+
"No LM Baseline": np.nan
|
258 |
+
}
|
259 |
+
|
260 |
+
# Create a transposed DataFrame with metrics as rows and sources as columns
|
261 |
+
metrics = ["Count", "No LM Baseline"]
|
262 |
+
result_df = pd.DataFrame(index=metrics, columns=all_sources + ["OVERALL"])
|
263 |
|
264 |
+
for source in all_sources + ["OVERALL"]:
|
265 |
+
for metric in metrics:
|
266 |
+
result_df.loc[metric, source] = source_results[source][metric]
|
267 |
+
|
268 |
+
return result_df
|
269 |
|
270 |
except Exception as e:
|
271 |
print(f"Error in get_wer_metrics: {str(e)}")
|
|
|
278 |
# Use vectorized operations instead of apply
|
279 |
df = df.copy()
|
280 |
|
281 |
+
# Format WER values
|
282 |
+
if "No LM Baseline" in df.index:
|
283 |
+
# Convert to object type first to avoid warnings
|
284 |
+
df.loc["No LM Baseline"] = df.loc["No LM Baseline"].astype(object)
|
285 |
+
|
286 |
+
for col in df.columns:
|
287 |
+
value = df.loc["No LM Baseline", col]
|
288 |
+
if pd.notna(value):
|
289 |
+
df.loc["No LM Baseline", col] = f"{value:.4f}"
|
290 |
+
else:
|
291 |
+
df.loc["No LM Baseline", col] = "N/A"
|
292 |
|
293 |
return df
|
294 |
|
|
|
311 |
# Create the Gradio interface
|
312 |
with gr.Blocks(title="ASR Text Correction Test Leaderboard") as demo:
|
313 |
gr.Markdown("# ASR Text Correction Baseline WER Leaderboard (Test Data)")
|
314 |
+
gr.Markdown("Word Error Rate (WER) metrics for different speech sources with No Language Model baseline")
|
315 |
|
316 |
with gr.Row():
|
317 |
refresh_btn = gr.Button("Refresh Leaderboard")
|