Spaces:
Sleeping
Sleeping
sotirios-slv
commited on
Commit
•
f0698ec
1
Parent(s):
dc44789
Updated to use larger model
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import logging
|
|
2 |
|
3 |
import gradio as gr
|
4 |
|
5 |
-
|
6 |
from transformers import (
|
7 |
AutoModelForSpeechSeq2Seq,
|
8 |
AutoProcessor,
|
@@ -13,7 +13,7 @@ from transformers import (
|
|
13 |
|
14 |
device = "cpu"
|
15 |
# device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
16 |
-
|
17 |
|
18 |
model_id = "openai/whisper-large-v3"
|
19 |
|
@@ -26,20 +26,20 @@ model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
|
26 |
)
|
27 |
model.to(device)
|
28 |
|
29 |
-
processor = WhisperProcessor.from_pretrained("openai/whisper-base.en")
|
30 |
|
31 |
-
|
32 |
|
33 |
pipe = pipeline(
|
34 |
task="automatic-speech-recognition",
|
35 |
model=model,
|
36 |
tokenizer=processor.tokenizer,
|
37 |
feature_extractor=processor.feature_extractor,
|
38 |
-
|
39 |
chunk_length_s=30,
|
40 |
batch_size=8,
|
41 |
-
|
42 |
-
|
43 |
device=device,
|
44 |
)
|
45 |
|
|
|
2 |
|
3 |
import gradio as gr
|
4 |
|
5 |
+
import torch
|
6 |
from transformers import (
|
7 |
AutoModelForSpeechSeq2Seq,
|
8 |
AutoProcessor,
|
|
|
13 |
|
14 |
device = "cpu"
|
15 |
# device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
16 |
+
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
17 |
|
18 |
model_id = "openai/whisper-large-v3"
|
19 |
|
|
|
26 |
)
|
27 |
model.to(device)
|
28 |
|
29 |
+
# processor = WhisperProcessor.from_pretrained("openai/whisper-base.en")
|
30 |
|
31 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
32 |
|
33 |
pipe = pipeline(
|
34 |
task="automatic-speech-recognition",
|
35 |
model=model,
|
36 |
tokenizer=processor.tokenizer,
|
37 |
feature_extractor=processor.feature_extractor,
|
38 |
+
max_new_tokens=128,
|
39 |
chunk_length_s=30,
|
40 |
batch_size=8,
|
41 |
+
return_timestamps=True,
|
42 |
+
torch_dtype=torch_dtype,
|
43 |
device=device,
|
44 |
)
|
45 |
|