Chrysoula commited on
Commit
ee53ffb
·
1 Parent(s): 6db55eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -4,7 +4,7 @@ import pytube as pt
4
 
5
  pipe = pipeline(model="Hoft/whisper-small-swedish-asr") # change to "your-username/the-name-you-picked"
6
 
7
- def microphone_transcribe(audio):
8
  text = pipe(audio)["text"]
9
  return text
10
 
@@ -22,7 +22,7 @@ def youtube_transcribe(url):
22
  app = gr.Blocks()
23
 
24
  microphone_tab = gr.Interface(
25
- fn=microphone_transcribe,
26
  inputs=gr.Audio(source="microphone", type="filepath"),
27
  outputs="text",
28
  title="Whisper Small Swedish",
@@ -37,7 +37,15 @@ youtube_tab = gr.Interface(
37
  description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
38
  )
39
 
 
 
 
 
 
 
 
 
40
  with app:
41
- gr.TabbedInterface([microphone_tab, youtube_tab], ["Microphone", "YouTube"])
42
 
43
  app.launch(enable_queue=True)
 
4
 
5
  pipe = pipeline(model="Hoft/whisper-small-swedish-asr") # change to "your-username/the-name-you-picked"
6
 
7
+ def microphone_or_file_transcribe(audio):
8
  text = pipe(audio)["text"]
9
  return text
10
 
 
22
  app = gr.Blocks()
23
 
24
  microphone_tab = gr.Interface(
25
+ fn=microphone_or_file_transcribe,
26
  inputs=gr.Audio(source="microphone", type="filepath"),
27
  outputs="text",
28
  title="Whisper Small Swedish",
 
37
  description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
38
  )
39
 
40
+ file_tab = gr.Interface(
41
+ fn=microphone_or_file_transcribe,
42
+ inputs= gr.inputs.Audio(source="upload", type="filepath"),
43
+ outputs="text",
44
+ title="Whisper Small Swedish",
45
+ description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
46
+ )
47
+
48
  with app:
49
+ gr.TabbedInterface([microphone_tab, youtube_tab, file_tab], ["Microphone", "YouTube", "File"])
50
 
51
  app.launch(enable_queue=True)