Yilin98 commited on
Commit
04ab4a3
1 Parent(s): d6b17e5

Add upload audio file option.

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -3,13 +3,21 @@ import gradio as gr
3
 
4
  pipe = pipeline(model="Yilin98/whisper-small-hi") # change to "your-username/the-name-you-picked"
5
 
6
- def transcribe(audio):
7
- text = pipe(audio)["text"]
 
 
 
 
 
 
8
  return text
9
 
10
  iface = gr.Interface(
11
  fn=transcribe,
12
- inputs=gr.Audio(source="microphone", type="filepath"),
 
 
13
  outputs="text",
14
  title="Whisper Small Swedish",
15
  description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
 
3
 
4
  pipe = pipeline(model="Yilin98/whisper-small-hi") # change to "your-username/the-name-you-picked"
5
 
6
+ def transcribe(audio=None, file=None):
7
+ if (audio is None) and (file is None):
8
+ return "No audio provided!"
9
+ elif audio is not None:
10
+ input=audio
11
+ elif file is not None:
12
+ imput=file
13
+ text = pipe(input)["text"]
14
  return text
15
 
16
  iface = gr.Interface(
17
  fn=transcribe,
18
+ inputs=[
19
+ gr.Audio(source="microphone", type="filepath"),
20
+ gr.Audio(source="upload", type="filepath")],
21
  outputs="text",
22
  title="Whisper Small Swedish",
23
  description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",