Spaces:
Running
on
Zero
Running
on
Zero
rafaaa2105
commited on
Commit
•
a24b265
1
Parent(s):
27f06c5
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import os
|
|
6 |
import tempfile
|
7 |
import torch
|
8 |
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
|
|
9 |
|
10 |
def extract_audio(video_path):
|
11 |
video = mp.VideoFileClip(video_path)
|
@@ -14,6 +15,7 @@ def extract_audio(video_path):
|
|
14 |
audio.write_audiofile(audio_path)
|
15 |
return audio_path
|
16 |
|
|
|
17 |
def generate_subtitles(audio_path):
|
18 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
19 |
processor = WhisperProcessor.from_pretrained("openai/whisper-large-v3")
|
|
|
6 |
import tempfile
|
7 |
import torch
|
8 |
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
9 |
+
import spaces
|
10 |
|
11 |
def extract_audio(video_path):
|
12 |
video = mp.VideoFileClip(video_path)
|
|
|
15 |
audio.write_audiofile(audio_path)
|
16 |
return audio_path
|
17 |
|
18 |
+
@spaces.GPU
|
19 |
def generate_subtitles(audio_path):
|
20 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
21 |
processor = WhisperProcessor.from_pretrained("openai/whisper-large-v3")
|