silvesterjk's picture
Update app.py (#1)
4a0acf5
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