Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,64 +1,64 @@
|
|
1 |
-
|
2 |
-
|
3 |
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
|
20 |
|
21 |
|
22 |
|
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 |
-
|
38 |
-
)
|
39 |
-
model.to(device)
|
40 |
|
41 |
-
processor = AutoProcessor.from_pretrained(model_id)
|
42 |
|
43 |
-
pipe = pipeline(
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
)
|
51 |
-
def transcribe(audio):
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
iface = gr.Interface(
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
)
|
63 |
|
64 |
-
iface.launch()
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
|
4 |
+
pipe = pipeline(model="jsbeaudry/creole-speech-to-text")
|
5 |
|
6 |
+
def transcribe(audio):
|
7 |
+
text = pipe(audio)["text"]
|
8 |
+
return text
|
9 |
|
10 |
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=transcribe,
|
13 |
+
inputs=gr.Audio(type="filepath"),
|
14 |
+
outputs="text",
|
15 |
+
title="Whisper medium Creole",
|
16 |
+
description="Realtime demo for Haitian Creole speech recognition using a fine-tuned medium small model.",
|
17 |
+
)
|
18 |
|
19 |
+
iface.launch()
|
20 |
|
21 |
|
22 |
|
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
|
53 |
+
# text = pipe(audio)["text"]
|
54 |
+
# return text
|
55 |
|
56 |
+
# iface = gr.Interface(
|
57 |
+
# fn=transcribe,
|
58 |
+
# inputs=gr.Audio(type="filepath"),
|
59 |
+
# outputs="text",
|
60 |
+
# title="Whisper medium Creole",
|
61 |
+
# description="Realtime demo for Haitian Creole speech recognition using a fine-tuned medium small model.",
|
62 |
+
# )
|
63 |
|
64 |
+
# iface.launch()
|