Spaces:
Runtime error
Runtime error
Add torch
Browse files- app.py +14 -3
- requirements.txt +4 -0
app.py
CHANGED
@@ -1,14 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
def transcribe(audio):
|
7 |
-
result = pipe(audio)
|
8 |
print(result)
|
9 |
|
10 |
return result
|
11 |
|
12 |
app = gr.Interface(transcribe, gr.Audio(sources=["microphone"]), outputs="textbox")
|
13 |
|
14 |
-
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
+
import torch
|
4 |
|
5 |
+
MODEL_NAME = "openai/whisper-large-v3"
|
6 |
+
BATCH_SIZE = 8
|
7 |
+
|
8 |
+
device = 0 if torch.cuda.is_available() else "cpu"
|
9 |
+
|
10 |
+
pipe = pipeline(
|
11 |
+
task="automatic-speech-recognition",
|
12 |
+
model=MODEL_NAME,
|
13 |
+
chunk_length_s=30,
|
14 |
+
device=device,
|
15 |
+
)
|
16 |
|
17 |
def transcribe(audio):
|
18 |
+
result = pipe(audio, batch_size=BATCH_SIZE)["text"]
|
19 |
print(result)
|
20 |
|
21 |
return result
|
22 |
|
23 |
app = gr.Interface(transcribe, gr.Audio(sources=["microphone"]), outputs="textbox")
|
24 |
|
25 |
+
app.launch(enable_queue=True)
|
requirements.txt
CHANGED
@@ -43,7 +43,9 @@ MarkupSafe==2.1.5
|
|
43 |
matplotlib==3.8.3
|
44 |
mdurl==0.1.2
|
45 |
ml-dtypes==0.3.2
|
|
|
46 |
namex==0.0.7
|
|
|
47 |
numpy==1.26.4
|
48 |
opt-einsum==3.3.0
|
49 |
orjson==3.9.15
|
@@ -72,6 +74,7 @@ shellingham==1.5.4
|
|
72 |
six==1.16.0
|
73 |
sniffio==1.3.1
|
74 |
starlette==0.36.3
|
|
|
75 |
tensorboard==2.16.2
|
76 |
tensorboard-data-server==0.7.2
|
77 |
tensorflow==2.16.1
|
@@ -81,6 +84,7 @@ tf_keras==2.16.0
|
|
81 |
tokenizers==0.15.2
|
82 |
tomlkit==0.12.0
|
83 |
toolz==0.12.1
|
|
|
84 |
tqdm==4.66.2
|
85 |
transformers==4.38.2
|
86 |
typer==0.9.0
|
|
|
43 |
matplotlib==3.8.3
|
44 |
mdurl==0.1.2
|
45 |
ml-dtypes==0.3.2
|
46 |
+
mpmath==1.3.0
|
47 |
namex==0.0.7
|
48 |
+
networkx==3.2.1
|
49 |
numpy==1.26.4
|
50 |
opt-einsum==3.3.0
|
51 |
orjson==3.9.15
|
|
|
74 |
six==1.16.0
|
75 |
sniffio==1.3.1
|
76 |
starlette==0.36.3
|
77 |
+
sympy==1.12
|
78 |
tensorboard==2.16.2
|
79 |
tensorboard-data-server==0.7.2
|
80 |
tensorflow==2.16.1
|
|
|
84 |
tokenizers==0.15.2
|
85 |
tomlkit==0.12.0
|
86 |
toolz==0.12.1
|
87 |
+
torch==2.2.1
|
88 |
tqdm==4.66.2
|
89 |
transformers==4.38.2
|
90 |
typer==0.9.0
|