File size: 1,166 Bytes
146c2ba
 
 
 
41c5c54
33d33c9
146c2ba
 
 
 
 
 
 
 
 
 
be966f0
146c2ba
 
 
 
 
 
8f25acd
be966f0
 
 
 
 
 
 
 
48c631e
be966f0
 
 
 
 
4b2cce8
be966f0
5c9ce87
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
os.system("pip install git+https://github.com/openai/whisper.git")
import gradio as gr
import whisper
from difflib import SequenceMatcher
import re


model = whisper.load_model("medium.en")

        
def transcribe(file):
    options = dict(task="transcribe", best_of=5)
    text = model.transcribe(file, **options)["text"]
    return text.strip()

with gr.Blocks() as demo:

        audio = gr.Audio(
            show_label=False,
            source="microphone",
            type="filepath"
        )
        
        with gr.Row():
            transcribe_button = gr.Button("Transcribe")
            sim_button = gr.Button("Similarity")
        
        textbox1 = gr.Textbox(show_label=False)      
        transcribe_button.click(transcribe, inputs=[audio], outputs=[textbox1])
        textbox2 = gr.Textbox(label="Enter the text to compare")            
        label = gr.Label()

            
        def text_sim(par1, par2):        
            sim = SequenceMatcher(None, par1, par2).ratio() * 100
            return sim
            
        sim_button.click(text_sim, inputs=[textbox1, textbox2], outputs=label)

demo.launch()

#Nicy is awesome