Spaces:
Runtime error
Runtime error
| 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() |