jsbeaudry commited on
Commit
53e911a
·
verified ·
1 Parent(s): 6287412

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -47
app.py CHANGED
@@ -1,64 +1,64 @@
1
- # from transformers import pipeline
2
- # import gradio as gr
3
 
4
- # pipe = pipeline(model="jsbeaudry/jsbeaudry/kreyol-tts")
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()
 
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()