Has-ai commited on
Commit
01aff57
·
1 Parent(s): b6108bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,4 +1,25 @@
1
  import gradio as gr
 
2
 
 
3
 
4
- gr.Interface.load("models/openai/whisper-large-v2").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ model = pipeline("automatic-speech-recognition")
5
 
6
+
7
+ def transcribe_audio(mic=None, file=None):
8
+ if mic is not None:
9
+ audio = mic
10
+ elif file is not None:
11
+ audio = file
12
+ else:
13
+ return "You must either provide a mic recording or a file"
14
+ transcription = model(audio)["text"]
15
+ return transcription
16
+
17
+
18
+ gr.Interface(
19
+ fn=transcribe_audio,
20
+ inputs=[
21
+ gr.Audio(source="microphone", type="filepath", optional=True),
22
+ gr.Audio(source="upload", type="filepath", optional=True),
23
+ ],
24
+ outputs="text",
25
+ ).launch()