File size: 692 Bytes
990b4f2
0d89ba6
990b4f2
0d89ba6
 
 
 
 
f9c8e63
 
0d89ba6
 
 
 
 
 
 
 
 
 
 
 
f9c8e63
0d89ba6
 
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
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()