whisper-2 / app.py
frankrobotics's picture
Update app.py
0d89ba6 verified
raw
history blame contribute delete
692 Bytes
import gradio as gr
import re
# Define the regex pattern to extract text
pattern = r'text=["\'](.*?)["\'],\s*chunks=None'
# Load the Whisper model
whisper = gr.load("models/openai/whisper-large-v3-turbo")
def transcribe(audio):
# Transcribe the audio using Whisper
result = whisper(audio)
# Use re.search to find the match
match = re.search(pattern, result)
if match:
# Access the captured group (the content inside the quotes)
captured_text = match.group(1)
return captured_text
else:
return result
# Define the Gradio interface
gr.Interface(fn=transcribe, inputs=gr.Audio(type="filepath"), outputs=gr.Textbox()).launch()