Yilin98 ZinebSN commited on
Commit
9430119
1 Parent(s): 946d548

Update app.py (#2)

Browse files

- Update app.py (7d9c01d724a370a36baea1f3c376ad18a5eba39a)


Co-authored-by: Zineb Senane <ZinebSN@users.noreply.huggingface.co>

Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -3,13 +3,16 @@ 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=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
  input=file
 
 
 
13
  text = pipe(input)["text"]
14
  return text
15
 
@@ -17,7 +20,8 @@ iface = gr.Interface(
17
  fn=transcribe,
18
  inputs=[
19
  gr.Audio(source="microphone", type="filepath", interactive=True),
20
- gr.Audio(source="upload", type="filepath", interactive=True)],
 
21
  outputs="text",
22
  title="Whisper Small Swedish",
23
  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, youtube=None):
7
+ if (audio is None) and (file is None) and (youtube is None):
8
  return "No audio provided!"
9
  elif audio is not None:
10
  input=audio
11
  elif file is not None:
12
  input=file
13
+ elif youtube is not None:
14
+ yt=pt.YouTube("https://www.youtube.com/watch?v=4KI9BBW_aP8")
15
+ input=yt.streams.filter(only_audio=True)[0]
16
  text = pipe(input)["text"]
17
  return text
18
 
 
20
  fn=transcribe,
21
  inputs=[
22
  gr.Audio(source="microphone", type="filepath", interactive=True),
23
+ gr.Audio(source="upload", type="filepath", interactive=True),
24
+ gr.Text(label="URL (YouTube, etc.)")],
25
  outputs="text",
26
  title="Whisper Small Swedish",
27
  description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",