Manickz commited on
Commit
04e3103
·
verified ·
1 Parent(s): af78355

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -26
app.py CHANGED
@@ -1,27 +1,26 @@
1
  import gradio as gr
2
-
3
- gr.load("models/openai/whisper-large-v3").launch()
4
-
5
- import gradio as gr
6
- import spaces
7
- import torch
8
-
9
- zero = torch.Tensor([0]).cuda()
10
- print(zero.device) # <-- 'cpu' 🤔
11
-
12
- @spaces.GPU
13
- gr.load("models/openai/whisper-large-v3").launch()
14
-
15
- import gradio as gr
16
- import spaces
17
- import torch
18
-
19
- zero = torch.Tensor([0]).cuda()
20
- print(zero.device) # <-- 'cpu' 🤔
21
-
22
- @spaces.GPU
23
- def greet():
24
- gr.load("models/openai/whisper-large-v3")
25
-
26
- demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
27
- demo.launch()
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the whisper-large-v3 model from Hugging Face on CPU
5
+ transcriber = pipeline(
6
+ "automatic-speech-recognition",
7
+ model="openai/whisper-large-v3",
8
+ device=-1 # Ensures the model runs on the CPU
9
+ )
10
+
11
+ def transcribe_audio(audio_file):
12
+ # Transcribe the audio file
13
+ transcription = transcriber(audio_file)["text"]
14
+ return transcription
15
+
16
+ # Gradio interface setup
17
+ iface = gr.Interface(
18
+ fn=transcribe_audio,
19
+ inputs=gr.Audio(source="upload", type="filepath"),
20
+ outputs="text",
21
+ title="Whisper Large v3 ASR",
22
+ description="Transcribe audio files using OpenAI's Whisper Large v3 model.",
23
+ )
24
+
25
+ # Launch the app
26
+ iface.launch()