Steveeeeeeen HF staff commited on
Commit
bd81ec2
·
verified ·
1 Parent(s): 4ad4e5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -28,10 +28,12 @@ def compute_wer_table(audio, text):
28
 
29
  trans = []
30
  wer_scores = []
 
 
31
  for model in model_name:
32
  pipe = pipeline("automatic-speech-recognition", model=model_name[model])
33
  transcription = pipe(audio_input)['text']
34
- transcription = transcription.replace(",", "").replace(".", "").replace("!", "").replace("?", "")
35
  trans.append(transcription)
36
  wer = wer_metric.compute(predictions=[transcription.upper()], references=[text.upper()])
37
  wer_scores.append(wer)
@@ -39,6 +41,7 @@ def compute_wer_table(audio, text):
39
  result = [[model, t, s] for model, t, s in zip(model_name.keys(), trans, wer_scores)]
40
 
41
  return result
 
42
  with gr.Blocks() as demo:
43
  with gr.Tab("Docs"):
44
  gr.Markdown((Path(__file__).parent / "demo.md").read_text())
 
28
 
29
  trans = []
30
  wer_scores = []
31
+ remove_chars = str.maketrans('', '', '.,!?')
32
+
33
  for model in model_name:
34
  pipe = pipeline("automatic-speech-recognition", model=model_name[model])
35
  transcription = pipe(audio_input)['text']
36
+ transcription = transcription.translate(remove_chars)
37
  trans.append(transcription)
38
  wer = wer_metric.compute(predictions=[transcription.upper()], references=[text.upper()])
39
  wer_scores.append(wer)
 
41
  result = [[model, t, s] for model, t, s in zip(model_name.keys(), trans, wer_scores)]
42
 
43
  return result
44
+
45
  with gr.Blocks() as demo:
46
  with gr.Tab("Docs"):
47
  gr.Markdown((Path(__file__).parent / "demo.md").read_text())