Spaces:
Runtime error
Runtime error
Commit
•
a36192a
1
Parent(s):
bcdc251
test
Browse files
app.py
CHANGED
@@ -27,13 +27,21 @@ device = None # Declare device at the global level
|
|
27 |
@spaces.GPU
|
28 |
def download_model():
|
29 |
global model, processor, device
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
model_id
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
# Function to set up the pipeline
|
39 |
def create_pipeline():
|
@@ -133,4 +141,6 @@ with gr.Blocks() as demo:
|
|
133 |
youtube_url_input = gr.Textbox(label="Enter YouTube URL")
|
134 |
youtube_download_output = gr.File(label="Download MP3", file_count="single")
|
135 |
youtube_url_input.change(youtube_video_to_mp3, inputs=youtube_url_input, outputs=youtube_download_output)
|
136 |
-
|
|
|
|
|
|
27 |
@spaces.GPU
|
28 |
def download_model():
|
29 |
global model, processor, device
|
30 |
+
try:
|
31 |
+
logging.info("Starting model download...")
|
32 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
33 |
+
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
34 |
+
model_id = "openai/whisper-large-v3"
|
35 |
+
|
36 |
+
model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
37 |
+
model_id, torch_dtype=torch_dtype
|
38 |
+
).to(device)
|
39 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
40 |
+
|
41 |
+
logging.info("Model and processor downloaded successfully.")
|
42 |
+
except Exception as e:
|
43 |
+
logging.error(f"An error occurred while downloading the model and processor: {e}")
|
44 |
+
|
45 |
|
46 |
# Function to set up the pipeline
|
47 |
def create_pipeline():
|
|
|
141 |
youtube_url_input = gr.Textbox(label="Enter YouTube URL")
|
142 |
youtube_download_output = gr.File(label="Download MP3", file_count="single")
|
143 |
youtube_url_input.change(youtube_video_to_mp3, inputs=youtube_url_input, outputs=youtube_download_output)
|
144 |
+
|
145 |
+
demo.launch()
|
146 |
+
|