silvesterjk commited on
Commit
33d33c9
1 Parent(s): be966f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -3,6 +3,7 @@ os.system("pip install git+https://github.com/openai/whisper.git")
3
  import gradio as gr
4
  import whisper
5
  from difflib import SequenceMatcher
 
6
 
7
 
8
  model = whisper.load_model("medium.en")
@@ -29,11 +30,16 @@ with gr.Blocks() as demo:
29
  transcribe_button.click(transcribe, inputs=[audio], outputs=[textbox1])
30
  textbox2 = gr.Textbox(label="Enter the text to compare")
31
  label = gr.Label()
 
 
 
 
 
32
 
33
  def text_sim(par1, par2):
34
  sim = SequenceMatcher(None, par1, par2).ratio() * 100
35
  return sim
36
 
37
- sim_button.click(text_sim, inputs=[textbox1, textbox2], outputs=label)
38
 
39
  demo.launch()
 
3
  import gradio as gr
4
  import whisper
5
  from difflib import SequenceMatcher
6
+ import re
7
 
8
 
9
  model = whisper.load_model("medium.en")
 
30
  transcribe_button.click(transcribe, inputs=[audio], outputs=[textbox1])
31
  textbox2 = gr.Textbox(label="Enter the text to compare")
32
  label = gr.Label()
33
+
34
+ ab = re.sub(r"[^a-zA-Z0-9 ]", " ", textbox1).lower()
35
+ txt1 = ab.split()
36
+ ba = re.sub(r"[^a-zA-Z0-9 ]", " ", textbox2).lower()
37
+ txt2 = ba.split()
38
 
39
  def text_sim(par1, par2):
40
  sim = SequenceMatcher(None, par1, par2).ratio() * 100
41
  return sim
42
 
43
+ sim_button.click(text_sim, inputs=[txt1, txt2], outputs=label)
44
 
45
  demo.launch()