alan commited on
Commit
6cd713c
1 Parent(s): 4dcbad1

update gradio

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +10 -7
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🔥
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: gradio
7
- sdk_version: 3.38.0
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 4.39.0
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
app.py CHANGED
@@ -4,6 +4,7 @@ import tempfile
4
  from math import floor
5
  from typing import Optional, List, Dict, Any
6
 
 
7
  import torch
8
  import gradio as gr
9
  import yt_dlp as youtube_dl
@@ -26,6 +27,7 @@ else:
26
  torch_dtype = torch.float32
27
  device = "cpu"
28
  model_kwargs = {}
 
29
  # define the pipeline
30
  pipe = pipeline(
31
  model=MODEL_NAME,
@@ -35,7 +37,7 @@ pipe = pipeline(
35
  device=device,
36
  model_kwargs=model_kwargs,
37
  trust_remote_code=True
38
- )
39
 
40
 
41
  def format_time(start: Optional[float], end: Optional[float]):
@@ -53,6 +55,7 @@ def format_time(start: Optional[float], end: Optional[float]):
53
  return f"[{_format_time(start)}-> {_format_time(end)}]:"
54
 
55
 
 
56
  def get_prediction(inputs, prompt: Optional[str]):
57
  generate_kwargs = {"language": "japanese", "task": "transcribe"}
58
  if prompt:
@@ -123,8 +126,8 @@ demo = gr.Blocks()
123
  mf_transcribe = gr.Interface(
124
  fn=transcribe,
125
  inputs=[
126
- gr.inputs.Audio(source="microphone", type="filepath", optional=True),
127
- gr.inputs.Textbox(lines=1, placeholder="Prompt", optional=True),
128
  ],
129
  outputs=["text", "text"],
130
  layout="horizontal",
@@ -137,8 +140,8 @@ mf_transcribe = gr.Interface(
137
  file_transcribe = gr.Interface(
138
  fn=transcribe,
139
  inputs=[
140
- gr.inputs.Audio(source="upload", type="filepath", optional=True, label="Audio file"),
141
- gr.inputs.Textbox(lines=1, placeholder="Prompt", optional=True),
142
  ],
143
  outputs=["text", "text"],
144
  layout="horizontal",
@@ -150,8 +153,8 @@ file_transcribe = gr.Interface(
150
  yt_transcribe = gr.Interface(
151
  fn=yt_transcribe,
152
  inputs=[
153
- gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL"),
154
- gr.inputs.Textbox(lines=1, placeholder="Prompt", optional=True),
155
  ],
156
  outputs=["html", "text", "text"],
157
  layout="horizontal",
 
4
  from math import floor
5
  from typing import Optional, List, Dict, Any
6
 
7
+ import spaces
8
  import torch
9
  import gradio as gr
10
  import yt_dlp as youtube_dl
 
27
  torch_dtype = torch.float32
28
  device = "cpu"
29
  model_kwargs = {}
30
+ print(device)
31
  # define the pipeline
32
  pipe = pipeline(
33
  model=MODEL_NAME,
 
37
  device=device,
38
  model_kwargs=model_kwargs,
39
  trust_remote_code=True
40
+ ).to(device)
41
 
42
 
43
  def format_time(start: Optional[float], end: Optional[float]):
 
55
  return f"[{_format_time(start)}-> {_format_time(end)}]:"
56
 
57
 
58
+ @spaces.GPU
59
  def get_prediction(inputs, prompt: Optional[str]):
60
  generate_kwargs = {"language": "japanese", "task": "transcribe"}
61
  if prompt:
 
126
  mf_transcribe = gr.Interface(
127
  fn=transcribe,
128
  inputs=[
129
+ gr.Audio(sources="microphone", type="filepath", optional=True),
130
+ gr.Textbox(lines=1, placeholder="Prompt", optional=True),
131
  ],
132
  outputs=["text", "text"],
133
  layout="horizontal",
 
140
  file_transcribe = gr.Interface(
141
  fn=transcribe,
142
  inputs=[
143
+ gr.Audio(sources="upload", type="filepath", optional=True, label="Audio file"),
144
+ gr.Textbox(lines=1, placeholder="Prompt", optional=True),
145
  ],
146
  outputs=["text", "text"],
147
  layout="horizontal",
 
153
  yt_transcribe = gr.Interface(
154
  fn=yt_transcribe,
155
  inputs=[
156
+ gr.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL"),
157
+ gr.Textbox(lines=1, placeholder="Prompt", optional=True),
158
  ],
159
  outputs=["html", "text", "text"],
160
  layout="horizontal",