frankrobotics commited on
Commit
0d89ba6
·
verified ·
1 Parent(s): 34e758f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -3
app.py CHANGED
@@ -1,8 +1,25 @@
1
  import gradio as gr
 
2
 
3
- whisper = gr.load("models/openai/whisper-small")
 
 
 
 
4
 
5
  def transcribe(audio):
6
- return whisper(audio).replace("AutomaticSpeechRecognitionOutput(text=' ", "").replace("', chunks=None)", "")
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- gr.Interface(transcribe, gr.Audio(type="filepath"), gr.Textbox()).launch()
 
 
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()