akki2825 commited on
Commit
820ab2f
·
verified ·
1 Parent(s): d1bf32a

add mismatched sentences

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -2,6 +2,21 @@ import spaces
2
  import gradio as gr
3
  import numpy as np
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  @spaces.GPU()
6
  def calculate_wer(reference, hypothesis):
7
  reference_words = reference.split()
@@ -73,7 +88,8 @@ def process_files(reference_file, hypothesis_file):
73
 
74
  return {
75
  "WER": wer_value,
76
- "CER": cer_value
 
77
  }
78
  except Exception as e:
79
  return {"error": str(e)}
 
2
  import gradio as gr
3
  import numpy as np
4
 
5
+ @spaces.GPU()
6
+ def get_mismatched_sentences(reference, hypothesis):
7
+ """
8
+ Get mismatched sentences between reference and hypothesis.
9
+ """
10
+ reference_sentences = reference.split()
11
+ hypothesis_sentences = hypothesis.split()
12
+
13
+ mismatched = []
14
+ for ref, hyp in zip(reference_sentences, hypothesis_sentences):
15
+ if ref != hyp:
16
+ mismatched.append((ref, hyp))
17
+
18
+ return mismatched
19
+
20
  @spaces.GPU()
21
  def calculate_wer(reference, hypothesis):
22
  reference_words = reference.split()
 
88
 
89
  return {
90
  "WER": wer_value,
91
+ "CER": cer_value,
92
+ "Mismatched Sentences": mismatched_sentences
93
  }
94
  except Exception as e:
95
  return {"error": str(e)}