Spaces:
Sleeping
Sleeping
Madhuslista
commited on
Commit
•
66b630d
1
Parent(s):
3f7a5e0
Refactor: Move device definitions to config file
Browse files- lib/config.py +11 -0
- lib/model.py +5 -8
lib/config.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
# -*- coding: utf-8 -*-
|
3 |
|
4 |
from pathlib import Path
|
|
|
5 |
|
6 |
# -->> Tunables <<---------------------
|
7 |
|
@@ -23,6 +24,16 @@ TRANSCRIPTS_DIR = MEDIA_DIR / "Transcriptions"
|
|
23 |
AUDIO_EXT = ".mp3"
|
24 |
TEXT_EXT = ".txt"
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
# -->> API <<--------------------------
|
27 |
|
28 |
|
|
|
2 |
# -*- coding: utf-8 -*-
|
3 |
|
4 |
from pathlib import Path
|
5 |
+
import torch
|
6 |
|
7 |
# -->> Tunables <<---------------------
|
8 |
|
|
|
24 |
AUDIO_EXT = ".mp3"
|
25 |
TEXT_EXT = ".txt"
|
26 |
|
27 |
+
# Model parameters
|
28 |
+
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
29 |
+
BATCH_SIZE = 16
|
30 |
+
|
31 |
+
if DEVICE == "cuda":
|
32 |
+
COMPUTE_TYPE = "float16"
|
33 |
+
else:
|
34 |
+
COMPUTE_TYPE = "int8"
|
35 |
+
|
36 |
+
print("Using device:", DEVICE)
|
37 |
# -->> API <<--------------------------
|
38 |
|
39 |
|
lib/model.py
CHANGED
@@ -6,17 +6,14 @@ from time import time
|
|
6 |
import torch
|
7 |
import whisperx as wx
|
8 |
|
|
|
|
|
|
|
|
|
|
|
9 |
# -->> Tunables <<---------------------
|
10 |
|
11 |
-
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
12 |
-
BATCH_SIZE = 16
|
13 |
|
14 |
-
if DEVICE == "cuda":
|
15 |
-
COMPUTE_TYPE = "float16"
|
16 |
-
else:
|
17 |
-
COMPUTE_TYPE = "int8"
|
18 |
-
|
19 |
-
print("Using device:", DEVICE)
|
20 |
# -->> Definitions <<------------------
|
21 |
|
22 |
|
|
|
6 |
import torch
|
7 |
import whisperx as wx
|
8 |
|
9 |
+
from .config import (
|
10 |
+
DEVICE,
|
11 |
+
COMPUTE_TYPE,
|
12 |
+
BATCH_SIZE,
|
13 |
+
)
|
14 |
# -->> Tunables <<---------------------
|
15 |
|
|
|
|
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
# -->> Definitions <<------------------
|
18 |
|
19 |
|