Spaces:
Runtime error
Runtime error
denis-kazakov
commited on
Commit
•
01a1731
1
Parent(s):
17c0730
Upload 2 files
Browse files- app.py +5 -10
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,12 +1,9 @@
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
-
import torch
|
4 |
|
5 |
-
device = 'cuda' if torch.cuda.is_available else 'cpu'
|
6 |
|
7 |
model = pipeline(
|
8 |
"automatic-speech-recognition",
|
9 |
-
device=device,
|
10 |
model='openai/whisper-large-v3',
|
11 |
chunk_length_s=30,
|
12 |
generate_kwargs={"task": "transcribe"}
|
@@ -20,13 +17,11 @@ def transcribe_audio(mic=None, file=None, return_timestamps=False):
|
|
20 |
else:
|
21 |
return "You must either provide a mic recording or a file"
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
result
|
26 |
-
|
27 |
-
|
28 |
-
else:
|
29 |
-
return result['text']
|
30 |
|
31 |
|
32 |
gr.Interface(
|
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
|
|
3 |
|
|
|
4 |
|
5 |
model = pipeline(
|
6 |
"automatic-speech-recognition",
|
|
|
7 |
model='openai/whisper-large-v3',
|
8 |
chunk_length_s=30,
|
9 |
generate_kwargs={"task": "transcribe"}
|
|
|
17 |
else:
|
18 |
return "You must either provide a mic recording or a file"
|
19 |
|
20 |
+
result = model(audio, return_timestamps=return_timestamps, batch_size=8)
|
21 |
+
if return_timestamps:
|
22 |
+
return result['chunks']
|
23 |
+
else:
|
24 |
+
return result['text']
|
|
|
|
|
25 |
|
26 |
|
27 |
gr.Interface(
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
transformers
|
2 |
-
|
|
|
1 |
transformers
|
2 |
+
|