MaximilianChen commited on
Commit
36bd290
·
1 Parent(s): c65aacc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
app.py CHANGED
@@ -1,23 +1,25 @@
1
- pip install transformers
2
-
3
  from transformers import pipeline
4
  import gradio as gr
5
 
6
- pipe = pipeline(model="MaximilianChen/Casper")
 
7
 
8
- def transcribe(audio):
9
- text = pipe(audio)["text"]
10
- return text
 
 
 
 
 
 
11
 
12
- iface = gr.Interface(
13
- fn=transcribe,
 
14
  inputs=[
15
- gr.Audio(label="Upload Speech", source="upload", type="numpy"),
16
- gr.Audio(label="Record Speech", source="microphone", type="numpy"),
17
- ],
18
  outputs="text",
19
- title="Casper",
20
- description="Realtime demo for Catalan speech recognition using a fine-tuned Whisper small model.",
21
- )
22
-
23
- iface.launch()
 
 
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ model = pipeline(model='MaximilianChen/Casper')
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()