Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,16 +23,30 @@
|
|
23 |
from transformers import pipeline
|
24 |
import gradio as gr
|
25 |
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
pipe = pipeline(
|
29 |
"automatic-speech-recognition",
|
30 |
-
model=
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
# torch_dtype=torch.float16 # Remove the device parameter
|
36 |
)
|
37 |
def transcribe(audio):
|
38 |
# Use the 'whisper' pipeline defined in the previous cell
|
|
|
23 |
from transformers import pipeline
|
24 |
import gradio as gr
|
25 |
|
26 |
+
import torch
|
27 |
+
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
|
28 |
+
from datasets import load_dataset
|
29 |
+
|
30 |
+
|
31 |
+
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
32 |
+
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
33 |
+
|
34 |
+
model_id = "jsbeaudry/creole-speech-to-text""
|
35 |
+
|
36 |
+
model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
37 |
+
model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
|
38 |
+
)
|
39 |
+
model.to(device)
|
40 |
+
|
41 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
42 |
+
|
43 |
pipe = pipeline(
|
44 |
"automatic-speech-recognition",
|
45 |
+
model=model,
|
46 |
+
tokenizer=processor.tokenizer,
|
47 |
+
feature_extractor=processor.feature_extractor,
|
48 |
+
torch_dtype=torch_dtype,
|
49 |
+
device=device,
|
|
|
50 |
)
|
51 |
def transcribe(audio):
|
52 |
# Use the 'whisper' pipeline defined in the previous cell
|