Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,25 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def transcribe(audio):
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import re
|
3 |
|
4 |
+
# Define the regex pattern to extract text
|
5 |
+
pattern = r'text=["\'](.*?)["\'],\s*chunks=None'
|
6 |
+
|
7 |
+
# Load the Whisper model
|
8 |
+
whisper = gr.load("models/openai/whisper-large-v3-turbo")
|
9 |
|
10 |
def transcribe(audio):
|
11 |
+
# Transcribe the audio using Whisper
|
12 |
+
result = whisper(audio)
|
13 |
+
|
14 |
+
# Use re.search to find the match
|
15 |
+
match = re.search(pattern, result)
|
16 |
+
|
17 |
+
if match:
|
18 |
+
# Access the captured group (the content inside the quotes)
|
19 |
+
captured_text = match.group(1)
|
20 |
+
return captured_text
|
21 |
+
else:
|
22 |
+
return result
|
23 |
|
24 |
+
# Define the Gradio interface
|
25 |
+
gr.Interface(fn=transcribe, inputs=gr.Audio(type="filepath"), outputs=gr.Textbox()).launch()
|